mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-11-08 08:21:10 +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
Vendored
+4
-4
@@ -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
|
* @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 {
|
function assertInstanceOf (value: unknown, Clazz: Function): void {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
(Clazz === Array && Array.isArray(value)) ||
|
(Clazz === Array && Array.isArray(value)) ||
|
||||||
@@ -188,7 +188,7 @@ function assertInstanceOf (value: unknown, Clazz: Function): void {
|
|||||||
* @param {string | unknown[]} value
|
* @param {string | unknown[]} value
|
||||||
* @param {string} check
|
* @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 {
|
function assertIncludes (value: string | unknown[], [check, Clazz]: [string, Function]): void {
|
||||||
assertInstanceOf(value, Clazz);
|
assertInstanceOf(value, Clazz);
|
||||||
assert.ok(value?.includes(check), `${value as string} does not include ${check}`);
|
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 () {
|
export function expect () {
|
||||||
const rootMatchers = {
|
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),
|
any: (Clazz: Function) => new Matcher(assertInstanceOf, Clazz),
|
||||||
anything: () => new Matcher(assertNonNullish),
|
anything: () => new Matcher(assertNonNullish),
|
||||||
arrayContaining: (check: string) => new Matcher(assertIncludes, [check, Array]),
|
arrayContaining: (check: string) => new Matcher(assertIncludes, [check, Array]),
|
||||||
@@ -229,7 +229,7 @@ export function expect () {
|
|||||||
toBe: (other: unknown) => assert.strictEqual(value, other),
|
toBe: (other: unknown) => assert.strictEqual(value, other),
|
||||||
toBeDefined: () => assert.ok(value !== undefined),
|
toBeDefined: () => assert.ok(value !== undefined),
|
||||||
toBeFalsy: () => assert.ok(!value),
|
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),
|
toBeInstanceOf: (Clazz: Function) => assertInstanceOf(value, Clazz),
|
||||||
toBeNull: (value: unknown) => assert.ok(value === null),
|
toBeNull: (value: unknown) => assert.ok(value === null),
|
||||||
toBeTruthy: () => assert.ok(value),
|
toBeTruthy: () => assert.ok(value),
|
||||||
|
|||||||
Vendored
+1
-1
@@ -32,7 +32,7 @@ function extendMock <F extends AnyFn> (mocked: WithMock<F>) {
|
|||||||
//
|
//
|
||||||
// Effectively the casts below ensure that our WithMock<*> aligns
|
// Effectively the casts below ensure that our WithMock<*> aligns
|
||||||
// on a high-level to what we use via private type...
|
// 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, {
|
return enhanceObj(enhanceObj(mocked, {
|
||||||
mockImplementation: <F extends AnyFn> (fn: F): void => {
|
mockImplementation: <F extends AnyFn> (fn: F): void => {
|
||||||
|
|||||||
Vendored
+6
-6
@@ -35,10 +35,10 @@ const MINUTE = 60 * 1000;
|
|||||||
* Wraps either describe or it with relevant .only, .skip, .todo & .each helpers,
|
* Wraps either describe or it with relevant .only, .skip, .todo & .each helpers,
|
||||||
* shimming it into a Jest-compatible environment.
|
* 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 {
|
function createWrapper (fn: WrapFn, defaultTimeout: number): Describe {
|
||||||
const wrap = (opts: WrapOpts) => (name: string, exec: () => void | Promise<void>, timeout?: number) => fn(name, { ...opts, timeout: (timeout || defaultTimeout) }, exec) as unknown as void;
|
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
|
// 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.
|
// 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 }),
|
only: wrap({ only: true }),
|
||||||
skip: wrap({ skip: true }),
|
skip: wrap({ skip: true }),
|
||||||
todo: wrap({ todo: 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 } {
|
export function suite (): { describe: Describe; it: It } {
|
||||||
return {
|
return {
|
||||||
describe: createWrapper(describe, 60 * MINUTE) as Describe,
|
describe: createWrapper(describe, 60 * MINUTE),
|
||||||
it: createWrapper(it, 2 * MINUTE) as It
|
it: createWrapper(it, 2 * MINUTE)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Vendored
-2
@@ -1,8 +1,6 @@
|
|||||||
// Copyright 2017-2026 @pezkuwi/dev-test authors & contributors
|
// Copyright 2017-2026 @pezkuwi/dev-test authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/* eslint-disable no-var */
|
|
||||||
|
|
||||||
import type { expect } from './env/expect.js';
|
import type { expect } from './env/expect.js';
|
||||||
import type { jest } from './env/jest.js';
|
import type { jest } from './env/jest.js';
|
||||||
import type { lifecycle } from './env/lifecycle.js';
|
import type { lifecycle } from './env/lifecycle.js';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export type AnyFn = (...args: any[]) => any;
|
|||||||
|
|
||||||
export type BaseObj = Record<string, unknown>;
|
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 BaseFn = Function;
|
||||||
|
|
||||||
export type StubFn = (...args: unknown[]) => unknown;
|
export type StubFn = (...args: unknown[]) => unknown;
|
||||||
@@ -25,4 +25,4 @@ export type WithMock<F extends AnyFn> = F & {
|
|||||||
resetCalls: () => void;
|
resetCalls: () => void;
|
||||||
restore: () => void;
|
restore: () => void;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
@@ -27,7 +27,7 @@ function createStub <N extends readonly string[]> (keys: N, creator: (key: strin
|
|||||||
obj[key] ??= creator(key);
|
obj[key] ??= creator(key);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}, {}) as unknown as { [K in N[number]]: StubFn };
|
}, {}) as unknown as Record<N[number], StubFn>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,34 +1,44 @@
|
|||||||
// Copyright 2017-2026 @pezkuwi/dev authors & contributors
|
// Copyright 2017-2026 @pezkuwi/dev authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// 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 eslintJs from '@eslint/js';
|
||||||
|
import stylisticPlugin from '@stylistic/eslint-plugin';
|
||||||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||||
import tsParser from '@typescript-eslint/parser';
|
import tsParser from '@typescript-eslint/parser';
|
||||||
// @ts-expect-error No definition for this one
|
// @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 headerPlugin from 'eslint-plugin-header';
|
||||||
import importPlugin from 'eslint-plugin-import';
|
|
||||||
// @ts-expect-error No definition for this one
|
// @ts-expect-error No definition for this one
|
||||||
import importNewlinesPlugin from 'eslint-plugin-import-newlines';
|
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';
|
import jestPlugin from 'eslint-plugin-jest';
|
||||||
// @ts-expect-error No definition for this one
|
|
||||||
import nPlugin from 'eslint-plugin-n';
|
import nPlugin from 'eslint-plugin-n';
|
||||||
// @ts-expect-error No definition for this one
|
// @ts-expect-error No definition for this one
|
||||||
import promisePlugin from 'eslint-plugin-promise';
|
import promisePlugin from 'eslint-plugin-promise';
|
||||||
import reactPlugin from 'eslint-plugin-react';
|
import reactPlugin from 'eslint-plugin-react';
|
||||||
// @ts-expect-error No definition for this one
|
|
||||||
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
||||||
// @ts-expect-error No definition for this one
|
|
||||||
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
||||||
// @ts-expect-error No definition for this one
|
// @ts-expect-error No definition for this one
|
||||||
import sortDestructureKeysPlugin from 'eslint-plugin-sort-destructure-keys';
|
import sortDestructureKeysPlugin from 'eslint-plugin-sort-destructure-keys';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
|
|
||||||
import { overrideAll, overrideJs, overrideJsx, overrideSpec } from './eslint.rules.js';
|
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_JS = ['.cjs', '.js', '.mjs'];
|
||||||
const EXT_TS = ['.ts', '.tsx'];
|
const EXT_TS = ['.ts', '.tsx'];
|
||||||
@@ -82,23 +92,27 @@ export default [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
|
'@stylistic': stylisticPlugin,
|
||||||
'@typescript-eslint': tsPlugin,
|
'@typescript-eslint': tsPlugin,
|
||||||
deprecation: deprecationPlugin,
|
// eslint-plugin-header reports at the first token after the leading
|
||||||
header: headerPlugin,
|
// comments, so a generated file's /* eslint-disable */ covers it; the
|
||||||
import: importPlugin,
|
// 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-newlines': importNewlinesPlugin,
|
||||||
|
'import-x': importPlugin,
|
||||||
n: nPlugin,
|
n: nPlugin,
|
||||||
promise: promisePlugin,
|
promise: promisePlugin,
|
||||||
'simple-import-sort': simpleImportSortPlugin,
|
'simple-import-sort': simpleImportSortPlugin,
|
||||||
'sort-destructure-keys': sortDestructureKeysPlugin
|
'sort-destructure-keys': sortDestructureKeysPlugin
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
'import/extensions': EXT_ALL,
|
'import-x/extensions': EXT_ALL,
|
||||||
'import/parsers': {
|
'import-x/parsers': {
|
||||||
'@typescript-eslint/parser': EXT_TS,
|
'@typescript-eslint/parser': EXT_TS,
|
||||||
espree: EXT_JS
|
espree: EXT_JS
|
||||||
},
|
},
|
||||||
'import/resolver': {
|
'import-x/resolver': {
|
||||||
node: {
|
node: {
|
||||||
extensions: EXT_ALL
|
extensions: EXT_ALL
|
||||||
},
|
},
|
||||||
@@ -112,7 +126,7 @@ export default [
|
|||||||
files: extsToGlobs(EXT_ALL),
|
files: extsToGlobs(EXT_ALL),
|
||||||
rules: {
|
rules: {
|
||||||
...eslintJs.configs.recommended.rules,
|
...eslintJs.configs.recommended.rules,
|
||||||
...standardConfig.rules,
|
...standardRules,
|
||||||
...tsPlugin.configs['recommended-type-checked'].rules,
|
...tsPlugin.configs['recommended-type-checked'].rules,
|
||||||
...tsPlugin.configs['stylistic-type-checked'].rules,
|
...tsPlugin.configs['stylistic-type-checked'].rules,
|
||||||
...overrideAll
|
...overrideAll
|
||||||
@@ -130,7 +144,9 @@ export default [
|
|||||||
'**/use*.ts'
|
'**/use*.ts'
|
||||||
],
|
],
|
||||||
plugins: {
|
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
|
'react-hooks': reactHooksPlugin
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
@@ -59,68 +59,17 @@ function getHeaderPattern () {
|
|||||||
|
|
||||||
export const overrideAll = {
|
export const overrideAll = {
|
||||||
...FIXME,
|
...FIXME,
|
||||||
// the next 2 enforce isolatedModules & verbatimModuleSyntax
|
'@stylistic/arrow-parens': ['error', 'always'],
|
||||||
'@typescript-eslint/consistent-type-exports': 'error',
|
'@stylistic/brace-style': ['error', '1tbs'],
|
||||||
'@typescript-eslint/consistent-type-imports': 'error',
|
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
|
||||||
'@typescript-eslint/dot-notation': 'error',
|
'@stylistic/indent': ['error', 2],
|
||||||
'@typescript-eslint/indent': ['error', 2],
|
'@stylistic/no-extra-semi': 'error',
|
||||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
'@stylistic/object-curly-newline': ['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', {
|
|
||||||
ExportDeclaration: { minProperties: 2048 },
|
ExportDeclaration: { minProperties: 2048 },
|
||||||
ImportDeclaration: { minProperties: 2048 },
|
ImportDeclaration: { minProperties: 2048 },
|
||||||
ObjectPattern: { minProperties: 2048 }
|
ObjectPattern: { minProperties: 2048 }
|
||||||
}],
|
}],
|
||||||
'padding-line-between-statements': [
|
'@stylistic/padding-line-between-statements': [
|
||||||
'error',
|
'error',
|
||||||
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
|
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
|
||||||
{ blankLine: 'any', next: ['const', 'let', 'var'], 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: 'always', next: '*', prev: 'import' },
|
||||||
{ blankLine: 'any', next: 'import', 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/exports': 'error',
|
||||||
'simple-import-sort/imports': ['error', {
|
'simple-import-sort/imports': ['error', {
|
||||||
groups: [
|
groups: [
|
||||||
@@ -150,55 +166,45 @@ export const overrideAll = {
|
|||||||
'sort-destructure-keys/sort-destructure-keys': ['error', {
|
'sort-destructure-keys/sort-destructure-keys': ['error', {
|
||||||
caseSensitive: true
|
caseSensitive: true
|
||||||
}],
|
}],
|
||||||
'sort-keys': 'error',
|
'sort-keys': 'error'
|
||||||
'spaced-comment': ['error', 'always', {
|
|
||||||
block: {
|
|
||||||
// pure export helpers
|
|
||||||
markers: ['#__PURE__']
|
|
||||||
},
|
|
||||||
line: {
|
|
||||||
// TS reference types
|
|
||||||
markers: ['/ <reference']
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const overrideJsx = {
|
export const overrideJsx = {
|
||||||
'jsx-quotes': ['error', 'prefer-single'],
|
'@stylistic/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
|
||||||
// swap from recommended warning to error
|
'@stylistic/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
|
||||||
'react-hooks/exhaustive-deps': 'error',
|
'@stylistic/jsx-max-props-per-line': ['warn', {
|
||||||
'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', {
|
|
||||||
maximum: 1,
|
maximum: 1,
|
||||||
when: 'always'
|
when: 'always'
|
||||||
}],
|
}],
|
||||||
'react/jsx-newline': ['error', {
|
'@stylistic/jsx-newline': ['error', {
|
||||||
prevent: true
|
prevent: true
|
||||||
}],
|
}],
|
||||||
'react/jsx-no-bind': 'error',
|
'@stylistic/jsx-props-no-multi-spaces': 'error',
|
||||||
'react/jsx-props-no-multi-spaces': 'error',
|
'@stylistic/jsx-quotes': ['error', 'prefer-single'],
|
||||||
'react/jsx-sort-props': ['warn', {
|
'@stylistic/jsx-sort-props': ['warn', {
|
||||||
noSortAlphabetically: false
|
noSortAlphabetically: false
|
||||||
}],
|
}],
|
||||||
'react/jsx-tag-spacing': ['error', {
|
'@stylistic/jsx-tag-spacing': ['error', {
|
||||||
afterOpening: 'never',
|
afterOpening: 'never',
|
||||||
beforeClosing: 'never',
|
beforeClosing: 'never',
|
||||||
beforeSelfClosing: 'always',
|
beforeSelfClosing: 'always',
|
||||||
closingSlash: 'never'
|
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
|
'react/prop-types': 'off' // this is a completely broken rule
|
||||||
};
|
};
|
||||||
|
|
||||||
export const overrideJs = {
|
export const overrideJs = {
|
||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/no-require-imports': 'off',
|
||||||
'@typescript-eslint/no-unsafe-argument': 'off',
|
'@typescript-eslint/no-unsafe-argument': 'off',
|
||||||
'@typescript-eslint/no-unsafe-assignment': 'off',
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
||||||
'@typescript-eslint/no-unsafe-call': 'off',
|
'@typescript-eslint/no-unsafe-call': 'off',
|
||||||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
'@typescript-eslint/no-unsafe-member-access': 'off',
|
||||||
'@typescript-eslint/no-unsafe-return': 'off',
|
'@typescript-eslint/no-unsafe-return': 'off',
|
||||||
'@typescript-eslint/no-var-requires': 'off',
|
|
||||||
'@typescript-eslint/restrict-plus-operands': 'off',
|
'@typescript-eslint/restrict-plus-operands': 'off',
|
||||||
'@typescript-eslint/restrict-template-expressions': 'off'
|
'@typescript-eslint/restrict-template-expressions': 'off'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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
@@ -3,7 +3,7 @@
|
|||||||
"bugs": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/issues",
|
"bugs": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/issues",
|
||||||
"description": "A collection of shared CI scripts and development environment used by @pezkuwi projects",
|
"description": "A collection of shared CI scripts and development environment used by @pezkuwi projects",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=20.19"
|
||||||
},
|
},
|
||||||
"homepage": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/tree/master/packages/dev#readme",
|
"homepage": "https://git.pezkuwichain.io/pezkuwichain/pezkuwi-dev/tree/master/packages/dev#readme",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@@ -49,47 +49,47 @@
|
|||||||
"./rootJs/testJson.json": "./src/rootJs/testJson.json"
|
"./rootJs/testJson.json": "./src/rootJs/testJson.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/js": "^8.56.0",
|
"@eslint/compat": "^2.1.1",
|
||||||
|
"@eslint/js": "^10.0.1",
|
||||||
"@pezkuwi/dev-test": "^0.85.12",
|
"@pezkuwi/dev-test": "^0.85.12",
|
||||||
"@pezkuwi/dev-ts": "^0.85.12",
|
"@pezkuwi/dev-ts": "^0.85.12",
|
||||||
"@rollup/plugin-alias": "^5.1.1",
|
"@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-dynamic-import-vars": "^2.1.5",
|
||||||
"@rollup/plugin-inject": "^5.0.5",
|
"@rollup/plugin-inject": "^5.0.5",
|
||||||
"@rollup/plugin-json": "^6.1.0",
|
"@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",
|
"@tsconfig/strictest": "^2.0.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
"@typescript-eslint/eslint-plugin": "^8.71.1",
|
||||||
"@typescript-eslint/parser": "^6.19.1",
|
"@typescript-eslint/parser": "^8.71.1",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^10.12.0",
|
||||||
"eslint-config-standard": "^17.1.0",
|
|
||||||
"eslint-import-resolver-node": "^0.3.9",
|
"eslint-import-resolver-node": "^0.3.9",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^4.4.5",
|
||||||
"eslint-plugin-deprecation": "^2.0.0",
|
|
||||||
"eslint-plugin-header": "^3.1.1",
|
"eslint-plugin-header": "^3.1.1",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import-newlines": "^2.0.0",
|
||||||
"eslint-plugin-import-newlines": "^1.3.4",
|
"eslint-plugin-import-x": "^4.17.1",
|
||||||
"eslint-plugin-jest": "^27.6.3",
|
"eslint-plugin-jest": "^29.16.6",
|
||||||
"eslint-plugin-n": "^16.6.2",
|
"eslint-plugin-n": "^18.4.1",
|
||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^7.3.0",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
||||||
"eslint-plugin-sort-destructure-keys": "^1.5.0",
|
"eslint-plugin-sort-destructure-keys": "^3.0.0",
|
||||||
"espree": "^9.6.1",
|
"espree": "^11.2.0",
|
||||||
"gh-pages": "^6.1.1",
|
"gh-pages": "^6.1.1",
|
||||||
"gh-release": "^7.0.2",
|
"gh-release": "^8.1.0",
|
||||||
"globals": "^13.24.0",
|
"globals": "^17.13.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"madge": "^6.1.0",
|
"madge": "^8.0.0",
|
||||||
"rollup": "^4.9.6",
|
"rollup": "^4.9.6",
|
||||||
"rollup-plugin-cleanup": "^3.2.1",
|
"rollup-plugin-cleanup": "^3.2.1",
|
||||||
"tslib": "^2.7.0",
|
"tslib": "^2.7.0",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"webpack": "^5.89.0",
|
"webpack": "^5.89.0",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "^7.2.3",
|
||||||
"webpack-dev-server": "^4.15.1",
|
"webpack-dev-server": "^6.0.0",
|
||||||
"webpack-merge": "^5.10.0",
|
"webpack-merge": "^6.0.1",
|
||||||
"webpack-subresource-integrity": "^5.2.0-rc.1",
|
"webpack-subresource-integrity": "^5.2.0-rc.1",
|
||||||
"yargs": "^17.7.2"
|
"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
|
// file will also be caught in the net, i.e. we expect all files to conform
|
||||||
if (n === 0 && (
|
if (n === 0 && (
|
||||||
!/\/\/ Copyright .* @pezkuwi\//.test(l) &&
|
!/\/\/ Copyright .* @pezkuwi\//.test(l) &&
|
||||||
!/\/\/ Auto-generated via `/.test(l) &&
|
!l.includes('// Auto-generated via `') &&
|
||||||
!/#!\/usr\/bin\/env node/.test(l)
|
!l.includes('#!/usr/bin/env node')
|
||||||
)) {
|
)) {
|
||||||
return createError(full, l, n, 'Invalid header definition');
|
return createError(full, l, n, 'Invalid header definition');
|
||||||
}
|
}
|
||||||
@@ -1281,7 +1281,7 @@ function extractPackageInfoImports (filepath, withDetectImport) {
|
|||||||
.readFileSync(filepath, { encoding: 'utf-8' })
|
.readFileSync(filepath, { encoding: 'utf-8' })
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.forEach((l) => {
|
.forEach((l) => {
|
||||||
const match = l.match(/import \{ packageInfo as (.*) \}/);
|
const match = /import \{ packageInfo as (.*) \}/.exec(l);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
otherImports.push(l);
|
otherImports.push(l);
|
||||||
@@ -1290,8 +1290,8 @@ function extractPackageInfoImports (filepath, withDetectImport) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
otherImports.sort((a, b) => {
|
otherImports.sort((a, b) => {
|
||||||
const am = a.match(/\} from '(.*)';/);
|
const am = /\} from '(.*)';/.exec(a);
|
||||||
const bm = b.match(/\} from '(.*)';/);
|
const bm = /\} from '(.*)';/.exec(b);
|
||||||
|
|
||||||
if (!am) {
|
if (!am) {
|
||||||
throw new Error(`Unable to extract from import from ${a}`);
|
throw new Error(`Unable to extract from import from ${a}`);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ function getFilename (r) {
|
|||||||
.split('\n')
|
.split('\n')
|
||||||
.map((l) => l.trim())
|
.map((l) => l.trim())
|
||||||
.filter((l) => l.startsWith('at ') && (l.includes('.spec.') || l.includes('.test.')))
|
.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(')', ''));
|
.map((l) => l?.replace('(', '')?.replace(')', ''));
|
||||||
|
|
||||||
if (stack.length) {
|
if (stack.length) {
|
||||||
@@ -186,7 +186,7 @@ function complete () {
|
|||||||
|
|
||||||
if (typeof r === 'string') {
|
if (typeof r === 'string') {
|
||||||
console.log(r); // Node.js <= 18.14
|
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
|
// Ignore internal diagnostics
|
||||||
} else {
|
} else {
|
||||||
if (lastFilename !== r.file) {
|
if (lastFilename !== r.file) {
|
||||||
@@ -328,11 +328,11 @@ if (isMainThread) {
|
|||||||
} else {
|
} else {
|
||||||
run({ files: workerData.files, timeout: 3_600_000 })
|
run({ files: workerData.files, timeout: 3_600_000 })
|
||||||
.on('data', () => undefined)
|
.on('data', () => undefined)
|
||||||
.on('end', () => parentPort && parentPort.postMessage(stats))
|
.on('end', () => parentPort?.postMessage(stats))
|
||||||
.on('test:coverage', () => undefined)
|
.on('test:coverage', () => undefined)
|
||||||
.on('test:diagnostic', (/** @type {DiagStat} */data) => {
|
.on('test:diagnostic', (/** @type {DiagStat} */data) => {
|
||||||
stats.diag.push(data);
|
stats.diag.push(data);
|
||||||
parentPort && parentPort.postMessage({ data: stats, type: 'result' });
|
parentPort?.postMessage({ data: stats, type: 'result' });
|
||||||
})
|
})
|
||||||
.on('test:fail', (/** @type {FailStat} */ data) => {
|
.on('test:fail', (/** @type {FailStat} */ data) => {
|
||||||
const statFail = structuredClone(data);
|
const statFail = structuredClone(data);
|
||||||
@@ -343,7 +343,7 @@ if (isMainThread) {
|
|||||||
|
|
||||||
stats.fail.push(statFail);
|
stats.fail.push(statFail);
|
||||||
stats.total++;
|
stats.total++;
|
||||||
parentPort && parentPort.postMessage({ data: 'x', type: 'progress' });
|
parentPort?.postMessage({ data: 'x', type: 'progress' });
|
||||||
|
|
||||||
if (bail) {
|
if (bail) {
|
||||||
complete();
|
complete();
|
||||||
@@ -361,7 +361,7 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stats.total++;
|
stats.total++;
|
||||||
parentPort && parentPort.postMessage({ data: symbol, type: 'progress' });
|
parentPort?.postMessage({ data: symbol, type: 'progress' });
|
||||||
})
|
})
|
||||||
.on('test:plan', () => undefined)
|
.on('test:plan', () => undefined)
|
||||||
.on('test:start', () => undefined);
|
.on('test:start', () => undefined);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export function copyDirSync (src, dest, include, exclude) {
|
|||||||
if (fs.statSync(srcPath).isDirectory()) {
|
if (fs.statSync(srcPath).isDirectory()) {
|
||||||
copyDirSync(srcPath, path.join(dest, file), include, exclude);
|
copyDirSync(srcPath, path.join(dest, file), include, exclude);
|
||||||
} else if (!include?.length || include.some((e) => file.endsWith(e))) {
|
} 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);
|
copyFileSync(srcPath, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -480,7 +480,7 @@ export function topoSort (dirs) {
|
|||||||
visited[key] = true;
|
visited[key] = true;
|
||||||
|
|
||||||
node.vertices.forEach((i) => {
|
node.vertices.forEach((i) => {
|
||||||
if (ancestors.indexOf(i) >= 0) {
|
if (ancestors.includes(i)) {
|
||||||
console.log('CIRCULAR: closed chain : ' + i + ' is in ' + id);
|
console.log('CIRCULAR: closed chain : ' + i + ' is in ' + id);
|
||||||
|
|
||||||
if (nodes[id].vertices.includes(i)) {
|
if (nodes[id].vertices.includes(i)) {
|
||||||
|
|||||||
@@ -11,4 +11,13 @@ import type * as testRoot from './root.js';
|
|||||||
import testRootBuild from '../build/cjs/root.js';
|
import testRootBuild from '../build/cjs/root.js';
|
||||||
import { runTests } from './rootTests.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));
|
||||||
@@ -7,7 +7,7 @@ export class Clazz {
|
|||||||
readonly and: number;
|
readonly and: number;
|
||||||
|
|
||||||
static staticProperty = 'foobar';
|
static staticProperty = 'foobar';
|
||||||
static staticFunction = (): string|null => Clazz.staticProperty;
|
static staticFunction = (): string | null => Clazz.staticProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param and the number we should and with
|
* @param and the number we should and with
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export async function dynamic (a: number, b: number): Promise<number> {
|
|||||||
// and CJS output (a './dynamic' import would be different otherwise)
|
// and CJS output (a './dynamic' import would be different otherwise)
|
||||||
const { sum } = await import('@pezkuwi/dev/rootJs/dynamic.mjs');
|
const { sum } = await import('@pezkuwi/dev/rootJs/dynamic.mjs');
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
||||||
return sum(a, b);
|
return sum(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user