mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-10-30 14:29:49 +00:00
Move the toolchain to eslint 10, typescript-eslint 8 and current plugins
eslint 8 and typescript-eslint 6 are past their support, and the webpack dev server chain carried the dependency alerts every repository using this package inherited. Upstream @polkadot/dev still pins the same versions, so this leaves it on purpose. The rules are carried over with their options, so the lint means what it meant: - eslint-config-standard 17 (written for eslint 8) is replaced by its 161 rules in config/eslint.standard.js, with their options. Its 48 formatting rules, deprecated in eslint core, are the same rules in @stylistic; no-new-object and no-new-symbol are no-object-constructor and no-new-native-nonconstructor; import/* is import-x/*. - eslint-plugin-import (eslint <= 9) is eslint-plugin-import-x; eslint-plugin-deprecation is @typescript-eslint/no-deprecated; the formatting rules of core, typescript-eslint and eslint-plugin-react used in eslint.rules.js are their @stylistic versions with the same options. - typescript-eslint 8's preset swaps core no-unused-expressions for its own with default options; standard's (short circuit, ternary and tagged templates allowed) are carried over to it. - eslint-plugin-react and eslint-plugin-header still call context methods eslint 10 removed; @eslint/compat's fixupPluginRules supplies them. The header rule also gets `schema: false`, as eslint 9+ rejects options for a rule with no schema. The original header plugin stays rather than its fork: it reports at the first token after leading comments, so a generated file's /* eslint-disable */ still covers it, as it always has. The effective config was compared rule by rule (--print-config) for .ts, .tsx, .spec.ts and .mjs files before and after. Every rule that left has its successor active; option differences are eslint 10 spelling out defaults. New rules come from the eslint 10, typescript-eslint 8 and react-hooks 7 presets. no-inner-declarations left eslint's preset upstream. Also current: webpack-dev-server 6, webpack-cli 7, webpack-merge 6, rollup plugins, madge 8, gh-release 8, globals 17, espree 11; Node >= 20.19 for the dev package, which eslint 10 requires. In this repository the new rules found: Function types now named by no-unsafe-function-type; optional chains, includes() and RegExp#exec where they say the same thing; createWrapper returns Describe, so its three casts were redundant; rootCjs.spec casts through unknown, so the lint result does not depend on whether build/ exists. lint, build and test (149 passed) pass, and lint leaves the tree unchanged with and without a build.
This commit is contained in:
1 parent
e73c5c953c
commit
bda5d06bac
17 files changed
+3401
-3570
No files matched your search
@@ -59,68 +59,17 @@ function getHeaderPattern () {
|
||||
|
||||
export const overrideAll = {
|
||||
...FIXME,
|
||||
// the next 2 enforce isolatedModules & verbatimModuleSyntax
|
||||
'@typescript-eslint/consistent-type-exports': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/indent': ['error', 2],
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
// ts itself checks and ignores those starting with _, align the linting
|
||||
'@typescript-eslint/no-unused-vars': ['error', {
|
||||
args: 'all',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'all',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
destructuredArrayIgnorePattern: '^_',
|
||||
vars: 'all',
|
||||
varsIgnorePattern: '^_'
|
||||
}],
|
||||
'@typescript-eslint/type-annotation-spacing': 'error',
|
||||
'arrow-parens': ['error', 'always'],
|
||||
'brace-style': ['error', '1tbs'],
|
||||
curly: ['error', 'all'],
|
||||
'default-param-last': 'off', // conflicts with TS version
|
||||
'deprecation/deprecation': 'error',
|
||||
'dot-notation': 'off', // conflicts with TS version
|
||||
'func-style': ['error', 'declaration', {
|
||||
allowArrowFunctions: true
|
||||
}],
|
||||
// this does help with declarations, but also
|
||||
// applies to invocations, which is an issue...
|
||||
// 'function-paren-newline': ['error', 'never'],
|
||||
'function-call-argument-newline': ['error', 'consistent'],
|
||||
'header/header': ['error', 'line', [
|
||||
{ pattern: getHeaderPattern() },
|
||||
' SPDX-License-Identifier: Apache-2.0'
|
||||
], 2],
|
||||
'import-newlines/enforce': ['error', {
|
||||
forceSingleLine: true,
|
||||
items: 2048
|
||||
}],
|
||||
'import/export': 'error',
|
||||
'import/extensions': ['error', 'ignorePackages', {
|
||||
cjs: 'always',
|
||||
js: 'always',
|
||||
json: 'always',
|
||||
jsx: 'never',
|
||||
mjs: 'always',
|
||||
ts: 'never',
|
||||
tsx: 'never'
|
||||
}],
|
||||
'import/first': 'error',
|
||||
'import/newline-after-import': 'error',
|
||||
'import/no-duplicates': 'error',
|
||||
'import/order': 'off', // conflicts with simple-import-sort
|
||||
indent: 'off', // required as 'off' since typescript-eslint has own versions
|
||||
'no-extra-semi': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'no-use-before-define': 'off',
|
||||
'object-curly-newline': ['error', {
|
||||
'@stylistic/arrow-parens': ['error', 'always'],
|
||||
'@stylistic/brace-style': ['error', '1tbs'],
|
||||
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
|
||||
'@stylistic/indent': ['error', 2],
|
||||
'@stylistic/no-extra-semi': 'error',
|
||||
'@stylistic/object-curly-newline': ['error', {
|
||||
ExportDeclaration: { minProperties: 2048 },
|
||||
ImportDeclaration: { minProperties: 2048 },
|
||||
ObjectPattern: { minProperties: 2048 }
|
||||
}],
|
||||
'padding-line-between-statements': [
|
||||
'@stylistic/padding-line-between-statements': [
|
||||
'error',
|
||||
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
|
||||
{ blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] },
|
||||
@@ -135,7 +84,74 @@ export const overrideAll = {
|
||||
{ blankLine: 'always', next: '*', prev: 'import' },
|
||||
{ blankLine: 'any', next: 'import', prev: 'import' }
|
||||
],
|
||||
semi: ['error', 'always'],
|
||||
'@stylistic/semi': ['error', 'always'],
|
||||
'@stylistic/spaced-comment': ['error', 'always', {
|
||||
block: {
|
||||
// pure export helpers
|
||||
markers: ['#__PURE__']
|
||||
},
|
||||
line: {
|
||||
// TS reference types
|
||||
markers: ['/ <reference']
|
||||
}
|
||||
}],
|
||||
'@stylistic/type-annotation-spacing': 'error',
|
||||
// the next 2 enforce isolatedModules & verbatimModuleSyntax
|
||||
'@typescript-eslint/consistent-type-exports': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/no-deprecated': 'error',
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
// standard's options for the core rule, which the TypeScript preset turns off
|
||||
// in favour of this one (with defaults that reject a && b() and a ? b() : c())
|
||||
'@typescript-eslint/no-unused-expressions': ['error', {
|
||||
allowShortCircuit: true,
|
||||
allowTaggedTemplates: true,
|
||||
allowTernary: true
|
||||
}],
|
||||
// ts itself checks and ignores those starting with _, align the linting
|
||||
'@typescript-eslint/no-unused-vars': ['error', {
|
||||
args: 'all',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'all',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
destructuredArrayIgnorePattern: '^_',
|
||||
vars: 'all',
|
||||
varsIgnorePattern: '^_'
|
||||
}],
|
||||
curly: ['error', 'all'],
|
||||
'default-param-last': 'off', // conflicts with TS version
|
||||
'dot-notation': 'off', // conflicts with TS version
|
||||
'func-style': ['error', 'declaration', {
|
||||
allowArrowFunctions: true
|
||||
}],
|
||||
// this does help with declarations, but also
|
||||
// applies to invocations, which is an issue...
|
||||
// '@stylistic/function-paren-newline': ['error', 'never'],
|
||||
'header/header': ['error', 'line', [
|
||||
{ pattern: getHeaderPattern() },
|
||||
' SPDX-License-Identifier: Apache-2.0'
|
||||
], 2],
|
||||
'import-newlines/enforce': ['error', {
|
||||
forceSingleLine: true,
|
||||
items: 2048
|
||||
}],
|
||||
'import-x/export': 'error',
|
||||
'import-x/extensions': ['error', 'ignorePackages', {
|
||||
cjs: 'always',
|
||||
js: 'always',
|
||||
json: 'always',
|
||||
jsx: 'never',
|
||||
mjs: 'always',
|
||||
ts: 'never',
|
||||
tsx: 'never'
|
||||
}],
|
||||
'import-x/first': 'error',
|
||||
'import-x/newline-after-import': 'error',
|
||||
'import-x/no-duplicates': 'error',
|
||||
'import-x/order': 'off', // conflicts with simple-import-sort
|
||||
'no-unused-vars': 'off',
|
||||
'no-use-before-define': 'off',
|
||||
'simple-import-sort/exports': 'error',
|
||||
'simple-import-sort/imports': ['error', {
|
||||
groups: [
|
||||
@@ -150,55 +166,45 @@ export const overrideAll = {
|
||||
'sort-destructure-keys/sort-destructure-keys': ['error', {
|
||||
caseSensitive: true
|
||||
}],
|
||||
'sort-keys': 'error',
|
||||
'spaced-comment': ['error', 'always', {
|
||||
block: {
|
||||
// pure export helpers
|
||||
markers: ['#__PURE__']
|
||||
},
|
||||
line: {
|
||||
// TS reference types
|
||||
markers: ['/ <reference']
|
||||
}
|
||||
}]
|
||||
'sort-keys': 'error'
|
||||
};
|
||||
|
||||
export const overrideJsx = {
|
||||
'jsx-quotes': ['error', 'prefer-single'],
|
||||
// swap from recommended warning to error
|
||||
'react-hooks/exhaustive-deps': 'error',
|
||||
'react/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
|
||||
'react/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
|
||||
'react/jsx-fragments': 'error',
|
||||
'react/jsx-max-props-per-line': ['warn', {
|
||||
'@stylistic/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
|
||||
'@stylistic/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
|
||||
'@stylistic/jsx-max-props-per-line': ['warn', {
|
||||
maximum: 1,
|
||||
when: 'always'
|
||||
}],
|
||||
'react/jsx-newline': ['error', {
|
||||
'@stylistic/jsx-newline': ['error', {
|
||||
prevent: true
|
||||
}],
|
||||
'react/jsx-no-bind': 'error',
|
||||
'react/jsx-props-no-multi-spaces': 'error',
|
||||
'react/jsx-sort-props': ['warn', {
|
||||
'@stylistic/jsx-props-no-multi-spaces': 'error',
|
||||
'@stylistic/jsx-quotes': ['error', 'prefer-single'],
|
||||
'@stylistic/jsx-sort-props': ['warn', {
|
||||
noSortAlphabetically: false
|
||||
}],
|
||||
'react/jsx-tag-spacing': ['error', {
|
||||
'@stylistic/jsx-tag-spacing': ['error', {
|
||||
afterOpening: 'never',
|
||||
beforeClosing: 'never',
|
||||
beforeSelfClosing: 'always',
|
||||
closingSlash: 'never'
|
||||
}],
|
||||
// swap from recommended warning to error
|
||||
'react-hooks/exhaustive-deps': 'error',
|
||||
'react/jsx-fragments': 'error',
|
||||
'react/jsx-no-bind': 'error',
|
||||
'react/prop-types': 'off' // this is a completely broken rule
|
||||
};
|
||||
|
||||
export const overrideJs = {
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-unsafe-argument': 'off',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'off',
|
||||
'@typescript-eslint/no-unsafe-call': 'off',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
||||
'@typescript-eslint/no-unsafe-return': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'@typescript-eslint/restrict-plus-operands': 'off',
|
||||
'@typescript-eslint/restrict-template-expressions': 'off'
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user