eslint-config-typed 7.5.0 → 7.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/configs/nodejs.d.mts +14 -1
- package/dist/configs/nodejs.d.mts.map +1 -1
- package/dist/configs/nodejs.mjs +37 -4
- package/dist/configs/nodejs.mjs.map +1 -1
- package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.d.mts +17 -3
- package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.d.mts.map +1 -1
- package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.mjs +124 -40
- package/dist/plugins/immer-coding-style/rules/prefer-curried-produce.mjs.map +1 -1
- package/dist/plugins/ts-restrictions/rules/no-export-type-side-effects.d.mts +23 -0
- package/dist/plugins/ts-restrictions/rules/no-export-type-side-effects.d.mts.map +1 -0
- package/dist/plugins/ts-restrictions/rules/no-export-type-side-effects.mjs +78 -0
- package/dist/plugins/ts-restrictions/rules/no-export-type-side-effects.mjs.map +1 -0
- package/dist/plugins/ts-restrictions/rules/rules.d.mts +1 -0
- package/dist/plugins/ts-restrictions/rules/rules.d.mts.map +1 -1
- package/dist/plugins/ts-restrictions/rules/rules.mjs +2 -0
- package/dist/plugins/ts-restrictions/rules/rules.mjs.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.d.mts +3 -1
- package/dist/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.d.mts.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.mjs +11 -12
- package/dist/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.mjs.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-false-over-expect-false.d.mts +2 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-false-over-expect-false.d.mts.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-false-over-expect-false.mjs +36 -24
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-false-over-expect-false.mjs.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-true-over-expect-true.d.mts +2 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-true-over-expect-true.d.mts.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-true-over-expect-true.mjs +36 -24
- package/dist/plugins/vitest-coding-style/rules/prefer-assert-is-true-over-expect-true.mjs.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/vitest-binding.d.mts +25 -0
- package/dist/plugins/vitest-coding-style/rules/vitest-binding.d.mts.map +1 -1
- package/dist/plugins/vitest-coding-style/rules/vitest-binding.mjs +56 -1
- package/dist/plugins/vitest-coding-style/rules/vitest-binding.mjs.map +1 -1
- package/dist/rules/eslint-rules.d.mts +58 -4
- package/dist/rules/eslint-rules.d.mts.map +1 -1
- package/dist/rules/eslint-rules.mjs +21 -3
- package/dist/rules/eslint-rules.mjs.map +1 -1
- package/dist/rules/eslint-ts-restrictions-rules.d.mts +1 -0
- package/dist/rules/eslint-ts-restrictions-rules.d.mts.map +1 -1
- package/dist/rules/eslint-ts-restrictions-rules.mjs +1 -0
- package/dist/rules/eslint-ts-restrictions-rules.mjs.map +1 -1
- package/dist/rules/eslint-unicorn-rules.d.mts +24 -6
- package/dist/rules/eslint-unicorn-rules.d.mts.map +1 -1
- package/dist/rules/eslint-unicorn-rules.mjs +22 -4
- package/dist/rules/eslint-unicorn-rules.mjs.map +1 -1
- package/dist/rules/node-version-gated-apis.d.mts +74 -14
- package/dist/rules/node-version-gated-apis.d.mts.map +1 -1
- package/dist/rules/node-version-gated-apis.mjs +146 -20
- package/dist/rules/node-version-gated-apis.mjs.map +1 -1
- package/dist/rules/typescript-eslint-rules.d.mts.map +1 -1
- package/dist/rules/typescript-eslint-rules.mjs +4 -0
- package/dist/rules/typescript-eslint-rules.mjs.map +1 -1
- package/dist/types/rules/eslint-cypress-rules.d.mts +1 -2
- package/dist/types/rules/eslint-cypress-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-functional-rules.d.mts +16 -17
- package/dist/types/rules/eslint-functional-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-import-rules.d.mts +28 -28
- package/dist/types/rules/eslint-import-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-jest-rules.d.mts +22 -23
- package/dist/types/rules/eslint-jest-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-jsx-a11y-rules.d.mts +36 -37
- package/dist/types/rules/eslint-jsx-a11y-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-math-rules.d.mts +3 -4
- package/dist/types/rules/eslint-math-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-n-rules.d.mts +31 -32
- package/dist/types/rules/eslint-n-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-playwright-rules.d.mts +23 -24
- package/dist/types/rules/eslint-playwright-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-plugin-rules.d.mts +14 -15
- package/dist/types/rules/eslint-plugin-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-plugin-sort-destructure-keys-rules.d.mts +1 -2
- package/dist/types/rules/eslint-plugin-sort-destructure-keys-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-prefer-arrow-functions-rules.d.mts +1 -2
- package/dist/types/rules/eslint-prefer-arrow-functions-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-promise-rules.d.mts +9 -10
- package/dist/types/rules/eslint-promise-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-react-coding-style-rules.d.mts +6 -7
- package/dist/types/rules/eslint-react-coding-style-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-react-hooks-rules.d.mts +28 -29
- package/dist/types/rules/eslint-react-hooks-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-react-perf-rules.d.mts +4 -5
- package/dist/types/rules/eslint-react-perf-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-react-refresh-rules.d.mts +1 -2
- package/dist/types/rules/eslint-react-refresh-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-react-rules.d.mts +63 -63
- package/dist/types/rules/eslint-react-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-rules.d.mts +83 -83
- package/dist/types/rules/eslint-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-stylistic-rules.d.mts +61 -61
- package/dist/types/rules/eslint-stylistic-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-testing-library-rules.d.mts +12 -13
- package/dist/types/rules/eslint-testing-library-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-ts-restrictions-rules.d.mts +19 -4
- package/dist/types/rules/eslint-ts-restrictions-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-unicorn-rules.d.mts +77 -77
- package/dist/types/rules/eslint-unicorn-rules.d.mts.map +1 -1
- package/dist/types/rules/eslint-vitest-rules.d.mts +24 -25
- package/dist/types/rules/eslint-vitest-rules.d.mts.map +1 -1
- package/dist/types/rules/typescript-eslint-rules.d.mts +69 -69
- package/dist/types/rules/typescript-eslint-rules.d.mts.map +1 -1
- package/package.json +10 -10
- package/src/configs/nodejs.mts +63 -4
- package/src/configs/nodejs.test.mts +83 -0
- package/src/configs/typescript.test.mts +64 -2
- package/src/plugins/immer-coding-style/rules/prefer-curried-produce.mts +207 -63
- package/src/plugins/immer-coding-style/rules/prefer-curried-produce.test.mts +316 -10
- package/src/plugins/ts-restrictions/rules/no-export-type-side-effects.mts +102 -0
- package/src/plugins/ts-restrictions/rules/no-export-type-side-effects.test.mts +129 -0
- package/src/plugins/ts-restrictions/rules/rules.mts +2 -0
- package/src/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.mts +27 -21
- package/src/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.test.mts +115 -0
- package/src/plugins/vitest-coding-style/rules/prefer-assert-coding-style-rules.test.mts +330 -0
- package/src/plugins/vitest-coding-style/rules/prefer-assert-is-false-over-expect-false.mts +58 -31
- package/src/plugins/vitest-coding-style/rules/prefer-assert-is-true-over-expect-true.mts +58 -31
- package/src/plugins/vitest-coding-style/rules/vitest-binding.mts +89 -1
- package/src/rules/eslint-rules.mts +24 -4
- package/src/rules/eslint-ts-restrictions-rules.mts +1 -0
- package/src/rules/eslint-unicorn-rules.mts +24 -6
- package/src/rules/node-version-gated-apis.mts +202 -47
- package/src/rules/node-version-gated-apis.test.mts +75 -5
- package/src/rules/typescript-eslint-rules.mts +5 -1
- package/src/types/rules/eslint-cypress-rules.mts +1 -9
- package/src/types/rules/eslint-functional-rules.mts +16 -54
- package/src/types/rules/eslint-import-rules.mts +28 -84
- package/src/types/rules/eslint-jest-rules.mts +22 -72
- package/src/types/rules/eslint-jsx-a11y-rules.mts +36 -114
- package/src/types/rules/eslint-math-rules.mts +3 -15
- package/src/types/rules/eslint-n-rules.mts +31 -99
- package/src/types/rules/eslint-playwright-rules.mts +23 -75
- package/src/types/rules/eslint-plugin-rules.mts +14 -48
- package/src/types/rules/eslint-plugin-sort-destructure-keys-rules.mts +1 -9
- package/src/types/rules/eslint-prefer-arrow-functions-rules.mts +1 -9
- package/src/types/rules/eslint-promise-rules.mts +9 -33
- package/src/types/rules/eslint-react-coding-style-rules.mts +6 -24
- package/src/types/rules/eslint-react-hooks-rules.mts +28 -90
- package/src/types/rules/eslint-react-perf-rules.mts +4 -18
- package/src/types/rules/eslint-react-refresh-rules.mts +1 -9
- package/src/types/rules/eslint-react-rules.mts +63 -189
- package/src/types/rules/eslint-rules.mts +83 -249
- package/src/types/rules/eslint-stylistic-rules.mts +61 -183
- package/src/types/rules/eslint-testing-library-rules.mts +12 -42
- package/src/types/rules/eslint-ts-restrictions-rules.mts +20 -12
- package/src/types/rules/eslint-unicorn-rules.mts +77 -231
- package/src/types/rules/eslint-vitest-rules.mts +24 -78
- package/src/types/rules/typescript-eslint-rules.mts +69 -207
package/README.md
CHANGED
|
@@ -367,6 +367,15 @@ export default [
|
|
|
367
367
|
] satisfies readonly FlatConfig[];
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
+
The presets report the built-in APIs, globals and syntax that the oldest
|
|
371
|
+
Node.js in this package's `engines.node` lacks (`Temporal`, `Iterator.zip`,
|
|
372
|
+
`using`, …), and turn off the rules whose fixes would write them. Files that run
|
|
373
|
+
only on a known newer Node.js, such as a repository's own scripts, pass its
|
|
374
|
+
major: `eslintConfigForNodeJs(['scripts/**'], { nodeMajor: 26 })` allows what
|
|
375
|
+
Node.js 26 has and still reports what it lacks. With `nodeMajor` the preset sets
|
|
376
|
+
the options of `no-restricted-globals`, `no-restricted-properties` and
|
|
377
|
+
`no-restricted-syntax` for those files, replacing any set before it.
|
|
378
|
+
|
|
370
379
|
### Node.js TypeScript Project
|
|
371
380
|
|
|
372
381
|
```tsx
|
|
@@ -571,7 +580,7 @@ The shape of the rule option varies depending on the rule, so please check the c
|
|
|
571
580
|
|
|
572
581
|
**`eslintPluginTsRestrictions`** - Custom ESLint plugin with additional rules for TypeScript
|
|
573
582
|
|
|
574
|
-
-
|
|
583
|
+
- Provides the `ts-restrictions/*` rules; `eslintTsRestrictionsRules` lists each one with the severity the preset sets. `ts-restrictions/no-restricted-syntax` duplicates ESLint's `no-restricted-syntax` rule.
|
|
575
584
|
- Can be used to set the error level to `error` or `warn` as needed.
|
|
576
585
|
|
|
577
586
|
Example:
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import { type FlatConfig } from '../types/index.mjs';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The Node.js globals and rules for `files`.
|
|
4
|
+
*
|
|
5
|
+
* `nodeMajor` is for files that run only on a known Node.js, newer than this
|
|
6
|
+
* package's `engines.node` floor — a repository's own scripts, say. The APIs,
|
|
7
|
+
* globals and syntax that the floor lacks and that runtime has are then
|
|
8
|
+
* allowed (`nodeVersionGateAt`); without it, every one the floor lacks is
|
|
9
|
+
* reported. With it, the preset sets the options of `no-restricted-globals`,
|
|
10
|
+
* `no-restricted-properties` and `no-restricted-syntax` for `files`, replacing
|
|
11
|
+
* any set before it there, as a flat config does.
|
|
12
|
+
*/
|
|
13
|
+
export declare const eslintConfigForNodeJs: (files?: readonly string[], options?: Readonly<{
|
|
14
|
+
nodeMajor?: number;
|
|
15
|
+
}>) => FlatConfig;
|
|
3
16
|
//# sourceMappingURL=nodejs.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodejs.d.mts","sourceRoot":"","sources":["../../src/configs/nodejs.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodejs.d.mts","sourceRoot":"","sources":["../../src/configs/nodejs.mts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,WACxB,SAAS,MAAM,EAAE,YACf,QAAQ,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,KACzC,UAmDU,CAAC"}
|
package/dist/configs/nodejs.mjs
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import globals from 'globals';
|
|
2
2
|
import { Arr } from 'ts-data-forge';
|
|
3
|
-
import { restrictedGlobals } from '../rules/index.mjs';
|
|
4
|
-
import { defineKnownRules } from '../types/index.mjs';
|
|
5
|
-
|
|
3
|
+
import { nodeVersionGateAt, restrictedGlobals, restrictedGlobalsWithoutNodeVersionGate, restrictedSyntaxWithoutNodeVersionGate, } from '../rules/index.mjs';
|
|
4
|
+
import { defineKnownRules, } from '../types/index.mjs';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const eslintConfigForNodeJs = (files, options) => ({
|
|
6
17
|
...(files === undefined ? {} : { files }),
|
|
7
18
|
languageOptions: {
|
|
8
19
|
|
|
@@ -11,7 +22,11 @@ export const eslintConfigForNodeJs = (files) => ({
|
|
|
11
22
|
},
|
|
12
23
|
},
|
|
13
24
|
rules: defineKnownRules({
|
|
14
|
-
|
|
25
|
+
...(options?.nodeMajor === undefined
|
|
26
|
+
? {
|
|
27
|
+
'no-restricted-globals': Arr.toUnshifted('error')(restrictedGlobals),
|
|
28
|
+
}
|
|
29
|
+
: runtimeGate(options.nodeMajor)),
|
|
15
30
|
'no-alert': 'off',
|
|
16
31
|
'no-implicit-globals': 'off',
|
|
17
32
|
'no-script-url': 'off',
|
|
@@ -47,4 +62,22 @@ export const eslintConfigForNodeJs = (files) => ({
|
|
|
47
62
|
'unicorn/require-passive-events': 'off',
|
|
48
63
|
}),
|
|
49
64
|
});
|
|
65
|
+
|
|
66
|
+
const runtimeGate = (nodeMajor) => {
|
|
67
|
+
const gate = nodeVersionGateAt(nodeMajor);
|
|
68
|
+
const globalsOption = [
|
|
69
|
+
...restrictedGlobalsWithoutNodeVersionGate,
|
|
70
|
+
...gate.globals,
|
|
71
|
+
];
|
|
72
|
+
const propertiesOption = gate.properties;
|
|
73
|
+
const syntaxOption = [
|
|
74
|
+
...restrictedSyntaxWithoutNodeVersionGate,
|
|
75
|
+
...gate.syntax,
|
|
76
|
+
];
|
|
77
|
+
return {
|
|
78
|
+
'no-restricted-globals': Arr.toUnshifted('error')(globalsOption),
|
|
79
|
+
'no-restricted-properties': Arr.toUnshifted('error')(propertiesOption),
|
|
80
|
+
'no-restricted-syntax': Arr.toUnshifted('error')(syntaxOption),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
50
83
|
//# sourceMappingURL=nodejs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodejs.mjs","sourceRoot":"","sources":["../../src/configs/nodejs.mts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"nodejs.mjs","sourceRoot":"","sources":["../../src/configs/nodejs.m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through type wrappers (`produce(state satisfies State,
|
|
6
|
-
* recipe)`), which change nothing at run time and go with the argument
|
|
7
|
-
* type
|
|
6
|
+
* recipe)`), which change nothing at run time and go with the argument. The
|
|
7
|
+
* type argument is the call's own (`produce<State>(state, recipe)`), else the
|
|
8
|
+
* parameter's annotation, else the wrapper's return type.
|
|
8
9
|
*
|
|
9
10
|
* The curried form passes its extra arguments on to the recipe (`recipe(draft,
|
|
10
11
|
* ...args)`), so `xs.map((s) => produce(s, r))` → `xs.map(produce(r))` would
|
|
@@ -19,7 +20,20 @@ type MessageIds = 'useCurriedProduce';
|
|
|
19
20
|
* would have nowhere to declare, and so is a base under `!`
|
|
20
21
|
* (`produce(state!, recipe)`): the curried form would take the draft's narrower
|
|
21
22
|
* type, and its callers could no longer pass what the wrapper took.
|
|
22
|
-
* An optional parameter is left alone for the same reason
|
|
23
|
+
* An optional parameter is left alone for the same reason, and so is a base
|
|
24
|
+
* under an `as` or `<T>` whose type is not the parameter's annotation
|
|
25
|
+
* (`(state: State | undefined) => produce(state as State, recipe)`), or that
|
|
26
|
+
* casts an unannotated parameter, whose type may come from the context.
|
|
27
|
+
* A call under `as` or `<T>` (`produce(state, recipe) as View`) is left alone
|
|
28
|
+
* too, since no curried form returns the type it asserts.
|
|
29
|
+
*
|
|
30
|
+
* `produce` is immer's: a named, aliased, default or namespace import from
|
|
31
|
+
* `immer` that nothing nearer shadows. The call and its callee are read through
|
|
32
|
+
* type wrappers. A call under `satisfies` or `!`, and a callee or namespace
|
|
33
|
+
* object in any wrapper (`(produce as typeof produce)(state, recipe)`,
|
|
34
|
+
* `(immer as T).produce(…)`), are reported without a fix, which could not keep
|
|
35
|
+
* the wrapper; so is an updater with a comment outside the recipe, which the
|
|
36
|
+
* fix would delete.
|
|
23
37
|
*/
|
|
24
38
|
export declare const preferCurriedProduceRule: TSESLint.RuleModule<MessageIds>;
|
|
25
39
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-curried-produce.d.mts","sourceRoot":"","sources":["../../../../src/plugins/immer-coding-style/rules/prefer-curried-produce.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"prefer-curried-produce.d.mts","sourceRoot":"","sources":["../../../../src/plugins/immer-coding-style/rules/prefer-curried-produce.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;AAalC,KAAK,UAAU,GAAG,mBAAmB,CAAC;AAOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAuL3D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AST_NODE_TYPES, } from '@typescript-eslint/utils';
|
|
2
|
-
import { isTypeWrapper, skipTypeWrappers, typeWrapperLayers, } from 'eslint-rule-forge';
|
|
2
|
+
import { buildCalleeResolver, getImportDeclarations, hasCommentWithin, hasForeignBinding, isTypeWrapper, skipTypeWrappers, typeWrapperLayers, } from 'eslint-rule-forge';
|
|
3
3
|
import { Arr, hasKey, isRecord } from 'ts-data-forge';
|
|
4
4
|
|
|
5
5
|
|
|
@@ -15,6 +15,20 @@ import { Arr, hasKey, isRecord } from 'ts-data-forge';
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
18
32
|
|
|
19
33
|
|
|
20
34
|
|
|
@@ -37,6 +51,35 @@ export const preferCurriedProduceRule = {
|
|
|
37
51
|
},
|
|
38
52
|
create: (context) => {
|
|
39
53
|
const sourceCode = context.sourceCode;
|
|
54
|
+
const immerImports = getImportDeclarations(sourceCode.ast, immerModule);
|
|
55
|
+
if (Arr.isEmpty(immerImports)) {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
const resolveCallee = buildCalleeResolver(immerImports);
|
|
59
|
+
|
|
60
|
+
const defaultImportNames = new Set(immerImports.flatMap((declaration) => Arr.generate(function* () {
|
|
61
|
+
for (const specifier of declaration.specifiers) {
|
|
62
|
+
if (specifier.type === AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
63
|
+
yield specifier.local.name;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})));
|
|
67
|
+
const isImmerProduce = (call) => {
|
|
68
|
+
const callee = call.callee;
|
|
69
|
+
const canonicalName = resolveCallee(callee)?.canonicalName;
|
|
70
|
+
const unwrapped = skipTypeWrappers(callee);
|
|
71
|
+
if (canonicalName !== 'produce' &&
|
|
72
|
+
canonicalName !== 'default' &&
|
|
73
|
+
!(unwrapped.type === AST_NODE_TYPES.Identifier &&
|
|
74
|
+
defaultImportNames.has(unwrapped.name))) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const bound = unwrapped.type === AST_NODE_TYPES.MemberExpression
|
|
78
|
+
? skipTypeWrappers(unwrapped.object)
|
|
79
|
+
: unwrapped;
|
|
80
|
+
return (bound.type === AST_NODE_TYPES.Identifier &&
|
|
81
|
+
!hasForeignBinding(sourceCode, call, bound.name, immerModule));
|
|
82
|
+
};
|
|
40
83
|
return {
|
|
41
84
|
ArrowFunctionExpression: (node) => {
|
|
42
85
|
if (node.async ||
|
|
@@ -53,8 +96,12 @@ export const preferCurriedProduceRule = {
|
|
|
53
96
|
return;
|
|
54
97
|
}
|
|
55
98
|
const { name: parameterName } = param;
|
|
56
|
-
const callExpression = node.body;
|
|
57
|
-
|
|
99
|
+
const callExpression = skipTypeWrappers(node.body);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (callExpression.type !== AST_NODE_TYPES.CallExpression ||
|
|
103
|
+
!isImmerProduce(callExpression) ||
|
|
104
|
+
typeWrapperLayers(node.body).some((layer) => castTypeOf(layer) !== undefined)) {
|
|
58
105
|
return;
|
|
59
106
|
}
|
|
60
107
|
const [baseArgument, ...restArguments] = callExpression.arguments;
|
|
@@ -68,6 +115,14 @@ export const preferCurriedProduceRule = {
|
|
|
68
115
|
if (typeWrapperLayers(baseArgument).some((layer) => layer.type === AST_NODE_TYPES.TSNonNullExpression)) {
|
|
69
116
|
return;
|
|
70
117
|
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if (assertsOtherType(baseArgument, param.typeAnnotation === undefined
|
|
122
|
+
? undefined
|
|
123
|
+
: tokensText(sourceCode, param.typeAnnotation.typeAnnotation), sourceCode)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
71
126
|
const baseIdentifier = findIdentifier(baseArgument, parameterName);
|
|
72
127
|
if (baseIdentifier === undefined) {
|
|
73
128
|
return;
|
|
@@ -75,10 +130,17 @@ export const preferCurriedProduceRule = {
|
|
|
75
130
|
if (hasOtherReferences(context, parameterName, baseIdentifier)) {
|
|
76
131
|
return;
|
|
77
132
|
}
|
|
133
|
+
const recipe = restArguments[0];
|
|
134
|
+
const isFixable = node.body === callExpression &&
|
|
135
|
+
!hasWrappedCallee(callExpression) &&
|
|
136
|
+
!hasCommentWithin(sourceCode, node, [
|
|
137
|
+
[node.range[0], recipe.range[0]],
|
|
138
|
+
[recipe.range[1], node.range[1]],
|
|
139
|
+
]);
|
|
78
140
|
report(context, {
|
|
79
141
|
arrowFunction: node,
|
|
80
|
-
baseArgument,
|
|
81
142
|
callExpression,
|
|
143
|
+
isFixable,
|
|
82
144
|
remainingArguments: restArguments,
|
|
83
145
|
sourceCode,
|
|
84
146
|
});
|
|
@@ -97,17 +159,6 @@ const getTypeArguments = (node) => {
|
|
|
97
159
|
}
|
|
98
160
|
return undefined;
|
|
99
161
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const getAssertedType = (node) => {
|
|
105
|
-
if (node.type === AST_NODE_TYPES.TSAsExpression ||
|
|
106
|
-
node.type === AST_NODE_TYPES.TSTypeAssertion) {
|
|
107
|
-
return node.typeAnnotation;
|
|
108
|
-
}
|
|
109
|
-
return isTypeWrapper(node) ? getAssertedType(node.expression) : undefined;
|
|
110
|
-
};
|
|
111
162
|
const getArrowFunctionParameterType = ({ arrowFunction, sourceCode, }) => {
|
|
112
163
|
const [parameter] = arrowFunction.params;
|
|
113
164
|
if (parameter?.type !== AST_NODE_TYPES.Identifier) {
|
|
@@ -124,16 +175,13 @@ const getArrowFunctionReturnType = ({ arrowFunction, sourceCode, }) => {
|
|
|
124
175
|
? undefined
|
|
125
176
|
: sourceCode.getText(typeAnnotation);
|
|
126
177
|
};
|
|
127
|
-
const getTypeParametersText = ({ arrowFunction,
|
|
178
|
+
const getTypeParametersText = ({ arrowFunction, callExpression, sourceCode, }) => {
|
|
128
179
|
const typeArguments = getTypeArguments(callExpression);
|
|
129
180
|
if (typeArguments !== undefined) {
|
|
130
181
|
return sourceCode.getText(typeArguments);
|
|
131
182
|
}
|
|
132
183
|
|
|
133
|
-
|
|
134
|
-
if (assertedType !== undefined) {
|
|
135
|
-
return `<${sourceCode.getText(assertedType)}>`;
|
|
136
|
-
}
|
|
184
|
+
|
|
137
185
|
const parameterType = getArrowFunctionParameterType({
|
|
138
186
|
arrowFunction,
|
|
139
187
|
sourceCode,
|
|
@@ -165,31 +213,67 @@ const normalizeMultilineText = (text) => {
|
|
|
165
213
|
const normalized = lines.map((line, index) => index === 0 ? line : line.slice(minIndent));
|
|
166
214
|
return normalized.join('\n');
|
|
167
215
|
};
|
|
168
|
-
const report = (context, { arrowFunction,
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
216
|
+
const report = (context, { arrowFunction, callExpression, isFixable, remainingArguments, sourceCode, }) => {
|
|
217
|
+
const buildReplacement = () => {
|
|
218
|
+
const calleeText = sourceCode.getText(callExpression.callee);
|
|
219
|
+
const typeParametersText = getTypeParametersText({
|
|
220
|
+
arrowFunction,
|
|
221
|
+
callExpression,
|
|
222
|
+
sourceCode,
|
|
223
|
+
});
|
|
224
|
+
const remainingArgumentsText = remainingArguments
|
|
225
|
+
.map((argument) => normalizeMultilineText(sourceCode.getText(argument)))
|
|
226
|
+
.join(', ');
|
|
227
|
+
return `${calleeText}${typeParametersText}(${remainingArgumentsText})`;
|
|
228
|
+
};
|
|
180
229
|
context.report({
|
|
181
230
|
node: arrowFunction,
|
|
182
231
|
messageId: 'useCurriedProduce',
|
|
183
|
-
fix:
|
|
232
|
+
fix: isFixable
|
|
233
|
+
? (fixer) => fixer.replaceText(arrowFunction, buildReplacement())
|
|
234
|
+
: null,
|
|
184
235
|
});
|
|
185
236
|
};
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
237
|
+
const immerModule = 'immer';
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
const castTypeOf = (node) => node.type === AST_NODE_TYPES.TSAsExpression ||
|
|
243
|
+
node.type === AST_NODE_TYPES.TSTypeAssertion
|
|
244
|
+
? node.typeAnnotation
|
|
245
|
+
: undefined;
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
const hasWrappedCallee = ({ callee, }) => isTypeWrapper(callee) ||
|
|
252
|
+
(callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
253
|
+
isTypeWrapper(callee.object));
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
const tokensText = (sourceCode,
|
|
259
|
+
|
|
260
|
+
node) => sourceCode
|
|
261
|
+
.getTokens(node)
|
|
262
|
+
.map((token) => token.value)
|
|
263
|
+
.join(' ');
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
const assertsOtherType = (argument, parameterType, sourceCode) => argument.type !== AST_NODE_TYPES.SpreadElement &&
|
|
272
|
+
typeWrapperLayers(argument).some((layer) => {
|
|
273
|
+
const castType = castTypeOf(layer);
|
|
274
|
+
return (castType !== undefined &&
|
|
275
|
+
tokensText(sourceCode, castType) !== parameterType);
|
|
276
|
+
});
|
|
193
277
|
|
|
194
278
|
|
|
195
279
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-curried-produce.mjs","sourceRoot":"","sources":["../../../../src/plugins/immer-coding-style/rules/prefer-curried-produce.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUvE
|
|
1
|
+
{"version":3,"file":"prefer-curried-produce.mjs","sourceRoot":"","sources":["../../../../src/plugins/immer-coding-style/rules/prefer-curried-produce.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAoC;IACvE,IAAI,EAAE;QACJ,IAAI,EAAE,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O,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAExC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1E,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,OAA2D,EAC3D,aAAqB,EACrB,cAAiD,EACxC,EAAE;IACX,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC;IAE3E,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CACnC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,aAAa,CACtD,CAAC;IAEF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAC7B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,KAAK,cAAc,CACvD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type Options = readonly [];
|
|
3
|
+
type MessageIds = 'useTopLevelQualifier' | 'importFromDeclaration';
|
|
4
|
+
/**
|
|
5
|
+
* The export-side twin of `@typescript-eslint/no-import-type-side-effects`.
|
|
6
|
+
*
|
|
7
|
+
* Under `verbatimModuleSyntax`, TypeScript drops each inline `type` specifier
|
|
8
|
+
* of `export { type A } from 'm'` and keeps the declaration, so a re-export
|
|
9
|
+
* whose specifiers are all inline `type` is emitted as `export {} from 'm'`: a
|
|
10
|
+
* runtime load of `m`, which fails at module load when `m` is a types-only
|
|
11
|
+
* package with no JavaScript entry. `export type { A } from 'm'` is erased
|
|
12
|
+
* whole. A declaration with no `from` is left alone, since `export {}` loads
|
|
13
|
+
* nothing, and so is one in a declaration file or a `declare module` block,
|
|
14
|
+
* where nothing is emitted.
|
|
15
|
+
*
|
|
16
|
+
* The fix removes each inline `type` and adds one after `export`. A re-export
|
|
17
|
+
* with import attributes (`with { type: 'json' }`) gets its own message and no
|
|
18
|
+
* fix, since TypeScript rejects attributes on a type-only re-export (TS2857):
|
|
19
|
+
* its types are better imported from where they are declared.
|
|
20
|
+
*/
|
|
21
|
+
export declare const noExportTypeSideEffects: TSESLint.RuleModule<MessageIds, Options>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=no-export-type-side-effects.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-export-type-side-effects.d.mts","sourceRoot":"","sources":["../../../../src/plugins/ts-restrictions/rules/no-export-type-side-effects.mts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzE,KAAK,OAAO,GAAG,SAAS,EAAE,CAAC;AAE3B,KAAK,UAAU,GAAG,sBAAsB,GAAG,uBAAuB,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CA4EjE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { inlineTypeQualifierRange } from 'eslint-rule-forge';
|
|
3
|
+
import { Arr } from 'ts-data-forge';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const noExportTypeSideEffects = {
|
|
22
|
+
meta: {
|
|
23
|
+
type: 'problem',
|
|
24
|
+
docs: {
|
|
25
|
+
description: 'Enforce a top-level `export type` qualifier on a re-export whose specifiers all have inline `type` qualifiers',
|
|
26
|
+
},
|
|
27
|
+
fixable: 'code',
|
|
28
|
+
schema: [],
|
|
29
|
+
messages: {
|
|
30
|
+
useTopLevelQualifier: "Under `verbatimModuleSyntax`, TypeScript removes only the inline type specifiers, which leaves `export {} from '…'` behind: a runtime import. Write `export type { … } from '…'` instead.",
|
|
31
|
+
importFromDeclaration: "Under `verbatimModuleSyntax`, TypeScript removes only the inline type specifiers, which leaves `export {} from '…' with { … }` behind: a runtime import. A type-only re-export cannot carry import attributes, so re-export these types from the module that declares them.",
|
|
32
|
+
},
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
},
|
|
35
|
+
create: (context) => {
|
|
36
|
+
if (/\.d\.[cm]?ts$/u.test(context.filename)) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
const { sourceCode } = context;
|
|
40
|
+
return {
|
|
41
|
+
ExportNamedDeclaration: (node) => {
|
|
42
|
+
if (node.source === null ||
|
|
43
|
+
node.exportKind === 'type' ||
|
|
44
|
+
Arr.isEmpty(node.specifiers) ||
|
|
45
|
+
node.specifiers.some((s) => s.exportKind !== 'type') ||
|
|
46
|
+
sourceCode
|
|
47
|
+
.getAncestors(node)
|
|
48
|
+
.some((a) => a.type === AST_NODE_TYPES.TSModuleDeclaration)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (Arr.isNonEmpty(node.attributes)) {
|
|
52
|
+
context.report({ node, messageId: 'importFromDeclaration' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const exportKeyword = sourceCode.getFirstToken(node);
|
|
58
|
+
const qualifierRanges = Arr.generate(function* () {
|
|
59
|
+
for (const specifier of node.specifiers) {
|
|
60
|
+
const range = inlineTypeQualifierRange(sourceCode, specifier);
|
|
61
|
+
if (range !== undefined) {
|
|
62
|
+
yield range;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
context.report({
|
|
67
|
+
node,
|
|
68
|
+
messageId: 'useTopLevelQualifier',
|
|
69
|
+
fix: exportKeyword === null ||
|
|
70
|
+
qualifierRanges.length !== node.specifiers.length
|
|
71
|
+
? null
|
|
72
|
+
: (fixer) => Arr.toPushed(qualifierRanges.map((range) => fixer.removeRange(range)), fixer.insertTextAfter(exportKeyword, ' type')),
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=no-export-type-side-effects.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-export-type-side-effects.mjs","sourceRoot":"","sources":["../../../../src/plugins/ts-restrictions/rules/no-export-type-side-effects.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC;IACE,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,+GAA+G;SAClH;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,oBAAoB,EAClB,2LAA2L;YAC7L,qBAAqB,EACnB,6QAA6Q;SAChR;QACD,cAAc,EAAE,EAAE;KACnB;IAED,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,EA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eAAe,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM;wBAC/C,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CACR,GAAG,CAAC,QAAQ,CACV,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EACxD,KAAK,CAAC,eAAe,CAAC,aAAa,EAAE,OAAO,CAAC,CAC9C;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACO,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare const tsRestrictionsRules: {
|
|
|
7
7
|
readonly 'function-order': import("@typescript-eslint/utils/ts-eslint").RuleModule<"calleeAfterCaller" | "exportedAfterHelper", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
8
8
|
readonly 'jsx-boolean-logical-operands': import("@typescript-eslint/utils/ts-eslint").RuleModule<"booleanOperands" | "nonBooleanLeft", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
9
9
|
readonly 'no-detached-jsdoc': import("@typescript-eslint/utils/ts-eslint").RuleModule<"detachedJsdoc", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
10
|
+
readonly 'no-export-type-side-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"importFromDeclaration" | "useTopLevelQualifier", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
10
11
|
readonly 'no-negated-comparison': import("@typescript-eslint/utils/ts-eslint").RuleModule<"invertComparison" | "negatedComparison" | "negatedComparisonMaybeNaN", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
11
12
|
readonly 'no-ragged-comment-wrap': import("@typescript-eslint/utils/ts-eslint").RuleModule<"raggedWrap", readonly [(Readonly<{
|
|
12
13
|
printWidth?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.mts","sourceRoot":"","sources":["../../../../src/plugins/ts-restrictions/rules/rules.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rules.d.mts","sourceRoot":"","sources":["../../../../src/plugins/ts-restrictions/rules/rules.mts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBU,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { explicitCollectionTypeArguments } from './explicit-collection-type-argu
|
|
|
3
3
|
import { functionOrder } from './function-order.mjs';
|
|
4
4
|
import { jsxBooleanLogicalOperands } from './jsx-boolean-logical-operands.mjs';
|
|
5
5
|
import { noDetachedJsdoc } from './no-detached-jsdoc.mjs';
|
|
6
|
+
import { noExportTypeSideEffects } from './no-export-type-side-effects.mjs';
|
|
6
7
|
import { noNegatedComparison } from './no-negated-comparison.mjs';
|
|
7
8
|
import { noRaggedCommentWrap } from './no-ragged-comment-wrap.mjs';
|
|
8
9
|
import { noRestrictedCastName } from './no-restricted-cast-name.mjs';
|
|
@@ -26,6 +27,7 @@ export const tsRestrictionsRules = {
|
|
|
26
27
|
'function-order': functionOrder,
|
|
27
28
|
'jsx-boolean-logical-operands': jsxBooleanLogicalOperands,
|
|
28
29
|
'no-detached-jsdoc': noDetachedJsdoc,
|
|
30
|
+
'no-export-type-side-effects': noExportTypeSideEffects,
|
|
29
31
|
'no-negated-comparison': noNegatedComparison,
|
|
30
32
|
'no-ragged-comment-wrap': noRaggedCommentWrap,
|
|
31
33
|
'no-restricted-cast-name': noRestrictedCastName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.mjs","sourceRoot":"","sources":["../../../../src/plugins/ts-restrictions/rules/rules.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,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B,EAAE,aAAa;IAC/B,4BAA4B,EAAE,sBAAsB;CACZ,CAAC"}
|
|
@@ -19,7 +19,9 @@ type MessageIds = 'useAssert';
|
|
|
19
19
|
* recovered by adding a second assertion.
|
|
20
20
|
*
|
|
21
21
|
* The calls and the `expect` function are read through `as`, `satisfies`, `!`
|
|
22
|
-
* and `<T>` (`expect(X)!.toStrictEqual(Y)`); `X` and `Y` keep theirs.
|
|
22
|
+
* and `<T>` (`expect(X)!.toStrictEqual(Y)`); `X` and `Y` keep theirs. `expect`
|
|
23
|
+
* is Vitest's only (`getVitestReceiver`), and the fix names Vitest's `assert`
|
|
24
|
+
* only (`createVitestAssertFixer`).
|
|
23
25
|
*/
|
|
24
26
|
export declare const noExpectToStrictEqualRule: TSESLint.RuleModule<MessageIds>;
|
|
25
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-expect-to-strict-equal.d.mts","sourceRoot":"","sources":["../../../../src/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"no-expect-to-strict-equal.d.mts","sourceRoot":"","sources":["../../../../src/plugins/vitest-coding-style/rules/no-expect-to-strict-equal.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;AAQlC,KAAK,UAAU,GAAG,WAAW,CAAC;AAO9B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAiF5D,CAAC"}
|