@antelopejs/tooling-configs 0.0.2 → 0.0.4
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/dist/eslint.mjs +1 -0
- package/dist/knip.mjs +13 -4
- package/dist/oxc/lint.d.mts +44 -4
- package/dist/oxc/lint.mjs +67 -17
- package/package.json +3 -2
package/dist/eslint.mjs
CHANGED
|
@@ -16,6 +16,7 @@ const ANTELOPE_NUXT_RULES = {
|
|
|
16
16
|
"vue/require-default-prop": "off",
|
|
17
17
|
"@typescript-eslint/no-explicit-any": "off",
|
|
18
18
|
"@typescript-eslint/no-empty-object-type": "off",
|
|
19
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
19
20
|
"@typescript-eslint/no-unused-vars": ["error", {
|
|
20
21
|
argsIgnorePattern: "^_",
|
|
21
22
|
varsIgnorePattern: "^_",
|
package/dist/knip.mjs
CHANGED
|
@@ -12,17 +12,26 @@ const DEFAULT_IGNORE = [
|
|
|
12
12
|
".antelope/**"
|
|
13
13
|
];
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* `typecheck` is a script in the Nuxt layer's own manifest, outside the analysed
|
|
16
|
+
* project, and every layer's CI runs it.
|
|
17
|
+
*
|
|
18
|
+
* The AntelopeJS CLIs are deliberately absent: a repository that invokes `ajs`
|
|
19
|
+
* or `acms` declares the package providing it, so Knip resolves them and an
|
|
20
|
+
* ignore would only hide a missing dependency.
|
|
18
21
|
*/
|
|
19
22
|
const DEFAULT_IGNORE_BINARIES = ["typecheck"];
|
|
23
|
+
/**
|
|
24
|
+
* The AntelopeJS runtime loads modules by name, from the antelope config rather
|
|
25
|
+
* than through an import, so nothing in the source points at them and Knip reads
|
|
26
|
+
* every one as dead weight.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_IGNORE_DEPENDENCIES = ["@antelopejs/.*"];
|
|
20
29
|
function antelopeKnipConfig(options = {}) {
|
|
21
30
|
return {
|
|
22
31
|
entry: [...DEFAULT_ENTRY, ...options.entry ?? []],
|
|
23
32
|
project: [...DEFAULT_PROJECT, ...options.project ?? []],
|
|
24
33
|
ignore: [...DEFAULT_IGNORE, ...options.ignore ?? []],
|
|
25
|
-
ignoreDependencies: options.ignoreDependencies ?? [],
|
|
34
|
+
ignoreDependencies: [...DEFAULT_IGNORE_DEPENDENCIES, ...options.ignoreDependencies ?? []],
|
|
26
35
|
ignoreBinaries: [...DEFAULT_IGNORE_BINARIES, ...options.ignoreBinaries ?? []]
|
|
27
36
|
};
|
|
28
37
|
}
|
package/dist/oxc/lint.d.mts
CHANGED
|
@@ -82,6 +82,40 @@ interface AntelopePresetOptions {
|
|
|
82
82
|
typeAware?: boolean;
|
|
83
83
|
}
|
|
84
84
|
/** Every generic anti-slop rule, exported so this package can lint itself. */
|
|
85
|
+
/**
|
|
86
|
+
* The anti-slop rules left off by default.
|
|
87
|
+
*
|
|
88
|
+
* Measured across the sixteen cms/dms repositories: these seven produced 3038
|
|
89
|
+
* of the 3429 anti-slop findings, and every sample we read was either the
|
|
90
|
+
* correct idiom or a design change well beyond a lint pass.
|
|
91
|
+
*
|
|
92
|
+
* - `require-safety-comment-for-type-assertion` (1283) is satisfied by writing
|
|
93
|
+
* a comment, so at that volume it manufactures the noise it exists to fight.
|
|
94
|
+
* Removing assertions is the goal; annotating them is not.
|
|
95
|
+
* - `no-unknown-parameters` (566) and `no-unknown-returns` (104) fire on catch
|
|
96
|
+
* handlers, where `unknown` is the only correct type, and on the parsers
|
|
97
|
+
* whose whole job is to take unknown in and hand typed values out.
|
|
98
|
+
* - `no-runtime-typeof` (460) assumes a validation layer above the check. In a
|
|
99
|
+
* CMS reading Vault responses, WebSocket frames and user-defined rows, the
|
|
100
|
+
* `typeof` *is* that layer.
|
|
101
|
+
* - `no-unsafe-dictionary-type` (442) is right in a business application and
|
|
102
|
+
* wrong here: tables and columns defined at run time have no compile-time
|
|
103
|
+
* schema, which is the product, not a typing gap.
|
|
104
|
+
* - `no-shape-in-symbol-names` (104) matches a substring in identifiers and
|
|
105
|
+
* catches domain words such as `BlueGreenShape`.
|
|
106
|
+
* - `no-module-mocking` (79) is a test-architecture position, not cleanup.
|
|
107
|
+
* - `no-known-value-widening` (201) is the near miss. Of 174 sampled, 96 are
|
|
108
|
+
* `return accumulator` where the object was filled in a loop from run-time
|
|
109
|
+
* keys, so the open dictionary is the honest type and there is no evidence to
|
|
110
|
+
* preserve; the rule reads them as stable consts because assigning a property
|
|
111
|
+
* is not a write to the binding. The 53 real ones -- annotated object
|
|
112
|
+
* literals that should use `satisfies` -- are worth fixing by hand, and are,
|
|
113
|
+
* but not at the price of 96 suppressions. Narrowing the rule to literals
|
|
114
|
+
* would make it worth turning back on.
|
|
115
|
+
*
|
|
116
|
+
* A repository that wants one back enables it in its own `rules` block.
|
|
117
|
+
*/
|
|
118
|
+
declare const ANTI_SLOP_RULES_OFF_BY_DEFAULT: readonly ["no-known-value-widening", "no-module-mocking", "no-runtime-typeof", "no-shape-in-symbol-names", "no-unknown-parameters", "no-unknown-returns", "no-unsafe-dictionary-type", "require-safety-comment-for-type-assertion"];
|
|
85
119
|
declare const ANTI_SLOP_RULES: readonly ["no-chained-type-assertions", "no-conditional-empty-object-spread", "no-known-value-widening", "no-module-mocking", "no-object-parameters", "no-reflect-apply", "no-reflect-get", "no-runtime-typeof", "no-shape-in-symbol-names", "no-unknown-parameters", "no-unknown-returns", "no-unknown-type-aliases", "no-unsafe-dictionary-type", "no-widen-then-assert", "require-safety-comment-for-type-assertion"];
|
|
86
120
|
/**
|
|
87
121
|
* The anti-slop rules at one severity. Exported for this repository's own config:
|
|
@@ -118,7 +152,13 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
118
152
|
argsIgnorePattern: "^_";
|
|
119
153
|
varsIgnorePattern: "^_";
|
|
120
154
|
caughtErrorsIgnorePattern: "^_";
|
|
155
|
+
ignoreRestSiblings: true;
|
|
156
|
+
}];
|
|
157
|
+
"eslint/eqeqeq": ["error", "always", {
|
|
158
|
+
null: "ignore";
|
|
121
159
|
}];
|
|
160
|
+
"eslint/radix": "error";
|
|
161
|
+
"eslint/prefer-regex-literals": "error";
|
|
122
162
|
"import/no-cycle": Severity;
|
|
123
163
|
"import/no-self-import": "error";
|
|
124
164
|
"import/no-duplicates": "error";
|
|
@@ -130,6 +170,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
130
170
|
"typescript/unbound-method": "warn";
|
|
131
171
|
"typescript/no-meaningless-void-operator": "warn";
|
|
132
172
|
"typescript/no-misused-spread": "warn";
|
|
173
|
+
"typescript/no-base-to-string": "warn";
|
|
133
174
|
"typescript/no-redundant-type-constituents": "warn";
|
|
134
175
|
"typescript/restrict-template-expressions": "warn";
|
|
135
176
|
"typescript/require-array-sort-compare": "warn";
|
|
@@ -139,9 +180,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
139
180
|
name: string;
|
|
140
181
|
specifier: string;
|
|
141
182
|
}[];
|
|
142
|
-
rules:
|
|
143
|
-
[k: string]: Severity;
|
|
144
|
-
};
|
|
183
|
+
rules: Record<string, Severity>;
|
|
145
184
|
} | {
|
|
146
185
|
rules: {
|
|
147
186
|
"eslint/max-params": [Severity, {
|
|
@@ -170,6 +209,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
170
209
|
"perfectionist/sort-imports": ["error", {
|
|
171
210
|
type: "line-length";
|
|
172
211
|
order: "asc";
|
|
212
|
+
sortSideEffects: boolean;
|
|
173
213
|
internalPattern: string[];
|
|
174
214
|
groups: string[][];
|
|
175
215
|
}];
|
|
@@ -180,4 +220,4 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
|
|
|
180
220
|
};
|
|
181
221
|
};
|
|
182
222
|
//#endregion
|
|
183
|
-
export { ANTELOPE_IGNORE_PATTERNS, ANTI_SLOP_RULES, AntelopePresetOptions, ComplexityThresholds, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset, antiSlopRules };
|
|
223
|
+
export { ANTELOPE_IGNORE_PATTERNS, ANTI_SLOP_RULES, ANTI_SLOP_RULES_OFF_BY_DEFAULT, AntelopePresetOptions, ComplexityThresholds, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset, antiSlopRules };
|
package/dist/oxc/lint.mjs
CHANGED
|
@@ -23,6 +23,49 @@ const DEFAULT_COMPLEXITY_THRESHOLDS = {
|
|
|
23
23
|
complexity: 20
|
|
24
24
|
};
|
|
25
25
|
/** Every generic anti-slop rule, exported so this package can lint itself. */
|
|
26
|
+
/**
|
|
27
|
+
* The anti-slop rules left off by default.
|
|
28
|
+
*
|
|
29
|
+
* Measured across the sixteen cms/dms repositories: these seven produced 3038
|
|
30
|
+
* of the 3429 anti-slop findings, and every sample we read was either the
|
|
31
|
+
* correct idiom or a design change well beyond a lint pass.
|
|
32
|
+
*
|
|
33
|
+
* - `require-safety-comment-for-type-assertion` (1283) is satisfied by writing
|
|
34
|
+
* a comment, so at that volume it manufactures the noise it exists to fight.
|
|
35
|
+
* Removing assertions is the goal; annotating them is not.
|
|
36
|
+
* - `no-unknown-parameters` (566) and `no-unknown-returns` (104) fire on catch
|
|
37
|
+
* handlers, where `unknown` is the only correct type, and on the parsers
|
|
38
|
+
* whose whole job is to take unknown in and hand typed values out.
|
|
39
|
+
* - `no-runtime-typeof` (460) assumes a validation layer above the check. In a
|
|
40
|
+
* CMS reading Vault responses, WebSocket frames and user-defined rows, the
|
|
41
|
+
* `typeof` *is* that layer.
|
|
42
|
+
* - `no-unsafe-dictionary-type` (442) is right in a business application and
|
|
43
|
+
* wrong here: tables and columns defined at run time have no compile-time
|
|
44
|
+
* schema, which is the product, not a typing gap.
|
|
45
|
+
* - `no-shape-in-symbol-names` (104) matches a substring in identifiers and
|
|
46
|
+
* catches domain words such as `BlueGreenShape`.
|
|
47
|
+
* - `no-module-mocking` (79) is a test-architecture position, not cleanup.
|
|
48
|
+
* - `no-known-value-widening` (201) is the near miss. Of 174 sampled, 96 are
|
|
49
|
+
* `return accumulator` where the object was filled in a loop from run-time
|
|
50
|
+
* keys, so the open dictionary is the honest type and there is no evidence to
|
|
51
|
+
* preserve; the rule reads them as stable consts because assigning a property
|
|
52
|
+
* is not a write to the binding. The 53 real ones -- annotated object
|
|
53
|
+
* literals that should use `satisfies` -- are worth fixing by hand, and are,
|
|
54
|
+
* but not at the price of 96 suppressions. Narrowing the rule to literals
|
|
55
|
+
* would make it worth turning back on.
|
|
56
|
+
*
|
|
57
|
+
* A repository that wants one back enables it in its own `rules` block.
|
|
58
|
+
*/
|
|
59
|
+
const ANTI_SLOP_RULES_OFF_BY_DEFAULT = [
|
|
60
|
+
"no-known-value-widening",
|
|
61
|
+
"no-module-mocking",
|
|
62
|
+
"no-runtime-typeof",
|
|
63
|
+
"no-shape-in-symbol-names",
|
|
64
|
+
"no-unknown-parameters",
|
|
65
|
+
"no-unknown-returns",
|
|
66
|
+
"no-unsafe-dictionary-type",
|
|
67
|
+
"require-safety-comment-for-type-assertion"
|
|
68
|
+
];
|
|
26
69
|
const ANTI_SLOP_RULES = [
|
|
27
70
|
"no-chained-type-assertions",
|
|
28
71
|
"no-conditional-empty-object-spread",
|
|
@@ -63,8 +106,16 @@ function basePreset(cycleSeverity) {
|
|
|
63
106
|
"eslint/no-unused-vars": ["error", {
|
|
64
107
|
argsIgnorePattern: "^_",
|
|
65
108
|
varsIgnorePattern: "^_",
|
|
66
|
-
caughtErrorsIgnorePattern: "^_"
|
|
109
|
+
caughtErrorsIgnorePattern: "^_",
|
|
110
|
+
ignoreRestSiblings: true
|
|
67
111
|
}],
|
|
112
|
+
"eslint/eqeqeq": [
|
|
113
|
+
"error",
|
|
114
|
+
"always",
|
|
115
|
+
{ null: "ignore" }
|
|
116
|
+
],
|
|
117
|
+
"eslint/radix": "error",
|
|
118
|
+
"eslint/prefer-regex-literals": "error",
|
|
68
119
|
"import/no-cycle": cycleSeverity,
|
|
69
120
|
"import/no-self-import": "error",
|
|
70
121
|
"import/no-duplicates": "error"
|
|
@@ -77,7 +128,8 @@ function basePreset(cycleSeverity) {
|
|
|
77
128
|
* so linting never waits on a build.
|
|
78
129
|
*/
|
|
79
130
|
function antiSlopRules(severity) {
|
|
80
|
-
|
|
131
|
+
const off = new Set(ANTI_SLOP_RULES_OFF_BY_DEFAULT);
|
|
132
|
+
return Object.fromEntries(ANTI_SLOP_RULES.map((rule) => [`anti-slop/${rule}`, off.has(rule) ? "off" : severity]));
|
|
81
133
|
}
|
|
82
134
|
function antiSlopPreset(severity) {
|
|
83
135
|
return defineConfig({
|
|
@@ -85,7 +137,7 @@ function antiSlopPreset(severity) {
|
|
|
85
137
|
name: "anti-slop",
|
|
86
138
|
specifier: "@antelopejs/tooling-configs/oxc/anti-slop"
|
|
87
139
|
}],
|
|
88
|
-
rules:
|
|
140
|
+
rules: antiSlopRules(severity)
|
|
89
141
|
});
|
|
90
142
|
}
|
|
91
143
|
function complexityPreset(thresholds, severity) {
|
|
@@ -118,6 +170,7 @@ function typeAwarePreset() {
|
|
|
118
170
|
"typescript/unbound-method": "warn",
|
|
119
171
|
"typescript/no-meaningless-void-operator": "warn",
|
|
120
172
|
"typescript/no-misused-spread": "warn",
|
|
173
|
+
"typescript/no-base-to-string": "warn",
|
|
121
174
|
"typescript/no-redundant-type-constituents": "warn",
|
|
122
175
|
"typescript/restrict-template-expressions": "warn",
|
|
123
176
|
"typescript/require-array-sort-compare": "warn"
|
|
@@ -129,20 +182,17 @@ function importSortingPreset() {
|
|
|
129
182
|
rules: { "perfectionist/sort-imports": ["error", {
|
|
130
183
|
type: "line-length",
|
|
131
184
|
order: "asc",
|
|
185
|
+
sortSideEffects: false,
|
|
132
186
|
internalPattern: ["^@/.*", "^~/.*"],
|
|
133
|
-
groups: [
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
"style",
|
|
143
|
-
"unknown"
|
|
144
|
-
]
|
|
145
|
-
]
|
|
187
|
+
groups: [["builtin", "external"], [
|
|
188
|
+
"internal",
|
|
189
|
+
"subpath",
|
|
190
|
+
"parent",
|
|
191
|
+
"sibling",
|
|
192
|
+
"index",
|
|
193
|
+
"style",
|
|
194
|
+
"unknown"
|
|
195
|
+
]]
|
|
146
196
|
}] }
|
|
147
197
|
});
|
|
148
198
|
}
|
|
@@ -185,4 +235,4 @@ function antelopePreset(options = {}) {
|
|
|
185
235
|
});
|
|
186
236
|
}
|
|
187
237
|
//#endregion
|
|
188
|
-
export { ANTELOPE_IGNORE_PATTERNS, ANTI_SLOP_RULES, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset, antiSlopRules };
|
|
238
|
+
export { ANTELOPE_IGNORE_PATTERNS, ANTI_SLOP_RULES, ANTI_SLOP_RULES_OFF_BY_DEFAULT, DEFAULT_COMPLEXITY_THRESHOLDS, antelopePreset, antiSlopRules };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS projects: oxlint (incl. vendored anti-slop) and Knip",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"./eslint": "./dist/eslint.mjs"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
29
|
+
"access": "public",
|
|
30
|
+
"provenance": true
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
33
|
"build": "tsdown",
|