@timmo001/oxlint-rules 0.3.0 → 0.3.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/dist/cli.js +247 -50
- package/dist/configs/recommended-effect.js +417 -220
- package/dist/configs/recommended.js +237 -40
- package/dist/upstream/anti-slop.js +230 -33
- package/package.json +5 -5
- package/vendor/anti-slop/src/index.ts +4 -0
- package/vendor/anti-slop/src/rules/no-array-filter-map.ts +28 -0
- package/vendor/anti-slop/src/rules/no-reduce-accumulator-copy.ts +109 -0
- package/vendor/anti-slop/src/shared/array-method.ts +94 -0
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,213 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { resolve as resolve2 } from "node:path";
|
|
5
|
+
|
|
6
|
+
// node_modules/oxlint/dist/index.js
|
|
7
|
+
function defineConfig(config) {
|
|
8
|
+
return config;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
// vendor/anti-slop/src/index.ts
|
|
4
12
|
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
5
13
|
|
|
6
|
-
// vendor/anti-slop/src/rules/no-
|
|
14
|
+
// vendor/anti-slop/src/rules/no-array-filter-map.ts
|
|
7
15
|
import { defineRule } from "@oxlint/plugins";
|
|
16
|
+
|
|
17
|
+
// vendor/anti-slop/src/shared/array-method.ts
|
|
18
|
+
function unwrapArrayExpression(node) {
|
|
19
|
+
while (node.type === "ParenthesizedExpression" || node.type === "ChainExpression" || node.type === "TSAsExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression" || node.type === "TSSatisfiesExpression") {
|
|
20
|
+
node = node.expression;
|
|
21
|
+
}
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
function resolveArrayBinding(sourceCode, node) {
|
|
25
|
+
node = unwrapArrayExpression(node);
|
|
26
|
+
if (node.type !== "Identifier")
|
|
27
|
+
return null;
|
|
28
|
+
let scope = sourceCode.getScope(node);
|
|
29
|
+
while (scope !== null) {
|
|
30
|
+
const variable = scope.set.get(node.name);
|
|
31
|
+
if (variable !== undefined)
|
|
32
|
+
return variable;
|
|
33
|
+
scope = scope.upper;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function arrayMethodTarget(node) {
|
|
38
|
+
node = unwrapArrayExpression(node);
|
|
39
|
+
if (node.type !== "MemberExpression")
|
|
40
|
+
return null;
|
|
41
|
+
const property = node.property;
|
|
42
|
+
if (!node.computed && property.type === "Identifier") {
|
|
43
|
+
return { name: property.name, object: node.object };
|
|
44
|
+
}
|
|
45
|
+
if (node.computed && property.type === "Literal" && typeof property.value === "string") {
|
|
46
|
+
return { name: property.value, object: node.object };
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
function isArrayAnnotation(type) {
|
|
51
|
+
if (type.type === "TSArrayType" || type.type === "TSTupleType")
|
|
52
|
+
return true;
|
|
53
|
+
if (type.type === "TSParenthesizedType")
|
|
54
|
+
return isArrayAnnotation(type.typeAnnotation);
|
|
55
|
+
if (type.type === "TSTypeOperator" && type.operator === "readonly") {
|
|
56
|
+
return isArrayAnnotation(type.typeAnnotation);
|
|
57
|
+
}
|
|
58
|
+
return type.type === "TSTypeReference" && type.typeName.type === "Identifier" && (type.typeName.name === "Array" || type.typeName.name === "ReadonlyArray");
|
|
59
|
+
}
|
|
60
|
+
function isKnownArrayExpression(sourceCode, node, visited = new Set) {
|
|
61
|
+
node = unwrapArrayExpression(node);
|
|
62
|
+
if (node.type === "ArrayExpression")
|
|
63
|
+
return true;
|
|
64
|
+
if (node.type === "CallExpression") {
|
|
65
|
+
const method = arrayMethodTarget(node.callee);
|
|
66
|
+
return method !== null && ["map", "filter", "flatMap", "slice", "concat", "toSorted", "toReversed", "toSpliced"].includes(method.name) && isKnownArrayExpression(sourceCode, method.object, visited);
|
|
67
|
+
}
|
|
68
|
+
if (node.type !== "Identifier")
|
|
69
|
+
return false;
|
|
70
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
71
|
+
if (variable === null || visited.has(variable))
|
|
72
|
+
return false;
|
|
73
|
+
visited.add(variable);
|
|
74
|
+
if (variable.references.some((reference) => reference.isWrite() && !reference.init))
|
|
75
|
+
return false;
|
|
76
|
+
for (const identifier of variable.identifiers) {
|
|
77
|
+
const annotation = identifier.typeAnnotation?.typeAnnotation;
|
|
78
|
+
if (annotation !== undefined)
|
|
79
|
+
return isArrayAnnotation(annotation);
|
|
80
|
+
}
|
|
81
|
+
for (const definition of variable.defs) {
|
|
82
|
+
if (definition.type === "Variable" && definition.node.type === "VariableDeclarator" && definition.node.id.type === "Identifier" && definition.node.init !== null && definition.node.parent.type === "VariableDeclaration" && definition.node.parent.kind === "const") {
|
|
83
|
+
return isKnownArrayExpression(sourceCode, definition.node.init, visited);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// vendor/anti-slop/src/rules/no-array-filter-map.ts
|
|
90
|
+
var noArrayFilterMapRule = defineRule({
|
|
91
|
+
meta: {
|
|
92
|
+
type: "suggestion",
|
|
93
|
+
docs: { description: "Disallow adjacent array filter/map passes in favor of lazy iterator helpers or a single transformation." },
|
|
94
|
+
messages: {
|
|
95
|
+
arrayFilterMap: "Avoid consecutive array `{{first}}` and `{{second}}` passes. Prefer `.values().{{first}}(...).{{second}}(...).toArray()` where iterator helpers are supported, or a single `flatMap`/mutating reducer. Preserve callback ordering, indexes, and filtering semantics."
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
createOnce(context) {
|
|
99
|
+
return {
|
|
100
|
+
CallExpression(node) {
|
|
101
|
+
const outer = arrayMethodTarget(node.callee);
|
|
102
|
+
if (outer === null || outer.name !== "map" && outer.name !== "filter")
|
|
103
|
+
return;
|
|
104
|
+
const innerCall = unwrapArrayExpression(outer.object);
|
|
105
|
+
if (innerCall.type !== "CallExpression")
|
|
106
|
+
return;
|
|
107
|
+
const inner = arrayMethodTarget(innerCall.callee);
|
|
108
|
+
if (inner === null || inner.name !== (outer.name === "map" ? "filter" : "map"))
|
|
109
|
+
return;
|
|
110
|
+
if (!isKnownArrayExpression(context.sourceCode, inner.object))
|
|
111
|
+
return;
|
|
112
|
+
context.report({ node, messageId: "arrayFilterMap", data: { first: inner.name, second: outer.name } });
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// vendor/anti-slop/src/rules/no-reduce-accumulator-copy.ts
|
|
119
|
+
import { defineRule as defineRule2 } from "@oxlint/plugins";
|
|
120
|
+
function enclosingReducer(node) {
|
|
121
|
+
let parent = node.parent;
|
|
122
|
+
while (parent !== null) {
|
|
123
|
+
if (parent.type === "FunctionDeclaration")
|
|
124
|
+
return null;
|
|
125
|
+
if (parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression") {
|
|
126
|
+
const callback = parent;
|
|
127
|
+
let owner = callback.parent;
|
|
128
|
+
while (owner !== null && unwrapArrayExpression(owner) === callback)
|
|
129
|
+
owner = owner.parent;
|
|
130
|
+
if (owner?.type !== "CallExpression")
|
|
131
|
+
return null;
|
|
132
|
+
const method = arrayMethodTarget(owner.callee);
|
|
133
|
+
const firstArgument = owner.arguments[0];
|
|
134
|
+
if (method === null || method.name !== "reduce" && method.name !== "reduceRight" || owner.arguments.length > 2 || firstArgument === undefined || unwrapArrayExpression(firstArgument) !== callback)
|
|
135
|
+
return null;
|
|
136
|
+
const firstParameter = callback.params[0];
|
|
137
|
+
const accumulator = firstParameter?.type === "AssignmentPattern" ? firstParameter.left : firstParameter;
|
|
138
|
+
if (accumulator?.type !== "Identifier")
|
|
139
|
+
return null;
|
|
140
|
+
return { callback, accumulator, initialValue: owner.arguments[1] };
|
|
141
|
+
}
|
|
142
|
+
parent = parent.parent;
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
function referencesAccumulator(sourceCode, node, accumulator, visited = new Set) {
|
|
147
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
148
|
+
if (variable === null || visited.has(variable))
|
|
149
|
+
return false;
|
|
150
|
+
if (variable === accumulator)
|
|
151
|
+
return true;
|
|
152
|
+
visited.add(variable);
|
|
153
|
+
if (variable.references.some((reference) => reference.isWrite() && !reference.init))
|
|
154
|
+
return false;
|
|
155
|
+
for (const definition of variable.defs) {
|
|
156
|
+
if (definition.type === "Variable" && definition.node.type === "VariableDeclarator" && definition.node.id.type === "Identifier" && definition.node.init !== null && definition.node.parent.type === "VariableDeclaration" && definition.node.parent.kind === "const") {
|
|
157
|
+
return referencesAccumulator(sourceCode, definition.node.init, accumulator, visited);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
function isGlobalCopyOwner(sourceCode, node, name) {
|
|
163
|
+
node = unwrapArrayExpression(node);
|
|
164
|
+
if (node.type !== "Identifier" || node.name !== name)
|
|
165
|
+
return false;
|
|
166
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
167
|
+
return variable === null || variable.defs.length === 0;
|
|
168
|
+
}
|
|
169
|
+
var noReduceAccumulatorCopyRule = defineRule2({
|
|
170
|
+
meta: {
|
|
171
|
+
type: "problem",
|
|
172
|
+
docs: { description: "Disallow copying growing reducer accumulators with Object.assign, Array.from, or array copy methods." },
|
|
173
|
+
messages: {
|
|
174
|
+
accumulatorCopy: "Do not copy the reducer accumulator on every iteration; growing copies can cause quadratic work. Mutate a fresh, locally owned accumulator and return it, or use an iterator pipeline/flatMap."
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
createOnce(context) {
|
|
178
|
+
return {
|
|
179
|
+
CallExpression(node) {
|
|
180
|
+
const method = arrayMethodTarget(node.callee);
|
|
181
|
+
if (method === null)
|
|
182
|
+
return;
|
|
183
|
+
const reducer = enclosingReducer(node);
|
|
184
|
+
if (reducer === null)
|
|
185
|
+
return;
|
|
186
|
+
const accumulator = context.sourceCode.getDeclaredVariables(reducer.callback).find((variable) => variable.identifiers.some((identifier) => identifier.start === reducer.accumulator.start));
|
|
187
|
+
if (accumulator === undefined)
|
|
188
|
+
return;
|
|
189
|
+
const isAccumulator = (expression) => referencesAccumulator(context.sourceCode, expression, accumulator);
|
|
190
|
+
let copiesAccumulator = false;
|
|
191
|
+
if (method.name === "assign" && isGlobalCopyOwner(context.sourceCode, method.object, "Object")) {
|
|
192
|
+
const target = node.arguments[0];
|
|
193
|
+
copiesAccumulator = target !== undefined && unwrapArrayExpression(target).type === "ObjectExpression" && node.arguments.slice(1).some(isAccumulator);
|
|
194
|
+
} else if (method.name === "from" && isGlobalCopyOwner(context.sourceCode, method.object, "Array")) {
|
|
195
|
+
const source = node.arguments[0];
|
|
196
|
+
copiesAccumulator = source !== undefined && isAccumulator(source);
|
|
197
|
+
} else if (["concat", "slice", "toSpliced", "toSorted", "toReversed", "with"].includes(method.name)) {
|
|
198
|
+
const initialValue = reducer.initialValue;
|
|
199
|
+
const arrayAccumulator = initialValue !== undefined && isKnownArrayExpression(context.sourceCode, initialValue);
|
|
200
|
+
copiesAccumulator = arrayAccumulator && isAccumulator(method.object);
|
|
201
|
+
}
|
|
202
|
+
if (copiesAccumulator)
|
|
203
|
+
context.report({ node, messageId: "accumulatorCopy" });
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// vendor/anti-slop/src/rules/no-chained-type-assertions.ts
|
|
210
|
+
import { defineRule as defineRule3 } from "@oxlint/plugins";
|
|
8
211
|
function isTypeAssertionExpression(node) {
|
|
9
212
|
return node.type === "TSAsExpression" || node.type === "TSTypeAssertion";
|
|
10
213
|
}
|
|
@@ -39,7 +242,7 @@ function isForbiddenAssertionChain(node) {
|
|
|
39
242
|
}
|
|
40
243
|
return assertionCount > 1 && hasNonConstAssertion;
|
|
41
244
|
}
|
|
42
|
-
var noChainedTypeAssertionsRule =
|
|
245
|
+
var noChainedTypeAssertionsRule = defineRule3({
|
|
43
246
|
meta: {
|
|
44
247
|
type: "problem",
|
|
45
248
|
docs: {
|
|
@@ -63,7 +266,7 @@ var noChainedTypeAssertionsRule = defineRule({
|
|
|
63
266
|
});
|
|
64
267
|
|
|
65
268
|
// vendor/anti-slop/src/rules/no-conditional-empty-object-spread.ts
|
|
66
|
-
import { defineRule as
|
|
269
|
+
import { defineRule as defineRule4 } from "@oxlint/plugins";
|
|
67
270
|
function unwrapParentheses(node) {
|
|
68
271
|
let current = node;
|
|
69
272
|
while (current.type === "ParenthesizedExpression") {
|
|
@@ -78,7 +281,7 @@ function isConditionalEmptyObjectSpread(node) {
|
|
|
78
281
|
const conditional = unwrapParentheses(node);
|
|
79
282
|
return conditional.type === "ConditionalExpression" && (isEmptyObjectExpression(conditional.consequent) || isEmptyObjectExpression(conditional.alternate));
|
|
80
283
|
}
|
|
81
|
-
var noConditionalEmptyObjectSpreadRule =
|
|
284
|
+
var noConditionalEmptyObjectSpreadRule = defineRule4({
|
|
82
285
|
meta: {
|
|
83
286
|
type: "suggestion",
|
|
84
287
|
docs: {
|
|
@@ -102,7 +305,7 @@ var noConditionalEmptyObjectSpreadRule = defineRule2({
|
|
|
102
305
|
});
|
|
103
306
|
|
|
104
307
|
// vendor/anti-slop/src/rules/no-known-value-widening.ts
|
|
105
|
-
import { defineRule as
|
|
308
|
+
import { defineRule as defineRule5 } from "@oxlint/plugins";
|
|
106
309
|
|
|
107
310
|
// vendor/anti-slop/src/shared/lexical-type-parameters.ts
|
|
108
311
|
function isNode(value) {
|
|
@@ -505,9 +708,9 @@ function classifyWideningTarget(type, environment) {
|
|
|
505
708
|
if (alias === null)
|
|
506
709
|
return null;
|
|
507
710
|
if ((alias.typeParameters?.params.length ?? 0) > 0) {
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
-
return
|
|
711
|
+
const substitutions = aliasSubstitution(alias, unwrapped, new Map);
|
|
712
|
+
const resolved = substitutions === null ? null : classifyAliasBroadTarget(alias.typeAnnotation, environment, substitutions, new Set([name]));
|
|
713
|
+
return resolved?.kind === "open dictionary" ? { kind: "generic container" } : null;
|
|
511
714
|
}
|
|
512
715
|
const substitutions = aliasSubstitution(alias, unwrapped, new Map);
|
|
513
716
|
if (substitutions === null)
|
|
@@ -801,7 +1004,7 @@ function isDictionaryAccumulatorTarget(destination) {
|
|
|
801
1004
|
function hasParentAssertion(node) {
|
|
802
1005
|
return node.parent?.type === "TSAsExpression" || node.parent?.type === "TSTypeAssertion";
|
|
803
1006
|
}
|
|
804
|
-
var noKnownValueWideningRule =
|
|
1007
|
+
var noKnownValueWideningRule = defineRule5({
|
|
805
1008
|
meta: {
|
|
806
1009
|
type: "problem",
|
|
807
1010
|
docs: {
|
|
@@ -914,7 +1117,7 @@ var noKnownValueWideningRule = defineRule3({
|
|
|
914
1117
|
});
|
|
915
1118
|
|
|
916
1119
|
// vendor/anti-slop/src/rules/no-module-mocking.ts
|
|
917
|
-
import { defineRule as
|
|
1120
|
+
import { defineRule as defineRule6 } from "@oxlint/plugins";
|
|
918
1121
|
var moduleMockMethods = new Set(["doMock", "mock", "unstable_mockModule"]);
|
|
919
1122
|
function resolveVariable2(sourceCode, identifier) {
|
|
920
1123
|
let scope = sourceCode.getScope(identifier);
|
|
@@ -959,7 +1162,7 @@ function moduleMockCall(sourceCode, callee) {
|
|
|
959
1162
|
const method = callee.computed ? property.type === "Literal" && (property.value === "doMock" || property.value === "mock" || property.value === "unstable_mockModule") ? property.value : null : property.type === "Identifier" ? property.name : null;
|
|
960
1163
|
return method !== null && moduleMockMethods.has(method);
|
|
961
1164
|
}
|
|
962
|
-
var noModuleMockingRule =
|
|
1165
|
+
var noModuleMockingRule = defineRule6({
|
|
963
1166
|
meta: {
|
|
964
1167
|
type: "problem",
|
|
965
1168
|
docs: {
|
|
@@ -983,8 +1186,8 @@ var noModuleMockingRule = defineRule4({
|
|
|
983
1186
|
});
|
|
984
1187
|
|
|
985
1188
|
// vendor/anti-slop/src/rules/no-object-parameters.ts
|
|
986
|
-
import { defineRule as
|
|
987
|
-
var noObjectParametersRule =
|
|
1189
|
+
import { defineRule as defineRule7 } from "@oxlint/plugins";
|
|
1190
|
+
var noObjectParametersRule = defineRule7({
|
|
988
1191
|
meta: {
|
|
989
1192
|
type: "problem",
|
|
990
1193
|
docs: {
|
|
@@ -1037,7 +1240,7 @@ var noObjectParametersRule = defineRule5({
|
|
|
1037
1240
|
});
|
|
1038
1241
|
|
|
1039
1242
|
// vendor/anti-slop/src/rules/no-reflect-apply.ts
|
|
1040
|
-
import { defineRule as
|
|
1243
|
+
import { defineRule as defineRule8 } from "@oxlint/plugins";
|
|
1041
1244
|
|
|
1042
1245
|
// vendor/anti-slop/src/shared/reflect-method.ts
|
|
1043
1246
|
function resolveVariable3(sourceCode, identifier) {
|
|
@@ -1068,7 +1271,7 @@ function isGlobalReflectMethodCall(sourceCode, callee, methodName) {
|
|
|
1068
1271
|
}
|
|
1069
1272
|
|
|
1070
1273
|
// vendor/anti-slop/src/rules/no-reflect-apply.ts
|
|
1071
|
-
var noReflectApplyRule =
|
|
1274
|
+
var noReflectApplyRule = defineRule8({
|
|
1072
1275
|
meta: {
|
|
1073
1276
|
type: "problem",
|
|
1074
1277
|
docs: {
|
|
@@ -1092,8 +1295,8 @@ var noReflectApplyRule = defineRule6({
|
|
|
1092
1295
|
});
|
|
1093
1296
|
|
|
1094
1297
|
// vendor/anti-slop/src/rules/no-reflect-get.ts
|
|
1095
|
-
import { defineRule as
|
|
1096
|
-
var noReflectGetRule =
|
|
1298
|
+
import { defineRule as defineRule9 } from "@oxlint/plugins";
|
|
1299
|
+
var noReflectGetRule = defineRule9({
|
|
1097
1300
|
meta: {
|
|
1098
1301
|
type: "problem",
|
|
1099
1302
|
docs: {
|
|
@@ -1117,7 +1320,7 @@ var noReflectGetRule = defineRule7({
|
|
|
1117
1320
|
});
|
|
1118
1321
|
|
|
1119
1322
|
// vendor/anti-slop/src/rules/no-runtime-typeof.ts
|
|
1120
|
-
import { defineRule as
|
|
1323
|
+
import { defineRule as defineRule10 } from "@oxlint/plugins";
|
|
1121
1324
|
function isRuntimeFunction(node) {
|
|
1122
1325
|
return node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression";
|
|
1123
1326
|
}
|
|
@@ -1140,7 +1343,7 @@ function isExistenceProbe(node) {
|
|
|
1140
1343
|
const other = parent.left === node ? parent.right : parent.left;
|
|
1141
1344
|
return other.type === "Literal" && other.value === "undefined";
|
|
1142
1345
|
}
|
|
1143
|
-
var noRuntimeTypeofRule =
|
|
1346
|
+
var noRuntimeTypeofRule = defineRule10({
|
|
1144
1347
|
meta: {
|
|
1145
1348
|
type: "problem",
|
|
1146
1349
|
docs: {
|
|
@@ -1174,7 +1377,7 @@ var noRuntimeTypeofRule = defineRule8({
|
|
|
1174
1377
|
});
|
|
1175
1378
|
|
|
1176
1379
|
// vendor/anti-slop/src/rules/no-shape-in-symbol-names.ts
|
|
1177
|
-
import { defineRule as
|
|
1380
|
+
import { defineRule as defineRule11 } from "@oxlint/plugins";
|
|
1178
1381
|
var FORBIDDEN_SYMBOL_NAME = "shape";
|
|
1179
1382
|
function containsForbiddenSymbolName(name) {
|
|
1180
1383
|
return name.toLowerCase().includes(FORBIDDEN_SYMBOL_NAME);
|
|
@@ -1185,7 +1388,7 @@ function isBorrowedMemberName(node) {
|
|
|
1185
1388
|
return false;
|
|
1186
1389
|
return parent.property === node && parent.computed === false;
|
|
1187
1390
|
}
|
|
1188
|
-
var noForbiddenTermInSymbolNamesRule =
|
|
1391
|
+
var noForbiddenTermInSymbolNamesRule = defineRule11({
|
|
1189
1392
|
meta: {
|
|
1190
1393
|
type: "problem",
|
|
1191
1394
|
docs: {
|
|
@@ -1214,12 +1417,12 @@ var noForbiddenTermInSymbolNamesRule = defineRule9({
|
|
|
1214
1417
|
});
|
|
1215
1418
|
|
|
1216
1419
|
// vendor/anti-slop/src/rules/no-unknown-parameters.ts
|
|
1217
|
-
import { defineRule as
|
|
1420
|
+
import { defineRule as defineRule12 } from "@oxlint/plugins";
|
|
1218
1421
|
function isTypePredicateSubject(owner, parameterName) {
|
|
1219
1422
|
const predicate = owner.returnType?.typeAnnotation;
|
|
1220
1423
|
return predicate?.type === "TSTypePredicate" && predicate.parameterName.type === "Identifier" && predicate.parameterName.name === parameterName;
|
|
1221
1424
|
}
|
|
1222
|
-
var noUnknownParametersRule =
|
|
1425
|
+
var noUnknownParametersRule = defineRule12({
|
|
1223
1426
|
meta: {
|
|
1224
1427
|
type: "problem",
|
|
1225
1428
|
docs: {
|
|
@@ -1263,8 +1466,8 @@ var noUnknownParametersRule = defineRule10({
|
|
|
1263
1466
|
});
|
|
1264
1467
|
|
|
1265
1468
|
// vendor/anti-slop/src/rules/no-unknown-returns.ts
|
|
1266
|
-
import { defineRule as
|
|
1267
|
-
var noUnknownReturnsRule =
|
|
1469
|
+
import { defineRule as defineRule13 } from "@oxlint/plugins";
|
|
1470
|
+
var noUnknownReturnsRule = defineRule13({
|
|
1268
1471
|
meta: {
|
|
1269
1472
|
type: "problem",
|
|
1270
1473
|
docs: {
|
|
@@ -1317,8 +1520,8 @@ var noUnknownReturnsRule = defineRule11({
|
|
|
1317
1520
|
});
|
|
1318
1521
|
|
|
1319
1522
|
// vendor/anti-slop/src/rules/no-unknown-type-aliases.ts
|
|
1320
|
-
import { defineRule as
|
|
1321
|
-
var noUnknownTypeAliasesRule =
|
|
1523
|
+
import { defineRule as defineRule14 } from "@oxlint/plugins";
|
|
1524
|
+
var noUnknownTypeAliasesRule = defineRule14({
|
|
1322
1525
|
meta: {
|
|
1323
1526
|
type: "problem",
|
|
1324
1527
|
docs: {
|
|
@@ -1356,7 +1559,7 @@ var noUnknownTypeAliasesRule = defineRule12({
|
|
|
1356
1559
|
});
|
|
1357
1560
|
|
|
1358
1561
|
// vendor/anti-slop/src/rules/no-unsafe-dictionary-type.ts
|
|
1359
|
-
import { defineRule as
|
|
1562
|
+
import { defineRule as defineRule15 } from "@oxlint/plugins";
|
|
1360
1563
|
var typeNodeKinds = new Set([
|
|
1361
1564
|
"JSDocNonNullableType",
|
|
1362
1565
|
"JSDocNullableType",
|
|
@@ -1443,7 +1646,7 @@ function shouldReportType(node, environment) {
|
|
|
1443
1646
|
}
|
|
1444
1647
|
return true;
|
|
1445
1648
|
}
|
|
1446
|
-
var noUnsafeDictionaryTypeRule =
|
|
1649
|
+
var noUnsafeDictionaryTypeRule = defineRule15({
|
|
1447
1650
|
meta: {
|
|
1448
1651
|
type: "problem",
|
|
1449
1652
|
docs: {
|
|
@@ -1485,7 +1688,7 @@ var noUnsafeDictionaryTypeRule = defineRule13({
|
|
|
1485
1688
|
});
|
|
1486
1689
|
|
|
1487
1690
|
// vendor/anti-slop/src/rules/no-widen-then-assert.ts
|
|
1488
|
-
import { defineRule as
|
|
1691
|
+
import { defineRule as defineRule16 } from "@oxlint/plugins";
|
|
1489
1692
|
var functionBoundaryTypes = new Set([
|
|
1490
1693
|
"ArrowFunctionExpression",
|
|
1491
1694
|
"FunctionDeclaration",
|
|
@@ -1681,7 +1884,7 @@ function assertionIsNarrower(sourceText, broadKind, evidence, assertedType) {
|
|
|
1681
1884
|
return isDefinitelyObjectType(assertedType);
|
|
1682
1885
|
return isDefinitelyNarrowerRecordType(assertedType);
|
|
1683
1886
|
}
|
|
1684
|
-
var noWidenThenAssertRule =
|
|
1887
|
+
var noWidenThenAssertRule = defineRule16({
|
|
1685
1888
|
meta: {
|
|
1686
1889
|
type: "problem",
|
|
1687
1890
|
docs: {
|
|
@@ -1721,7 +1924,7 @@ var noWidenThenAssertRule = defineRule14({
|
|
|
1721
1924
|
});
|
|
1722
1925
|
|
|
1723
1926
|
// vendor/anti-slop/src/rules/require-safety-comment-for-type-assertion.ts
|
|
1724
|
-
import { defineRule as
|
|
1927
|
+
import { defineRule as defineRule17 } from "@oxlint/plugins";
|
|
1725
1928
|
var DEFAULT_SAFETY_MARKERS = ["SAFETY"];
|
|
1726
1929
|
var commentOwnerKinds = new Set([
|
|
1727
1930
|
"ExpressionStatement",
|
|
@@ -1764,7 +1967,7 @@ function hasSafetyComment(sourceCode, node, pattern) {
|
|
|
1764
1967
|
current = current.parent;
|
|
1765
1968
|
}
|
|
1766
1969
|
}
|
|
1767
|
-
var requireSafetyCommentForTypeAssertionRule =
|
|
1970
|
+
var requireSafetyCommentForTypeAssertionRule = defineRule17({
|
|
1768
1971
|
meta: {
|
|
1769
1972
|
type: "problem",
|
|
1770
1973
|
docs: {
|
|
@@ -1817,6 +2020,8 @@ var requireSafetyCommentForTypeAssertionRule = defineRule15({
|
|
|
1817
2020
|
var antiSlopPlugin = eslintCompatPlugin({
|
|
1818
2021
|
meta: { name: "anti-slop" },
|
|
1819
2022
|
rules: {
|
|
2023
|
+
"no-array-filter-map": noArrayFilterMapRule,
|
|
2024
|
+
"no-reduce-accumulator-copy": noReduceAccumulatorCopyRule,
|
|
1820
2025
|
"no-chained-type-assertions": noChainedTypeAssertionsRule,
|
|
1821
2026
|
"no-conditional-empty-object-spread": noConditionalEmptyObjectSpreadRule,
|
|
1822
2027
|
"no-known-value-widening": noKnownValueWideningRule,
|
|
@@ -1839,7 +2044,7 @@ var src_default = antiSlopPlugin;
|
|
|
1839
2044
|
import { eslintCompatPlugin as eslintCompatPlugin2 } from "@oxlint/plugins";
|
|
1840
2045
|
|
|
1841
2046
|
// src/generic/rules/prefer-event-parameter-type.ts
|
|
1842
|
-
import { defineRule as
|
|
2047
|
+
import { defineRule as defineRule18 } from "@oxlint/plugins";
|
|
1843
2048
|
function nearestEnclosingFunction(node) {
|
|
1844
2049
|
let current = node.parent;
|
|
1845
2050
|
while (current) {
|
|
@@ -1866,7 +2071,7 @@ function assertedEventParameter(node) {
|
|
|
1866
2071
|
property
|
|
1867
2072
|
};
|
|
1868
2073
|
}
|
|
1869
|
-
var preferEventParameterTypeRule =
|
|
2074
|
+
var preferEventParameterTypeRule = defineRule18({
|
|
1870
2075
|
meta: {
|
|
1871
2076
|
type: "suggestion",
|
|
1872
2077
|
docs: {
|
|
@@ -1903,11 +2108,6 @@ var timmoPlugin = eslintCompatPlugin2({
|
|
|
1903
2108
|
});
|
|
1904
2109
|
var generic_default = timmoPlugin;
|
|
1905
2110
|
|
|
1906
|
-
// node_modules/oxlint/dist/index.js
|
|
1907
|
-
function defineConfig(config) {
|
|
1908
|
-
return config;
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
2111
|
// src/configs/enable-plugin-rules.ts
|
|
1912
2112
|
function enablePluginRules(namespace, plugin) {
|
|
1913
2113
|
return Object.fromEntries(Object.keys(plugin.rules).sort().map((rule) => [`${namespace}/${rule}`, "error"]));
|
|
@@ -1933,7 +2133,7 @@ var recommended_default = recommended;
|
|
|
1933
2133
|
import { eslintCompatPlugin as eslintCompatPlugin3 } from "@oxlint/plugins";
|
|
1934
2134
|
|
|
1935
2135
|
// src/effect/rules/no-try-catch-in-effect-generators.ts
|
|
1936
|
-
import { defineRule as
|
|
2136
|
+
import { defineRule as defineRule19 } from "@oxlint/plugins";
|
|
1937
2137
|
function resolveVariable4(sourceCode, identifier) {
|
|
1938
2138
|
let scope = sourceCode.getScope(identifier);
|
|
1939
2139
|
while (scope) {
|
|
@@ -1999,7 +2199,7 @@ function isRecognisedEffectGenerator(sourceCode, owner) {
|
|
|
1999
2199
|
const factoryCall = parent.callee;
|
|
2000
2200
|
return factoryCall.type === "CallExpression" && isEffectMethod(sourceCode, factoryCall.callee, "fn");
|
|
2001
2201
|
}
|
|
2002
|
-
var noTryCatchInEffectGeneratorsRule =
|
|
2202
|
+
var noTryCatchInEffectGeneratorsRule = defineRule19({
|
|
2003
2203
|
meta: {
|
|
2004
2204
|
type: "problem",
|
|
2005
2205
|
docs: {
|
|
@@ -2037,7 +2237,7 @@ var effect_default = timmoEffectPlugin;
|
|
|
2037
2237
|
import { eslintCompatPlugin as eslintCompatPlugin4 } from "@oxlint/plugins";
|
|
2038
2238
|
|
|
2039
2239
|
// vendor/anti-slop/src/effect/rules/no-service-constructor-imports.ts
|
|
2040
|
-
import { defineRule as
|
|
2240
|
+
import { defineRule as defineRule20 } from "@oxlint/plugins";
|
|
2041
2241
|
var SERVICE_CONSTRUCTOR_NAME = /^make[A-Z]/u;
|
|
2042
2242
|
var TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
|
|
2043
2243
|
function isProjectLocalImport(source) {
|
|
@@ -2048,7 +2248,7 @@ function getImportedName(specifier) {
|
|
|
2048
2248
|
return specifier.imported.name;
|
|
2049
2249
|
return specifier.imported.value;
|
|
2050
2250
|
}
|
|
2051
|
-
var noServiceConstructorImportsRule =
|
|
2251
|
+
var noServiceConstructorImportsRule = defineRule20({
|
|
2052
2252
|
meta: {
|
|
2053
2253
|
type: "problem",
|
|
2054
2254
|
docs: {
|
|
@@ -2067,13 +2267,13 @@ var noServiceConstructorImportsRule = defineRule18({
|
|
|
2067
2267
|
for (const specifier of node.specifiers) {
|
|
2068
2268
|
if (specifier.type !== "ImportSpecifier")
|
|
2069
2269
|
continue;
|
|
2070
|
-
const
|
|
2071
|
-
if (!SERVICE_CONSTRUCTOR_NAME.test(
|
|
2270
|
+
const importedName = getImportedName(specifier);
|
|
2271
|
+
if (!SERVICE_CONSTRUCTOR_NAME.test(importedName))
|
|
2072
2272
|
continue;
|
|
2073
2273
|
context.report({
|
|
2074
2274
|
node: specifier,
|
|
2075
2275
|
messageId: "serviceConstructorImport",
|
|
2076
|
-
data: { name:
|
|
2276
|
+
data: { name: importedName }
|
|
2077
2277
|
});
|
|
2078
2278
|
}
|
|
2079
2279
|
}
|
|
@@ -2106,9 +2306,6 @@ var recommendedEffect = defineConfig({
|
|
|
2106
2306
|
});
|
|
2107
2307
|
var recommended_effect_default = recommendedEffect;
|
|
2108
2308
|
|
|
2109
|
-
// src/cli.ts
|
|
2110
|
-
import { resolve as resolve2 } from "node:path";
|
|
2111
|
-
|
|
2112
2309
|
// src/install/copy.ts
|
|
2113
2310
|
import { cp, mkdir, readdir, rm } from "node:fs/promises";
|
|
2114
2311
|
import { dirname, join, relative, resolve, sep } from "node:path";
|