-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1697: Update ESLint and related packages r=curquiza a=flevi29 # Pull Request ## Why? ESLint received major upgrade from 8 -> 9. With this comes a new flat config. Also rules have been changed a little bit. This PR updates ESLint, related packages, and adapts config. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: F. Levi <[email protected]>
- Loading branch information
Showing
9 changed files
with
446 additions
and
331 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const eslint = require("@eslint/js"); | ||
const tseslint = require("typescript-eslint"); | ||
const tsdoc = require("eslint-plugin-tsdoc"); | ||
const jest = require("eslint-plugin-jest"); | ||
const globals = require("globals"); | ||
const prettier = require("eslint-config-prettier"); | ||
|
||
/** @type {import("eslint").Linter.Config[]} */ | ||
module.exports = [ | ||
{ | ||
ignores: ["dist/", "tests/env/", "coverage/", "playgrounds/", "docs/"], | ||
}, | ||
// Standard linting for js files | ||
{ | ||
files: ["**/*.js"], | ||
languageOptions: { sourceType: "script", globals: globals.node }, | ||
plugins: { eslint }, | ||
rules: eslint.configs.recommended.rules, | ||
}, | ||
// TypeScript linting for ts files | ||
...tseslint.configs.recommendedTypeChecked.map((config) => ({ | ||
...config, | ||
files: ["**/*.ts"], | ||
languageOptions: { | ||
...config.languageOptions, | ||
globals: { ...config.languageOptions?.globals, ...globals.node }, | ||
parserOptions: { | ||
...config.languageOptions?.parserOptions, | ||
project: "tsconfig.eslint.json", | ||
}, | ||
}, | ||
plugins: { ...config.plugins, tsdoc }, | ||
rules: { | ||
...config.rules, | ||
"tsdoc/syntax": "error", | ||
// @TODO: Remove the ones between "~~", adapt code | ||
// ~~ | ||
"@typescript-eslint/prefer-as-const": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
// ~~ | ||
"@typescript-eslint/array-type": ["warn", { default: "array-simple" }], | ||
// @TODO: Should be careful with this rule, should leave it be and disable | ||
// it within files where necessary with explanations | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern | ||
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern | ||
{ args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, | ||
], | ||
// @TODO: Not recommended to disable rule, should instead disable locally | ||
// with explanation | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
}, | ||
})), | ||
// Jest linting for test files | ||
{ | ||
files: ["tests/*.ts"], | ||
...jest.configs["flat/recommended"], | ||
// languageOptions: { | ||
// ...jest.configs['flat/recommended'].languageOptions, | ||
// globals: globals.jest, | ||
// }, | ||
rules: { | ||
...jest.configs["flat/recommended"].rules, | ||
// @TODO: Remove all of these rules and adapt code! | ||
"jest/no-disabled-tests": "off", | ||
"jest/expect-expect": "off", | ||
"jest/no-conditional-expect": "off", | ||
"jest/valid-title": "off", | ||
"jest/no-jasmine-globals": "off", | ||
"jest/valid-expect-in-promise": "off", | ||
"jest/valid-expect": "off", | ||
"jest/no-alias-methods": "off", | ||
}, | ||
}, | ||
prettier, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,8 @@ | |
"style:fix": "yarn fmt:fix && yarn lint:fix", | ||
"fmt": "prettier -c ./**/*.{js,ts}", | ||
"fmt:fix": "prettier -w ./**/*.{js,ts}", | ||
"lint": "eslint --ext .js,.ts,.tsx .", | ||
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"typingsheader": "node scripts/build.js" | ||
}, | ||
"files": [ | ||
|
@@ -75,18 +75,19 @@ | |
"devDependencies": { | ||
"@babel/core": "^7.25.2", | ||
"@babel/preset-env": "^7.25.4", | ||
"@eslint/js": "^9.11.1", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "28.0.0", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@rollup/plugin-node-resolve": "15.3.0", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/jest": "^29.5.11", | ||
"@typescript-eslint/eslint-plugin": "^6.19.0", | ||
"@typescript-eslint/parser": "^6.19.0", | ||
"brotli-size": "^4.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint": "^9.11.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^27.6.3", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"eslint-plugin-jest": "^28.8.0", | ||
"eslint-plugin-tsdoc": "^0.3.0", | ||
"globals": "^15.9.0", | ||
"gzip-size": "^6.0.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
|
@@ -104,7 +105,8 @@ | |
"shx": "^0.3.2", | ||
"ts-jest": "^29.2.5", | ||
"typedoc": "^0.26.7", | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.4.5", | ||
"typescript-eslint": "^8.8.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.