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:
Satoshi Qazi Muhammed authored and SatoshiQaziMuhammed committed 2026-10-09 08:56:18 +04:00
1 parent 9e6a1ab2a2
commit f9f04f6adc
17 files changed
+3401 -3570

No files matched your search

+4 -4
View File
@@ -164,7 +164,7 @@ function assertMatchStr (value: unknown, check: string | RegExp): void {
*
* @see https://github.com/facebook/jest/blob/a49c88610e49a3242576160740a32a2fe11161e1/packages/expect/src/asymmetricMatchers.ts#L103-L133
*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
function assertInstanceOf (value: unknown, Clazz: Function): void {
assert.ok(
(Clazz === Array && Array.isArray(value)) ||
@@ -188,7 +188,7 @@ function assertInstanceOf (value: unknown, Clazz: Function): void {
* @param {string | unknown[]} value
* @param {string} check
*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
function assertIncludes (value: string | unknown[], [check, Clazz]: [string, Function]): void {
assertInstanceOf(value, Clazz);
assert.ok(value?.includes(check), `${value as string} does not include ${check}`);
@@ -201,7 +201,7 @@ function assertIncludes (value: string | unknown[], [check, Clazz]: [string, Fun
**/
export function expect () {
const rootMatchers = {
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
any: (Clazz: Function) => new Matcher(assertInstanceOf, Clazz),
anything: () => new Matcher(assertNonNullish),
arrayContaining: (check: string) => new Matcher(assertIncludes, [check, Array]),
@@ -229,7 +229,7 @@ export function expect () {
toBe: (other: unknown) => assert.strictEqual(value, other),
toBeDefined: () => assert.ok(value !== undefined),
toBeFalsy: () => assert.ok(!value),
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
toBeInstanceOf: (Clazz: Function) => assertInstanceOf(value, Clazz),
toBeNull: (value: unknown) => assert.ok(value === null),
toBeTruthy: () => assert.ok(value),
+1 -1
View File
@@ -32,7 +32,7 @@ function extendMock <F extends AnyFn> (mocked: WithMock<F>) {
//
// Effectively the casts below ensure that our WithMock<*> aligns
// on a high-level to what we use via private type...
const spy = (mocked as unknown as ReturnType<typeof mock['fn']>);
const spy = mocked as unknown as ReturnType<typeof mock['fn']>;
return enhanceObj(enhanceObj(mocked, {
mockImplementation: <F extends AnyFn> (fn: F): void => {
+6 -6
View File
@@ -35,10 +35,10 @@ const MINUTE = 60 * 1000;
* Wraps either describe or it with relevant .only, .skip, .todo & .each helpers,
* shimming it into a Jest-compatible environment.
*
* @param {} fn
* Describe and It have the same shape, so one return type serves both.
*/
function createWrapper <T extends WrapFn> (fn: T, defaultTimeout: number): Describe | It {
const wrap = (opts: WrapOpts) => (name: string, exec: () => void | Promise<void>, timeout?: number) => fn(name, { ...opts, timeout: (timeout || defaultTimeout) }, exec) as unknown as void;
function createWrapper (fn: WrapFn, defaultTimeout: number): Describe {
const wrap = (opts: WrapOpts): TestFn => (name: string, exec: () => void | Promise<void>, timeout?: number) => fn(name, { ...opts, timeout: (timeout || defaultTimeout) }, exec) as unknown as void;
// Ensure that we have consistent helpers on the function. These are not consistently
// applied accross all node:test versions, latest has all, so always apply ours.
@@ -47,7 +47,7 @@ function createWrapper <T extends WrapFn> (fn: T, defaultTimeout: number): Descr
only: wrap({ only: true }),
skip: wrap({ skip: true }),
todo: wrap({ todo: true })
}) as Describe | It;
});
}
/**
@@ -56,7 +56,7 @@ function createWrapper <T extends WrapFn> (fn: T, defaultTimeout: number): Descr
**/
export function suite (): { describe: Describe; it: It } {
return {
describe: createWrapper(describe, 60 * MINUTE) as Describe,
it: createWrapper(it, 2 * MINUTE) as It
describe: createWrapper(describe, 60 * MINUTE),
it: createWrapper(it, 2 * MINUTE)
};
}
-2
View File
@@ -1,8 +1,6 @@
// Copyright 2017-2026 @pezkuwi/dev-test authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable no-var */
import type { expect } from './env/expect.js';
import type { jest } from './env/jest.js';
import type { lifecycle } from './env/lifecycle.js';
+2 -2
View File
@@ -6,7 +6,7 @@ export type AnyFn = (...args: any[]) => any;
export type BaseObj = Record<string, unknown>;
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export type BaseFn = Function;
export type StubFn = (...args: unknown[]) => unknown;
@@ -25,4 +25,4 @@ export type WithMock<F extends AnyFn> = F & {
resetCalls: () => void;
restore: () => void;
}
}
};
+1 -1
View File
@@ -27,7 +27,7 @@ function createStub <N extends readonly string[]> (keys: N, creator: (key: strin
obj[key] ??= creator(key);
return obj;
}, {}) as unknown as { [K in N[number]]: StubFn };
}, {}) as unknown as Record<N[number], StubFn>;
}
/**
+33 -17
View File
@@ -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: {
+89 -83
View File
@@ -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'
};
+585
View File
@@ -0,0 +1,585 @@
// 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'
]
};
+26 -26
View File
@@ -3,7 +3,7 @@
"bugs": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/issues",
"description": "A collection of shared CI scripts and development environment used by @pezkuwi projects",
"engines": {
"node": ">=18"
"node": ">=20.19"
},
"homepage": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/tree/master/packages/dev#readme",
"license": "Apache-2.0",
@@ -49,47 +49,47 @@
"./rootJs/testJson.json": "./src/rootJs/testJson.json"
},
"dependencies": {
"@eslint/js": "^8.56.0",
"@eslint/compat": "^2.1.1",
"@eslint/js": "^10.0.1",
"@pezkuwi/dev-test": "^0.85.12",
"@pezkuwi/dev-ts": "^0.85.12",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-commonjs": "^29.0.3",
"@rollup/plugin-dynamic-import-vars": "^2.1.5",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.1",
"@rollup/plugin-node-resolve": "^16.0.3",
"@stylistic/eslint-plugin": "^5.10.0",
"@tsconfig/strictest": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"eslint": "^8.56.0",
"eslint-config-standard": "^17.1.0",
"@typescript-eslint/eslint-plugin": "^8.71.1",
"@typescript-eslint/parser": "^8.71.1",
"eslint": "^10.12.0",
"eslint-import-resolver-node": "^0.3.9",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-import-resolver-typescript": "^4.4.5",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import-newlines": "^1.3.4",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"espree": "^9.6.1",
"eslint-plugin-import-newlines": "^2.0.0",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-jest": "^29.16.6",
"eslint-plugin-n": "^18.4.1",
"eslint-plugin-promise": "^7.3.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-simple-import-sort": "^14.0.0",
"eslint-plugin-sort-destructure-keys": "^3.0.0",
"espree": "^11.2.0",
"gh-pages": "^6.1.1",
"gh-release": "^7.0.2",
"globals": "^13.24.0",
"gh-release": "^8.1.0",
"globals": "^17.13.0",
"json5": "^2.2.3",
"madge": "^6.1.0",
"madge": "^8.0.0",
"rollup": "^4.9.6",
"rollup-plugin-cleanup": "^3.2.1",
"tslib": "^2.7.0",
"typescript": "^5.5.4",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.10.0",
"webpack-cli": "^7.2.3",
"webpack-dev-server": "^6.0.0",
"webpack-merge": "^6.0.1",
"webpack-subresource-integrity": "^5.2.0-rc.1",
"yargs": "^17.7.2"
},
@@ -1119,8 +1119,8 @@ function lintInput (dir) {
// file will also be caught in the net, i.e. we expect all files to conform
if (n === 0 && (
!/\/\/ Copyright .* @pezkuwi\//.test(l) &&
!/\/\/ Auto-generated via `/.test(l) &&
!/#!\/usr\/bin\/env node/.test(l)
!l.includes('// Auto-generated via `') &&
!l.includes('#!/usr/bin/env node')
)) {
return createError(full, l, n, 'Invalid header definition');
}
@@ -1281,7 +1281,7 @@ function extractPackageInfoImports (filepath, withDetectImport) {
.readFileSync(filepath, { encoding: 'utf-8' })
.split('\n')
.forEach((l) => {
const match = l.match(/import \{ packageInfo as (.*) \}/);
const match = /import \{ packageInfo as (.*) \}/.exec(l);
if (match) {
otherImports.push(l);
@@ -1290,8 +1290,8 @@ function extractPackageInfoImports (filepath, withDetectImport) {
});
otherImports.sort((a, b) => {
const am = a.match(/\} from '(.*)';/);
const bm = b.match(/\} from '(.*)';/);
const am = /\} from '(.*)';/.exec(a);
const bm = /\} from '(.*)';/.exec(b);
if (!am) {
throw new Error(`Unable to extract from import from ${a}`);
@@ -122,7 +122,7 @@ function getFilename (r) {
.split('\n')
.map((l) => l.trim())
.filter((l) => l.startsWith('at ') && (l.includes('.spec.') || l.includes('.test.')))
.map((l) => l.match(/\(.*:\d\d?:\d\d?\)$/)?.[0])
.map((l) => (/\(.*:\d\d?:\d\d?\)$/.exec(l))?.[0])
.map((l) => l?.replace('(', '')?.replace(')', ''));
if (stack.length) {
@@ -186,7 +186,7 @@ function complete () {
if (typeof r === 'string') {
console.log(r); // Node.js <= 18.14
} else if (r.file && r.file.includes('@pezkuwi/dev/scripts')) {
} else if (r.file?.includes('@pezkuwi/dev/scripts')) {
// Ignore internal diagnostics
} else {
if (lastFilename !== r.file) {
@@ -328,11 +328,11 @@ if (isMainThread) {
} else {
run({ files: workerData.files, timeout: 3_600_000 })
.on('data', () => undefined)
.on('end', () => parentPort && parentPort.postMessage(stats))
.on('end', () => parentPort?.postMessage(stats))
.on('test:coverage', () => undefined)
.on('test:diagnostic', (/** @type {DiagStat} */data) => {
stats.diag.push(data);
parentPort && parentPort.postMessage({ data: stats, type: 'result' });
parentPort?.postMessage({ data: stats, type: 'result' });
})
.on('test:fail', (/** @type {FailStat} */ data) => {
const statFail = structuredClone(data);
@@ -343,7 +343,7 @@ if (isMainThread) {
stats.fail.push(statFail);
stats.total++;
parentPort && parentPort.postMessage({ data: 'x', type: 'progress' });
parentPort?.postMessage({ data: 'x', type: 'progress' });
if (bail) {
complete();
@@ -361,7 +361,7 @@ if (isMainThread) {
}
stats.total++;
parentPort && parentPort.postMessage({ data: symbol, type: 'progress' });
parentPort?.postMessage({ data: symbol, type: 'progress' });
})
.on('test:plan', () => undefined)
.on('test:start', () => undefined);
+2 -2
View File
@@ -83,7 +83,7 @@ export function copyDirSync (src, dest, include, exclude) {
if (fs.statSync(srcPath).isDirectory()) {
copyDirSync(srcPath, path.join(dest, file), include, exclude);
} else if (!include?.length || include.some((e) => file.endsWith(e))) {
if (!exclude || !exclude.some((e) => file.endsWith(e))) {
if (!exclude?.some((e) => file.endsWith(e))) {
copyFileSync(srcPath, dest);
}
}
@@ -480,7 +480,7 @@ export function topoSort (dirs) {
visited[key] = true;
node.vertices.forEach((i) => {
if (ancestors.indexOf(i) >= 0) {
if (ancestors.includes(i)) {
console.log('CIRCULAR: closed chain : ' + i + ' is in ' + id);
if (nodes[id].vertices.includes(i)) {
+10 -1
View File
@@ -11,4 +11,13 @@ import type * as testRoot from './root.js';
import testRootBuild from '../build/cjs/root.js';
import { runTests } from './rootTests.js';
runTests(testRootBuild as unknown as typeof testRoot);
/**
* The CommonJS build is untyped until it is built, and lint runs both before
* and after the build. Casting from unknown here is needed either way, so the
* outcome does not depend on whether build/ exists.
*/
function asRoot (build: unknown): typeof testRoot {
return build as typeof testRoot;
}
runTests(asRoot(testRootBuild));
+1 -1
View File
@@ -7,7 +7,7 @@ export class Clazz {
readonly and: number;
static staticProperty = 'foobar';
static staticFunction = (): string|null => Clazz.staticProperty;
static staticFunction = (): string | null => Clazz.staticProperty;
/**
* @param and the number we should and with
-1
View File
@@ -22,7 +22,6 @@ export async function dynamic (a: number, b: number): Promise<number> {
// and CJS output (a './dynamic' import would be different otherwise)
const { sum } = await import('@pezkuwi/dev/rootJs/dynamic.mjs');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return sum(a, b);
}
+2630 -3412
View File
File diff suppressed because it is too large. Load diff