mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-11-03 15:11:07 +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
@@ -1,34 +1,44 @@
|
||||
// Copyright 2017-2026 @pezkuwi/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// @ts-expect-error No definition for this one
|
||||
import { fixupPluginRules } from '@eslint/compat';
|
||||
import eslintJs from '@eslint/js';
|
||||
import stylisticPlugin from '@stylistic/eslint-plugin';
|
||||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
// @ts-expect-error No definition for this one
|
||||
import standardConfig from 'eslint-config-standard';
|
||||
import deprecationPlugin from 'eslint-plugin-deprecation';
|
||||
// @ts-expect-error No definition for this one
|
||||
import headerPlugin from 'eslint-plugin-header';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
// @ts-expect-error No definition for this one
|
||||
import importNewlinesPlugin from 'eslint-plugin-import-newlines';
|
||||
// @ts-expect-error No definition for this one
|
||||
import importPlugin from 'eslint-plugin-import-x';
|
||||
import jestPlugin from 'eslint-plugin-jest';
|
||||
// @ts-expect-error No definition for this one
|
||||
import nPlugin from 'eslint-plugin-n';
|
||||
// @ts-expect-error No definition for this one
|
||||
import promisePlugin from 'eslint-plugin-promise';
|
||||
import reactPlugin from 'eslint-plugin-react';
|
||||
// @ts-expect-error No definition for this one
|
||||
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
||||
// @ts-expect-error No definition for this one
|
||||
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
||||
// @ts-expect-error No definition for this one
|
||||
import sortDestructureKeysPlugin from 'eslint-plugin-sort-destructure-keys';
|
||||
import globals from 'globals';
|
||||
|
||||
import { overrideAll, overrideJs, overrideJsx, overrideSpec } from './eslint.rules.js';
|
||||
import { standardRules } from './eslint.standard.js';
|
||||
|
||||
/**
|
||||
* eslint-plugin-header declares no options schema, and eslint 9+ rejects
|
||||
* options for a rule without one. `schema: false` is how a rule says it
|
||||
* validates its own options; the rule itself is unchanged.
|
||||
*/
|
||||
const headerPluginFixed = {
|
||||
...headerPlugin,
|
||||
rules: {
|
||||
header: {
|
||||
...headerPlugin.rules.header,
|
||||
meta: { ...headerPlugin.rules.header.meta, schema: false }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const EXT_JS = ['.cjs', '.js', '.mjs'];
|
||||
const EXT_TS = ['.ts', '.tsx'];
|
||||
@@ -82,23 +92,27 @@ export default [
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
'@stylistic': stylisticPlugin,
|
||||
'@typescript-eslint': tsPlugin,
|
||||
deprecation: deprecationPlugin,
|
||||
header: headerPlugin,
|
||||
import: importPlugin,
|
||||
// eslint-plugin-header reports at the first token after the leading
|
||||
// comments, so a generated file's /* eslint-disable */ covers it; the
|
||||
// maintained fork reports at line 1 instead. The compat layer supplies the
|
||||
// context methods eslint 10 removed; headerPluginFixed, the options schema.
|
||||
header: fixupPluginRules(headerPluginFixed),
|
||||
'import-newlines': importNewlinesPlugin,
|
||||
'import-x': importPlugin,
|
||||
n: nPlugin,
|
||||
promise: promisePlugin,
|
||||
'simple-import-sort': simpleImportSortPlugin,
|
||||
'sort-destructure-keys': sortDestructureKeysPlugin
|
||||
},
|
||||
settings: {
|
||||
'import/extensions': EXT_ALL,
|
||||
'import/parsers': {
|
||||
'import-x/extensions': EXT_ALL,
|
||||
'import-x/parsers': {
|
||||
'@typescript-eslint/parser': EXT_TS,
|
||||
espree: EXT_JS
|
||||
},
|
||||
'import/resolver': {
|
||||
'import-x/resolver': {
|
||||
node: {
|
||||
extensions: EXT_ALL
|
||||
},
|
||||
@@ -112,7 +126,7 @@ export default [
|
||||
files: extsToGlobs(EXT_ALL),
|
||||
rules: {
|
||||
...eslintJs.configs.recommended.rules,
|
||||
...standardConfig.rules,
|
||||
...standardRules,
|
||||
...tsPlugin.configs['recommended-type-checked'].rules,
|
||||
...tsPlugin.configs['stylistic-type-checked'].rules,
|
||||
...overrideAll
|
||||
@@ -130,7 +144,9 @@ export default [
|
||||
'**/use*.ts'
|
||||
],
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
// eslint-plugin-react still calls context methods eslint 10 removed
|
||||
// (getFilename and others); the compat layer provides them.
|
||||
react: fixupPluginRules(reactPlugin),
|
||||
'react-hooks': reactHooksPlugin
|
||||
},
|
||||
rules: {
|
||||
|
||||
Reference in new issue
Block a user