Files
pezkuwi-dev/packages/dev/config/eslint.standard.js
T
Satoshi Qazi Muhammed bda5d06bac 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.
2026-10-09 08:54:50 +04:00

586 lines
11 KiB
JavaScript

// Copyright 2017-2026 @pezkuwi/dev authors & contributors
// SPDX-License-Identifier: Apache-2.0
// The rules of eslint-config-standard 17.1.0 (MIT, Copyright Feross Aboukhadijeh,
// https://github.com/standard/eslint-config-standard), carried here once and with
// the same options, so the lint stays what it was: that package is written for
// eslint 8. Its formatting rules are deprecated in eslint core and continue in
// @stylistic under the same names (func-call-spacing is function-call-spacing
// there). no-new-object and no-new-symbol, deprecated too, are no-object-constructor
// and no-new-native-nonconstructor here; import/* is import-x/*.
export const standardRules = {
'@stylistic/array-bracket-spacing': [
'error',
'never'
],
'@stylistic/arrow-spacing': [
'error',
{
after: true,
before: true
}
],
'@stylistic/block-spacing': [
'error',
'always'
],
'@stylistic/brace-style': [
'error',
'1tbs',
{
allowSingleLine: true
}
],
'@stylistic/comma-dangle': [
'error',
{
arrays: 'never',
exports: 'never',
functions: 'never',
imports: 'never',
objects: 'never'
}
],
'@stylistic/comma-spacing': [
'error',
{
after: true,
before: false
}
],
'@stylistic/comma-style': [
'error',
'last'
],
'@stylistic/computed-property-spacing': [
'error',
'never',
{
enforceForClassMembers: true
}
],
'@stylistic/dot-location': [
'error',
'property'
],
'@stylistic/eol-last': 'error',
'@stylistic/function-call-spacing': [
'error',
'never'
],
'@stylistic/generator-star-spacing': [
'error',
{
after: true,
before: true
}
],
'@stylistic/indent': [
'error',
2,
{
ArrayExpression: 1,
CallExpression: {
arguments: 1
},
FunctionDeclaration: {
body: 1,
parameters: 1
},
FunctionExpression: {
body: 1,
parameters: 1
},
ImportDeclaration: 1,
MemberExpression: 1,
ObjectExpression: 1,
SwitchCase: 1,
VariableDeclarator: 1,
flatTernaryExpressions: false,
ignoreComments: false,
ignoredNodes: [
'TemplateLiteral *',
'JSXElement',
'JSXElement > *',
'JSXAttribute',
'JSXIdentifier',
'JSXNamespacedName',
'JSXMemberExpression',
'JSXSpreadAttribute',
'JSXExpressionContainer',
'JSXOpeningElement',
'JSXClosingElement',
'JSXFragment',
'JSXOpeningFragment',
'JSXClosingFragment',
'JSXText',
'JSXEmptyExpression',
'JSXSpreadChild'
],
offsetTernaryExpressions: true,
outerIIFEBody: 1
}
],
'@stylistic/key-spacing': [
'error',
{
afterColon: true,
beforeColon: false
}
],
'@stylistic/keyword-spacing': [
'error',
{
after: true,
before: true
}
],
'@stylistic/lines-between-class-members': [
'error',
'always',
{
exceptAfterSingleLine: true
}
],
'@stylistic/multiline-ternary': [
'error',
'always-multiline'
],
'@stylistic/new-parens': 'error',
'@stylistic/no-extra-parens': [
'error',
'functions'
],
'@stylistic/no-floating-decimal': 'error',
'@stylistic/no-mixed-operators': [
'error',
{
allowSamePrecedence: true,
groups: [
[
'==',
'!=',
'===',
'!==',
'>',
'>=',
'<',
'<='
],
[
'&&',
'||'
],
[
'in',
'instanceof'
]
]
}
],
'@stylistic/no-mixed-spaces-and-tabs': 'error',
'@stylistic/no-multi-spaces': 'error',
'@stylistic/no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 0,
maxEOF: 0
}
],
'@stylistic/no-tabs': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/no-whitespace-before-property': 'error',
'@stylistic/object-curly-newline': [
'error',
{
consistent: true,
multiline: true
}
],
'@stylistic/object-curly-spacing': [
'error',
'always'
],
// allowMultiplePropertiesPerLine was core's alias for allowAllPropertiesOnSameLine
// (the two were OR-ed); @stylistic only takes the latter.
'@stylistic/object-property-newline': [
'error',
{
allowAllPropertiesOnSameLine: true
}
],
'@stylistic/operator-linebreak': [
'error',
'after',
{
overrides: {
':': 'before',
'?': 'before',
'|>': 'before'
}
}
],
'@stylistic/padded-blocks': [
'error',
{
blocks: 'never',
classes: 'never',
switches: 'never'
}
],
'@stylistic/quote-props': [
'error',
'as-needed'
],
'@stylistic/quotes': [
'error',
'single',
{
allowTemplateLiterals: 'never',
avoidEscape: true
}
],
'@stylistic/rest-spread-spacing': [
'error',
'never'
],
'@stylistic/semi': [
'error',
'never'
],
'@stylistic/semi-spacing': [
'error',
{
after: true,
before: false
}
],
'@stylistic/space-before-blocks': [
'error',
'always'
],
'@stylistic/space-before-function-paren': [
'error',
'always'
],
'@stylistic/space-in-parens': [
'error',
'never'
],
'@stylistic/space-infix-ops': 'error',
'@stylistic/space-unary-ops': [
'error',
{
nonwords: false,
words: true
}
],
'@stylistic/spaced-comment': [
'error',
'always',
{
block: {
balanced: true,
exceptions: [
'*'
],
markers: [
'*package',
'!',
',',
':',
'::',
'flow-include'
]
},
line: {
markers: [
'*package',
'!',
'/',
',',
'='
]
}
}
],
'@stylistic/template-curly-spacing': [
'error',
'never'
],
'@stylistic/template-tag-spacing': [
'error',
'never'
],
'@stylistic/wrap-iife': [
'error',
'any',
{
functionPrototypeMethods: true
}
],
'@stylistic/yield-star-spacing': [
'error',
'both'
],
'accessor-pairs': [
'error',
{
enforceForClassMembers: true,
setWithoutGet: true
}
],
'array-callback-return': [
'error',
{
allowImplicit: false,
checkForEach: false
}
],
camelcase: [
'error',
{
allow: [
'^UNSAFE_'
],
ignoreGlobals: true,
properties: 'never'
}
],
'constructor-super': 'error',
curly: [
'error',
'multi-line'
],
'default-case-last': 'error',
'dot-notation': [
'error',
{
allowKeywords: true
}
],
eqeqeq: [
'error',
'always',
{
null: 'ignore'
}
],
'import-x/export': 'error',
'import-x/first': 'error',
'import-x/no-absolute-path': [
'error',
{
amd: false,
commonjs: true,
esmodule: true
}
],
'import-x/no-duplicates': 'error',
'import-x/no-named-default': 'error',
'import-x/no-webpack-loader-syntax': 'error',
'n/handle-callback-err': [
'error',
'^(err|error)$'
],
'n/no-callback-literal': 'error',
'n/no-deprecated-api': 'error',
'n/no-exports-assign': 'error',
'n/no-new-require': 'error',
'n/no-path-concat': 'error',
'n/process-exit-as-throw': 'error',
'new-cap': [
'error',
{
capIsNew: false,
newIsCap: true,
properties: true
}
],
'no-array-constructor': 'error',
'no-async-promise-executor': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-const-assign': 'error',
'no-constant-condition': [
'error',
{
checkLoops: false
}
],
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': [
'error',
{
allowEmptyCatch: true
}
],
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-eval': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-fallthrough': 'error',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-implied-eval': 'error',
'no-import-assign': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-labels': [
'error',
{
allowLoop: false,
allowSwitch: false
}
],
'no-lone-blocks': 'error',
'no-loss-of-precision': 'error',
'no-misleading-character-class': 'error',
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-native-nonconstructor': 'error',
'no-new-wrappers': 'error',
'no-obj-calls': 'error',
'no-object-constructor': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-prototype-builtins': 'error',
'no-redeclare': [
'error',
{
builtinGlobals: false
}
],
'no-regex-spaces': 'error',
'no-return-assign': [
'error',
'except-parens'
],
'no-self-assign': [
'error',
{
props: true
}
],
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'error',
'no-unneeded-ternary': [
'error',
{
defaultAssignment: false
}
],
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTaggedTemplates: true,
allowTernary: true
}
],
'no-unused-vars': [
'error',
{
args: 'none',
caughtErrors: 'none',
ignoreRestSiblings: true,
vars: 'all'
}
],
'no-use-before-define': [
'error',
{
classes: false,
functions: false,
variables: false
}
],
'no-useless-backreference': 'error',
'no-useless-call': 'error',
'no-useless-catch': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-escape': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'warn',
'no-void': 'error',
'no-with': 'error',
'object-shorthand': [
'warn',
'properties'
],
'one-var': [
'error',
{
initialized: 'never'
}
],
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': [
'error',
{
disallowRedundantWrapping: true
}
],
'promise/param-names': 'error',
'symbol-description': 'error',
'unicode-bom': [
'error',
'never'
],
'use-isnan': [
'error',
{
enforceForIndexOf: true,
enforceForSwitchCase: true
}
],
'valid-typeof': [
'error',
{
requireStringLiterals: true
}
],
yoda: [
'error',
'never'
]
};