chore: move to eslint v9 (#7041)
- Upgrades eslint from v8 to v9 - Upgrades all other eslint packages. We will have to do a new full-project lint, as new rules have been added - Upgrades husky from v8 to v9 - Upgrades lint-staged from v14 to v15 - Moves the old .eslintrc.cjs file format to the new eslint.config.js flat file format. Previously, we were very specific regarding which rules are applied to which files. Now that `extends` is no longer a thing, I have to use deepMerge & imports instead. This is rather uncommon and is not a documented pattern - e.g. typescript-eslint docs want us to add the default typescript-eslint rules to the top-level & then disable it in files using the disable-typechecked config. However, I hate this opt-out approach. The way I did it here adds a lot of clarity as to which rules are applied to which files, and is pretty easy to read. Much less black magic ## .eslintignore These files are no longer supported (see https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files). I moved the entries to the ignores property in the eslint config. => one less file in each package folder!
This commit is contained in:
37
packages/eslint-plugin/index.mjs
Normal file
37
packages/eslint-plugin/index.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import noJsxImportStatements from './customRules/no-jsx-import-statements.js'
|
||||
import noNonRetryableAssertions from './customRules/no-non-retryable-assertions.js'
|
||||
import noRelativeMonorepoImports from './customRules/no-relative-monorepo-imports.js'
|
||||
import noImportsFromExportsDir from './customRules/no-imports-from-exports-dir.js'
|
||||
import noFlakyAssertions from './customRules/no-flaky-assertions.js'
|
||||
|
||||
|
||||
/**
|
||||
* @type {import('eslint').ESLint.Plugin}
|
||||
*/
|
||||
const index = {
|
||||
rules: {
|
||||
'no-jsx-import-statements': noJsxImportStatements,
|
||||
'no-non-retryable-assertions': noNonRetryableAssertions,
|
||||
'no-relative-monorepo-imports': noRelativeMonorepoImports,
|
||||
'no-imports-from-exports-dir': noImportsFromExportsDir,
|
||||
'no-flaky-assertions': noFlakyAssertions,
|
||||
'no-wait-function': {
|
||||
create: function (context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
// Check if the function being called is named "wait"
|
||||
if (node.callee.name === 'wait') {
|
||||
context.report({
|
||||
node,
|
||||
message:
|
||||
'Usage of "wait" function is discouraged as it\'s flaky. Proper assertions should be used instead.',
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default index
|
||||
Reference in New Issue
Block a user