@antelopejs/tooling-configs 0.0.3 → 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.
@@ -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,6 +152,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
118
152
  argsIgnorePattern: "^_";
119
153
  varsIgnorePattern: "^_";
120
154
  caughtErrorsIgnorePattern: "^_";
155
+ ignoreRestSiblings: true;
121
156
  }];
122
157
  "eslint/eqeqeq": ["error", "always", {
123
158
  null: "ignore";
@@ -145,9 +180,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
145
180
  name: string;
146
181
  specifier: string;
147
182
  }[];
148
- rules: {
149
- [k: string]: Severity;
150
- };
183
+ rules: Record<string, Severity>;
151
184
  } | {
152
185
  rules: {
153
186
  "eslint/max-params": [Severity, {
@@ -176,6 +209,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
176
209
  "perfectionist/sort-imports": ["error", {
177
210
  type: "line-length";
178
211
  order: "asc";
212
+ sortSideEffects: boolean;
179
213
  internalPattern: string[];
180
214
  groups: string[][];
181
215
  }];
@@ -186,4 +220,4 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
186
220
  };
187
221
  };
188
222
  //#endregion
189
- 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,7 +106,8 @@ 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
  }],
68
112
  "eslint/eqeqeq": [
69
113
  "error",
@@ -84,7 +128,8 @@ function basePreset(cycleSeverity) {
84
128
  * so linting never waits on a build.
85
129
  */
86
130
  function antiSlopRules(severity) {
87
- return Object.fromEntries(ANTI_SLOP_RULES.map((rule) => [`anti-slop/${rule}`, severity]));
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]));
88
133
  }
89
134
  function antiSlopPreset(severity) {
90
135
  return defineConfig({
@@ -92,7 +137,7 @@ function antiSlopPreset(severity) {
92
137
  name: "anti-slop",
93
138
  specifier: "@antelopejs/tooling-configs/oxc/anti-slop"
94
139
  }],
95
- rules: Object.fromEntries(ANTI_SLOP_RULES.map((rule) => [`anti-slop/${rule}`, severity]))
140
+ rules: antiSlopRules(severity)
96
141
  });
97
142
  }
98
143
  function complexityPreset(thresholds, severity) {
@@ -137,20 +182,17 @@ function importSortingPreset() {
137
182
  rules: { "perfectionist/sort-imports": ["error", {
138
183
  type: "line-length",
139
184
  order: "asc",
185
+ sortSideEffects: false,
140
186
  internalPattern: ["^@/.*", "^~/.*"],
141
- groups: [
142
- ["side-effect", "side-effect-style"],
143
- ["builtin", "external"],
144
- [
145
- "internal",
146
- "subpath",
147
- "parent",
148
- "sibling",
149
- "index",
150
- "style",
151
- "unknown"
152
- ]
153
- ]
187
+ groups: [["builtin", "external"], [
188
+ "internal",
189
+ "subpath",
190
+ "parent",
191
+ "sibling",
192
+ "index",
193
+ "style",
194
+ "unknown"
195
+ ]]
154
196
  }] }
155
197
  });
156
198
  }
@@ -193,4 +235,4 @@ function antelopePreset(options = {}) {
193
235
  });
194
236
  }
195
237
  //#endregion
196
- 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",
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",