exadev-eslint-config 2.15.0 → 2.16.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 +6 -4
- package/dist/index.cjs +33 -13
- package/dist/index.js +33 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Consumers need `eslint >=10.0.0` and `typescript-eslint >=8.0.0` as required pee
|
|
|
16
16
|
pnpm add -D @exadev/eslint-config typescript-eslint eslint
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
The default export is the full, type-checked ruleset: typescript-eslint's `strictTypeChecked` + `stylisticTypeChecked` presets (`strictTypeChecked` subsumes `recommendedTypeChecked`, so it already includes `no-deprecated`, `no-misused-spread`, `no-mixed-enums`, `no-unnecessary-condition`, `use-unknown-in-catch-callback-variable`, `return-await`, `related-getter-setter-pairs`, `no-unnecessary-type-parameters`, and more -- those are no longer re-listed below), `exadev/barrel-policy` at `mode: 'banned'` (see [Barrel policy](#barrel-policy)), `exadev/no-object-assign`, `exadev/no-mutable-union-array-param`, `exadev/no-array-isarray-mutation`, `exadev/no-enum-number-widening`, `exadev/no-enum-reverse-lookup-widening`, `exadev/no-map-instanceof-mutation`, `exadev/no-set-instanceof-mutation`, `exadev/prefer-readonly-array-param`, `exadev/prefer-readonly-object-param`, `exadev/prefer-numeric-sort-compare`, `exadev/no-pointless-reassignment`, `linterOptions.noInlineConfig`, `@typescript-eslint/consistent-type-assertions` banning all type assertions, `@typescript-eslint/consistent-type-imports`, `@typescript-eslint/consistent-type-exports`, `@typescript-eslint/consistent-return` (a function that implicitly returns `undefined` on one path and a real value on another -- a common real bug, not a deliberate design), `@typescript-eslint/no-non-null-assertion` banning the `!` operator (the same manual-override escape hatch as a type assertion, under a different spelling), `@typescript-eslint/no-redeclare`, `@typescript-eslint/no-shadow`, `@typescript-eslint/no-use-before-define` set to `{ functions: false }` (a genuine temporal-dead-zone crash risk for `let`/`const`/`class`/enum bindings, but exempting function declarations, which are fully hoisted and therefore runtime-safe to call before their point of textual declaration -- this codebase's own rule files consistently define their helper functions after the logic that calls them), `@typescript-eslint/ban-ts-comment` banning `@ts-expect-error` outright, `@typescript-eslint/method-signature-style` set to `'property'` (method-shorthand signatures are checked bivariantly under `strictFunctionTypes`, which is unsound), `@typescript-eslint/prefer-readonly`, `@typescript-eslint/promise-function-async`, `@typescript-eslint/require-array-sort-compare`, `@typescript-eslint/strict-void-return` (not yet in any typescript-eslint preset -- disallows passing a value-returning function where a void-returning one is expected, e.g. `arr.forEach(x => otherArray.push(x))`, which typechecks today under TS's own void-return contravariance leniency), `@typescript-eslint/switch-exhaustiveness-check`, `@typescript-eslint/strict-boolean-expressions` at the rule's own bare defaults (an unambiguous non-nullable truthy check stays allowed; an ambiguous nullable check does not), `@typescript-eslint/no-magic-numbers` tuned to exempt array indexes, enum members, readonly class properties, default parameter values, and the handful of universally-idiomatic bare numbers (`-1`, `0`, `1`, `2`), `max-lines` set to `{ max: 800, skipBlankLines: true, skipComments: true }` (counting only real code, so a file isn't pushed over the limit by whitespace or its own WHY-explanation comments), and `no-warning-comments` banning any comment containing `Stryker disable` (Stryker's own mutation-testing suppression directive, invisible to ESLint's `noInlineConfig` above since it isn't an eslint-disable comment at all) -- the type-assertion and ts-comment rules are relaxed in test files, and `no-magic-numbers`/`max-lines`/`no-warning-comments` are not (see below). Spread it directly into `tseslint.config(...)`:
|
|
19
|
+
The default export is the full, type-checked ruleset: typescript-eslint's `strictTypeChecked` + `stylisticTypeChecked` presets (`strictTypeChecked` subsumes `recommendedTypeChecked`, so it already includes `no-deprecated`, `no-misused-spread`, `no-mixed-enums`, `no-unnecessary-condition`, `use-unknown-in-catch-callback-variable`, `return-await`, `related-getter-setter-pairs`, `no-unnecessary-type-parameters`, and more -- those are no longer re-listed below), `exadev/barrel-policy` at `mode: 'banned'` (see [Barrel policy](#barrel-policy)), `exadev/no-object-assign`, `exadev/no-mutable-union-array-param`, `exadev/no-array-isarray-mutation`, `exadev/no-enum-number-widening`, `exadev/no-enum-reverse-lookup-widening`, `exadev/no-map-instanceof-mutation`, `exadev/no-set-instanceof-mutation`, `exadev/prefer-readonly-array-param`, `exadev/prefer-readonly-object-param`, `exadev/prefer-numeric-sort-compare`, `exadev/no-pointless-reassignment`, `linterOptions.noInlineConfig`, `@typescript-eslint/consistent-type-assertions` banning all type assertions, `@typescript-eslint/consistent-type-imports`, `@typescript-eslint/consistent-type-exports`, `@typescript-eslint/consistent-return` (a function that implicitly returns `undefined` on one path and a real value on another -- a common real bug, not a deliberate design), `@typescript-eslint/no-non-null-assertion` banning the `!` operator (the same manual-override escape hatch as a type assertion, under a different spelling), `@typescript-eslint/no-redeclare`, `@typescript-eslint/no-shadow`, `@typescript-eslint/no-use-before-define` set to `{ functions: false }` (a genuine temporal-dead-zone crash risk for `let`/`const`/`class`/enum bindings, but exempting function declarations, which are fully hoisted and therefore runtime-safe to call before their point of textual declaration -- this codebase's own rule files consistently define their helper functions after the logic that calls them), `@typescript-eslint/ban-ts-comment` banning `@ts-expect-error` outright, `@typescript-eslint/method-signature-style` set to `'property'` (method-shorthand signatures are checked bivariantly under `strictFunctionTypes`, which is unsound), `@typescript-eslint/prefer-readonly`, `@typescript-eslint/promise-function-async`, `@typescript-eslint/require-array-sort-compare`, `@typescript-eslint/strict-void-return` (not yet in any typescript-eslint preset -- disallows passing a value-returning function where a void-returning one is expected, e.g. `arr.forEach(x => otherArray.push(x))`, which typechecks today under TS's own void-return contravariance leniency), `@typescript-eslint/switch-exhaustiveness-check`, `@typescript-eslint/strict-boolean-expressions` at the rule's own bare defaults (an unambiguous non-nullable truthy check stays allowed; an ambiguous nullable check does not), `@typescript-eslint/no-magic-numbers` tuned to exempt array indexes, enum members, readonly class properties, default parameter values, numeric literal types (e.g. `type Indent = 2 | 4`), and the handful of universally-idiomatic bare numbers (`-1`, `0`, `1`, `2`), `max-lines` set to `{ max: 800, skipBlankLines: true, skipComments: true }` (counting only real code, so a file isn't pushed over the limit by whitespace or its own WHY-explanation comments), and `no-warning-comments` banning any comment containing `Stryker disable` (Stryker's own mutation-testing suppression directive, invisible to ESLint's `noInlineConfig` above since it isn't an eslint-disable comment at all) -- the type-assertion and ts-comment rules are relaxed in test files, and `no-magic-numbers`/`max-lines`/`no-warning-comments` are not (see below). Spread it directly into `tseslint.config(...)`:
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
// eslint.config.ts
|
|
@@ -162,11 +162,13 @@ Trailing arguments are arbitrary flat-config objects, appended in order after ev
|
|
|
162
162
|
|
|
163
163
|
## RFC 8785 canonical JSON formatting
|
|
164
164
|
|
|
165
|
-
Every JSON file
|
|
165
|
+
Every JSON file is linted against [`eslint-plugin-json-canonical`](https://github.com/ExaDev/eslint-plugin-json-canonical) v2 -- plain UTF-16 code-unit key ordering, canonical number formatting, canonical string escaping, and (as of that plugin's own v2) pretty-printed layout (2-space indentation, one member/element per line, a trailing newline), per [RFC 8785](https://www.rfc-editor.org/rfc/rfc8785). This is bundled unconditionally, the same way jsdoc/tsdoc support is: `eslint-plugin-json-canonical` is a plain dependency of this package, so every consumer already has it. There is no option to turn it off.
|
|
166
166
|
|
|
167
|
-
The plugin's own
|
|
167
|
+
The plugin's own full-canonicalization rule (`no-insignificant-whitespace`, which collapses a document to a single compacted line with no whitespace at all) is deliberately not part of the config this package extends -- it stays available for a consumer to opt into directly for their own genuine canonicalization pass (hashing, signing, byte-for-byte comparison).
|
|
168
168
|
|
|
169
|
-
`**/tsconfig*.json
|
|
169
|
+
`**/*.jsonc`, `**/tsconfig*.json`, and `**/turbo.json` get the plugin's `configs.contentOnlyJsonc` instead of the plain-JSON config: they genuinely carry comments (TypeScript and turbo both accept them), which `@eslint/json`'s `json/json` language has no concept of and fails to parse, and neither pretty-printing nor whitespace-collapsing has a well-defined answer for a comment's own attachment to a member once its surrounding whitespace is rewritten. Content canonicalization (key order, number/string formatting) still applies to these files under `json/jsonc`.
|
|
170
|
+
|
|
171
|
+
`**/package.json` gets everything the plain-JSON config gives every other file -- including pretty-printed layout -- except `json/sort-keys`, turned back off in its own override block, since its key order is the separate, syncpack-aware concern the next section covers.
|
|
170
172
|
|
|
171
173
|
## Optional package.json key ordering
|
|
172
174
|
|
package/dist/index.cjs
CHANGED
|
@@ -81,17 +81,36 @@ const jsdocAndTsdoc = [{
|
|
|
81
81
|
function isSingleFlatConfig(value) {
|
|
82
82
|
return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
function requireConfig(name) {
|
|
85
|
+
const config = eslint_plugin_json_canonical.default.configs?.[name];
|
|
86
|
+
if (!isSingleFlatConfig(config)) throw new Error(`eslint-plugin-json-canonical: expected configs.${name} to be a single flat config object, got an array or undefined`);
|
|
87
|
+
return config;
|
|
88
|
+
}
|
|
89
|
+
const recommended = requireConfig("recommended");
|
|
90
|
+
const contentOnlyJsonc = requireConfig("contentOnlyJsonc");
|
|
91
|
+
const jsonCanonicalConfig = [
|
|
92
|
+
{
|
|
93
|
+
files: ["**/*.json"],
|
|
94
|
+
ignores: [
|
|
95
|
+
"**/*.jsonc",
|
|
96
|
+
"**/tsconfig*.json",
|
|
97
|
+
"**/turbo.json"
|
|
98
|
+
],
|
|
99
|
+
...recommended
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
files: [
|
|
103
|
+
"**/*.jsonc",
|
|
104
|
+
"**/tsconfig*.json",
|
|
105
|
+
"**/turbo.json"
|
|
106
|
+
],
|
|
107
|
+
...contentOnlyJsonc
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
files: ["**/package.json"],
|
|
111
|
+
rules: { "json/sort-keys": "off" }
|
|
112
|
+
}
|
|
113
|
+
];
|
|
95
114
|
//#endregion
|
|
96
115
|
//#region src/optional-plugin.ts
|
|
97
116
|
const nodeRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
@@ -141,7 +160,7 @@ function buildNextjsConfig(options = {}) {
|
|
|
141
160
|
}
|
|
142
161
|
//#endregion
|
|
143
162
|
//#region package.json
|
|
144
|
-
var version = "2.
|
|
163
|
+
var version = "2.16.1";
|
|
145
164
|
//#endregion
|
|
146
165
|
//#region src/react.ts
|
|
147
166
|
const JSX_FILE_PATTERNS = ["**/*.jsx", "**/*.tsx"];
|
|
@@ -1812,7 +1831,8 @@ const recommendedTypeChecked = [
|
|
|
1812
1831
|
ignoreArrayIndexes: true,
|
|
1813
1832
|
ignoreEnums: true,
|
|
1814
1833
|
ignoreReadonlyClassProperties: true,
|
|
1815
|
-
ignoreDefaultValues: true
|
|
1834
|
+
ignoreDefaultValues: true,
|
|
1835
|
+
ignoreNumericLiteralTypes: true
|
|
1816
1836
|
}],
|
|
1817
1837
|
"@typescript-eslint/no-non-null-assertion": "error",
|
|
1818
1838
|
"@typescript-eslint/no-redeclare": "error",
|
package/dist/index.js
CHANGED
|
@@ -49,17 +49,36 @@ const jsdocAndTsdoc = [{
|
|
|
49
49
|
function isSingleFlatConfig(value) {
|
|
50
50
|
return typeof value === "object" && value !== null && !Array.isArray(value) && "language" in value;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
function requireConfig(name) {
|
|
53
|
+
const config = jsonCanonical.configs?.[name];
|
|
54
|
+
if (!isSingleFlatConfig(config)) throw new Error(`eslint-plugin-json-canonical: expected configs.${name} to be a single flat config object, got an array or undefined`);
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
const recommended = requireConfig("recommended");
|
|
58
|
+
const contentOnlyJsonc = requireConfig("contentOnlyJsonc");
|
|
59
|
+
const jsonCanonicalConfig = [
|
|
60
|
+
{
|
|
61
|
+
files: ["**/*.json"],
|
|
62
|
+
ignores: [
|
|
63
|
+
"**/*.jsonc",
|
|
64
|
+
"**/tsconfig*.json",
|
|
65
|
+
"**/turbo.json"
|
|
66
|
+
],
|
|
67
|
+
...recommended
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
files: [
|
|
71
|
+
"**/*.jsonc",
|
|
72
|
+
"**/tsconfig*.json",
|
|
73
|
+
"**/turbo.json"
|
|
74
|
+
],
|
|
75
|
+
...contentOnlyJsonc
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
files: ["**/package.json"],
|
|
79
|
+
rules: { "json/sort-keys": "off" }
|
|
80
|
+
}
|
|
81
|
+
];
|
|
63
82
|
//#endregion
|
|
64
83
|
//#region src/optional-plugin.ts
|
|
65
84
|
const nodeRequire = createRequire(import.meta.url);
|
|
@@ -109,7 +128,7 @@ function buildNextjsConfig(options = {}) {
|
|
|
109
128
|
}
|
|
110
129
|
//#endregion
|
|
111
130
|
//#region package.json
|
|
112
|
-
var version = "2.
|
|
131
|
+
var version = "2.16.1";
|
|
113
132
|
//#endregion
|
|
114
133
|
//#region src/react.ts
|
|
115
134
|
const JSX_FILE_PATTERNS = ["**/*.jsx", "**/*.tsx"];
|
|
@@ -1780,7 +1799,8 @@ const recommendedTypeChecked = [
|
|
|
1780
1799
|
ignoreArrayIndexes: true,
|
|
1781
1800
|
ignoreEnums: true,
|
|
1782
1801
|
ignoreReadonlyClassProperties: true,
|
|
1783
|
-
ignoreDefaultValues: true
|
|
1802
|
+
ignoreDefaultValues: true,
|
|
1803
|
+
ignoreNumericLiteralTypes: true
|
|
1784
1804
|
}],
|
|
1785
1805
|
"@typescript-eslint/no-non-null-assertion": "error",
|
|
1786
1806
|
"@typescript-eslint/no-redeclare": "error",
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exadev-eslint-config",
|
|
3
3
|
"description": "Shared custom ESLint rules and plugin for ExaDev projects",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@eslint/js": "^10.0.1",
|
|
7
7
|
"@typescript-eslint/utils": "8.67.0",
|
|
8
8
|
"eslint-plugin-jsdoc": "64.3.6",
|
|
9
|
-
"eslint-plugin-json-canonical": "
|
|
9
|
+
"eslint-plugin-json-canonical": "2.0.0",
|
|
10
10
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
11
11
|
"ts-api-utils": "^2.5.0"
|
|
12
12
|
},
|