@timmo001/oxlint-rules 0.2.1 → 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/README.md +2 -2
- package/dist/cli.js +344 -147
- package/dist/configs/{effect.js → recommended-effect.js} +246 -49
- package/dist/configs/recommended.js +237 -40
- package/dist/upstream/anti-slop.js +230 -33
- package/package.json +6 -6
- package/skills/install-timmo-oxlint-rules/SKILL.md +3 -2
- 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
|
@@ -1,8 +1,208 @@
|
|
|
1
|
+
// node_modules/oxlint/dist/index.js
|
|
2
|
+
function defineConfig(config) {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// vendor/anti-slop/src/index.ts
|
|
2
7
|
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
3
8
|
|
|
4
|
-
// vendor/anti-slop/src/rules/no-
|
|
9
|
+
// vendor/anti-slop/src/rules/no-array-filter-map.ts
|
|
5
10
|
import { defineRule } from "@oxlint/plugins";
|
|
11
|
+
|
|
12
|
+
// vendor/anti-slop/src/shared/array-method.ts
|
|
13
|
+
function unwrapArrayExpression(node) {
|
|
14
|
+
while (node.type === "ParenthesizedExpression" || node.type === "ChainExpression" || node.type === "TSAsExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression" || node.type === "TSSatisfiesExpression") {
|
|
15
|
+
node = node.expression;
|
|
16
|
+
}
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
function resolveArrayBinding(sourceCode, node) {
|
|
20
|
+
node = unwrapArrayExpression(node);
|
|
21
|
+
if (node.type !== "Identifier")
|
|
22
|
+
return null;
|
|
23
|
+
let scope = sourceCode.getScope(node);
|
|
24
|
+
while (scope !== null) {
|
|
25
|
+
const variable = scope.set.get(node.name);
|
|
26
|
+
if (variable !== undefined)
|
|
27
|
+
return variable;
|
|
28
|
+
scope = scope.upper;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function arrayMethodTarget(node) {
|
|
33
|
+
node = unwrapArrayExpression(node);
|
|
34
|
+
if (node.type !== "MemberExpression")
|
|
35
|
+
return null;
|
|
36
|
+
const property = node.property;
|
|
37
|
+
if (!node.computed && property.type === "Identifier") {
|
|
38
|
+
return { name: property.name, object: node.object };
|
|
39
|
+
}
|
|
40
|
+
if (node.computed && property.type === "Literal" && typeof property.value === "string") {
|
|
41
|
+
return { name: property.value, object: node.object };
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function isArrayAnnotation(type) {
|
|
46
|
+
if (type.type === "TSArrayType" || type.type === "TSTupleType")
|
|
47
|
+
return true;
|
|
48
|
+
if (type.type === "TSParenthesizedType")
|
|
49
|
+
return isArrayAnnotation(type.typeAnnotation);
|
|
50
|
+
if (type.type === "TSTypeOperator" && type.operator === "readonly") {
|
|
51
|
+
return isArrayAnnotation(type.typeAnnotation);
|
|
52
|
+
}
|
|
53
|
+
return type.type === "TSTypeReference" && type.typeName.type === "Identifier" && (type.typeName.name === "Array" || type.typeName.name === "ReadonlyArray");
|
|
54
|
+
}
|
|
55
|
+
function isKnownArrayExpression(sourceCode, node, visited = new Set) {
|
|
56
|
+
node = unwrapArrayExpression(node);
|
|
57
|
+
if (node.type === "ArrayExpression")
|
|
58
|
+
return true;
|
|
59
|
+
if (node.type === "CallExpression") {
|
|
60
|
+
const method = arrayMethodTarget(node.callee);
|
|
61
|
+
return method !== null && ["map", "filter", "flatMap", "slice", "concat", "toSorted", "toReversed", "toSpliced"].includes(method.name) && isKnownArrayExpression(sourceCode, method.object, visited);
|
|
62
|
+
}
|
|
63
|
+
if (node.type !== "Identifier")
|
|
64
|
+
return false;
|
|
65
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
66
|
+
if (variable === null || visited.has(variable))
|
|
67
|
+
return false;
|
|
68
|
+
visited.add(variable);
|
|
69
|
+
if (variable.references.some((reference) => reference.isWrite() && !reference.init))
|
|
70
|
+
return false;
|
|
71
|
+
for (const identifier of variable.identifiers) {
|
|
72
|
+
const annotation = identifier.typeAnnotation?.typeAnnotation;
|
|
73
|
+
if (annotation !== undefined)
|
|
74
|
+
return isArrayAnnotation(annotation);
|
|
75
|
+
}
|
|
76
|
+
for (const definition of variable.defs) {
|
|
77
|
+
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") {
|
|
78
|
+
return isKnownArrayExpression(sourceCode, definition.node.init, visited);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// vendor/anti-slop/src/rules/no-array-filter-map.ts
|
|
85
|
+
var noArrayFilterMapRule = defineRule({
|
|
86
|
+
meta: {
|
|
87
|
+
type: "suggestion",
|
|
88
|
+
docs: { description: "Disallow adjacent array filter/map passes in favor of lazy iterator helpers or a single transformation." },
|
|
89
|
+
messages: {
|
|
90
|
+
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."
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
createOnce(context) {
|
|
94
|
+
return {
|
|
95
|
+
CallExpression(node) {
|
|
96
|
+
const outer = arrayMethodTarget(node.callee);
|
|
97
|
+
if (outer === null || outer.name !== "map" && outer.name !== "filter")
|
|
98
|
+
return;
|
|
99
|
+
const innerCall = unwrapArrayExpression(outer.object);
|
|
100
|
+
if (innerCall.type !== "CallExpression")
|
|
101
|
+
return;
|
|
102
|
+
const inner = arrayMethodTarget(innerCall.callee);
|
|
103
|
+
if (inner === null || inner.name !== (outer.name === "map" ? "filter" : "map"))
|
|
104
|
+
return;
|
|
105
|
+
if (!isKnownArrayExpression(context.sourceCode, inner.object))
|
|
106
|
+
return;
|
|
107
|
+
context.report({ node, messageId: "arrayFilterMap", data: { first: inner.name, second: outer.name } });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// vendor/anti-slop/src/rules/no-reduce-accumulator-copy.ts
|
|
114
|
+
import { defineRule as defineRule2 } from "@oxlint/plugins";
|
|
115
|
+
function enclosingReducer(node) {
|
|
116
|
+
let parent = node.parent;
|
|
117
|
+
while (parent !== null) {
|
|
118
|
+
if (parent.type === "FunctionDeclaration")
|
|
119
|
+
return null;
|
|
120
|
+
if (parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression") {
|
|
121
|
+
const callback = parent;
|
|
122
|
+
let owner = callback.parent;
|
|
123
|
+
while (owner !== null && unwrapArrayExpression(owner) === callback)
|
|
124
|
+
owner = owner.parent;
|
|
125
|
+
if (owner?.type !== "CallExpression")
|
|
126
|
+
return null;
|
|
127
|
+
const method = arrayMethodTarget(owner.callee);
|
|
128
|
+
const firstArgument = owner.arguments[0];
|
|
129
|
+
if (method === null || method.name !== "reduce" && method.name !== "reduceRight" || owner.arguments.length > 2 || firstArgument === undefined || unwrapArrayExpression(firstArgument) !== callback)
|
|
130
|
+
return null;
|
|
131
|
+
const firstParameter = callback.params[0];
|
|
132
|
+
const accumulator = firstParameter?.type === "AssignmentPattern" ? firstParameter.left : firstParameter;
|
|
133
|
+
if (accumulator?.type !== "Identifier")
|
|
134
|
+
return null;
|
|
135
|
+
return { callback, accumulator, initialValue: owner.arguments[1] };
|
|
136
|
+
}
|
|
137
|
+
parent = parent.parent;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function referencesAccumulator(sourceCode, node, accumulator, visited = new Set) {
|
|
142
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
143
|
+
if (variable === null || visited.has(variable))
|
|
144
|
+
return false;
|
|
145
|
+
if (variable === accumulator)
|
|
146
|
+
return true;
|
|
147
|
+
visited.add(variable);
|
|
148
|
+
if (variable.references.some((reference) => reference.isWrite() && !reference.init))
|
|
149
|
+
return false;
|
|
150
|
+
for (const definition of variable.defs) {
|
|
151
|
+
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") {
|
|
152
|
+
return referencesAccumulator(sourceCode, definition.node.init, accumulator, visited);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
function isGlobalCopyOwner(sourceCode, node, name) {
|
|
158
|
+
node = unwrapArrayExpression(node);
|
|
159
|
+
if (node.type !== "Identifier" || node.name !== name)
|
|
160
|
+
return false;
|
|
161
|
+
const variable = resolveArrayBinding(sourceCode, node);
|
|
162
|
+
return variable === null || variable.defs.length === 0;
|
|
163
|
+
}
|
|
164
|
+
var noReduceAccumulatorCopyRule = defineRule2({
|
|
165
|
+
meta: {
|
|
166
|
+
type: "problem",
|
|
167
|
+
docs: { description: "Disallow copying growing reducer accumulators with Object.assign, Array.from, or array copy methods." },
|
|
168
|
+
messages: {
|
|
169
|
+
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."
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
createOnce(context) {
|
|
173
|
+
return {
|
|
174
|
+
CallExpression(node) {
|
|
175
|
+
const method = arrayMethodTarget(node.callee);
|
|
176
|
+
if (method === null)
|
|
177
|
+
return;
|
|
178
|
+
const reducer = enclosingReducer(node);
|
|
179
|
+
if (reducer === null)
|
|
180
|
+
return;
|
|
181
|
+
const accumulator = context.sourceCode.getDeclaredVariables(reducer.callback).find((variable) => variable.identifiers.some((identifier) => identifier.start === reducer.accumulator.start));
|
|
182
|
+
if (accumulator === undefined)
|
|
183
|
+
return;
|
|
184
|
+
const isAccumulator = (expression) => referencesAccumulator(context.sourceCode, expression, accumulator);
|
|
185
|
+
let copiesAccumulator = false;
|
|
186
|
+
if (method.name === "assign" && isGlobalCopyOwner(context.sourceCode, method.object, "Object")) {
|
|
187
|
+
const target = node.arguments[0];
|
|
188
|
+
copiesAccumulator = target !== undefined && unwrapArrayExpression(target).type === "ObjectExpression" && node.arguments.slice(1).some(isAccumulator);
|
|
189
|
+
} else if (method.name === "from" && isGlobalCopyOwner(context.sourceCode, method.object, "Array")) {
|
|
190
|
+
const source = node.arguments[0];
|
|
191
|
+
copiesAccumulator = source !== undefined && isAccumulator(source);
|
|
192
|
+
} else if (["concat", "slice", "toSpliced", "toSorted", "toReversed", "with"].includes(method.name)) {
|
|
193
|
+
const initialValue = reducer.initialValue;
|
|
194
|
+
const arrayAccumulator = initialValue !== undefined && isKnownArrayExpression(context.sourceCode, initialValue);
|
|
195
|
+
copiesAccumulator = arrayAccumulator && isAccumulator(method.object);
|
|
196
|
+
}
|
|
197
|
+
if (copiesAccumulator)
|
|
198
|
+
context.report({ node, messageId: "accumulatorCopy" });
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// vendor/anti-slop/src/rules/no-chained-type-assertions.ts
|
|
205
|
+
import { defineRule as defineRule3 } from "@oxlint/plugins";
|
|
6
206
|
function isTypeAssertionExpression(node) {
|
|
7
207
|
return node.type === "TSAsExpression" || node.type === "TSTypeAssertion";
|
|
8
208
|
}
|
|
@@ -37,7 +237,7 @@ function isForbiddenAssertionChain(node) {
|
|
|
37
237
|
}
|
|
38
238
|
return assertionCount > 1 && hasNonConstAssertion;
|
|
39
239
|
}
|
|
40
|
-
var noChainedTypeAssertionsRule =
|
|
240
|
+
var noChainedTypeAssertionsRule = defineRule3({
|
|
41
241
|
meta: {
|
|
42
242
|
type: "problem",
|
|
43
243
|
docs: {
|
|
@@ -61,7 +261,7 @@ var noChainedTypeAssertionsRule = defineRule({
|
|
|
61
261
|
});
|
|
62
262
|
|
|
63
263
|
// vendor/anti-slop/src/rules/no-conditional-empty-object-spread.ts
|
|
64
|
-
import { defineRule as
|
|
264
|
+
import { defineRule as defineRule4 } from "@oxlint/plugins";
|
|
65
265
|
function unwrapParentheses(node) {
|
|
66
266
|
let current = node;
|
|
67
267
|
while (current.type === "ParenthesizedExpression") {
|
|
@@ -76,7 +276,7 @@ function isConditionalEmptyObjectSpread(node) {
|
|
|
76
276
|
const conditional = unwrapParentheses(node);
|
|
77
277
|
return conditional.type === "ConditionalExpression" && (isEmptyObjectExpression(conditional.consequent) || isEmptyObjectExpression(conditional.alternate));
|
|
78
278
|
}
|
|
79
|
-
var noConditionalEmptyObjectSpreadRule =
|
|
279
|
+
var noConditionalEmptyObjectSpreadRule = defineRule4({
|
|
80
280
|
meta: {
|
|
81
281
|
type: "suggestion",
|
|
82
282
|
docs: {
|
|
@@ -100,7 +300,7 @@ var noConditionalEmptyObjectSpreadRule = defineRule2({
|
|
|
100
300
|
});
|
|
101
301
|
|
|
102
302
|
// vendor/anti-slop/src/rules/no-known-value-widening.ts
|
|
103
|
-
import { defineRule as
|
|
303
|
+
import { defineRule as defineRule5 } from "@oxlint/plugins";
|
|
104
304
|
|
|
105
305
|
// vendor/anti-slop/src/shared/lexical-type-parameters.ts
|
|
106
306
|
function isNode(value) {
|
|
@@ -503,9 +703,9 @@ function classifyWideningTarget(type, environment) {
|
|
|
503
703
|
if (alias === null)
|
|
504
704
|
return null;
|
|
505
705
|
if ((alias.typeParameters?.params.length ?? 0) > 0) {
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
return
|
|
706
|
+
const substitutions = aliasSubstitution(alias, unwrapped, new Map);
|
|
707
|
+
const resolved = substitutions === null ? null : classifyAliasBroadTarget(alias.typeAnnotation, environment, substitutions, new Set([name]));
|
|
708
|
+
return resolved?.kind === "open dictionary" ? { kind: "generic container" } : null;
|
|
509
709
|
}
|
|
510
710
|
const substitutions = aliasSubstitution(alias, unwrapped, new Map);
|
|
511
711
|
if (substitutions === null)
|
|
@@ -799,7 +999,7 @@ function isDictionaryAccumulatorTarget(destination) {
|
|
|
799
999
|
function hasParentAssertion(node) {
|
|
800
1000
|
return node.parent?.type === "TSAsExpression" || node.parent?.type === "TSTypeAssertion";
|
|
801
1001
|
}
|
|
802
|
-
var noKnownValueWideningRule =
|
|
1002
|
+
var noKnownValueWideningRule = defineRule5({
|
|
803
1003
|
meta: {
|
|
804
1004
|
type: "problem",
|
|
805
1005
|
docs: {
|
|
@@ -912,7 +1112,7 @@ var noKnownValueWideningRule = defineRule3({
|
|
|
912
1112
|
});
|
|
913
1113
|
|
|
914
1114
|
// vendor/anti-slop/src/rules/no-module-mocking.ts
|
|
915
|
-
import { defineRule as
|
|
1115
|
+
import { defineRule as defineRule6 } from "@oxlint/plugins";
|
|
916
1116
|
var moduleMockMethods = new Set(["doMock", "mock", "unstable_mockModule"]);
|
|
917
1117
|
function resolveVariable2(sourceCode, identifier) {
|
|
918
1118
|
let scope = sourceCode.getScope(identifier);
|
|
@@ -957,7 +1157,7 @@ function moduleMockCall(sourceCode, callee) {
|
|
|
957
1157
|
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;
|
|
958
1158
|
return method !== null && moduleMockMethods.has(method);
|
|
959
1159
|
}
|
|
960
|
-
var noModuleMockingRule =
|
|
1160
|
+
var noModuleMockingRule = defineRule6({
|
|
961
1161
|
meta: {
|
|
962
1162
|
type: "problem",
|
|
963
1163
|
docs: {
|
|
@@ -981,8 +1181,8 @@ var noModuleMockingRule = defineRule4({
|
|
|
981
1181
|
});
|
|
982
1182
|
|
|
983
1183
|
// vendor/anti-slop/src/rules/no-object-parameters.ts
|
|
984
|
-
import { defineRule as
|
|
985
|
-
var noObjectParametersRule =
|
|
1184
|
+
import { defineRule as defineRule7 } from "@oxlint/plugins";
|
|
1185
|
+
var noObjectParametersRule = defineRule7({
|
|
986
1186
|
meta: {
|
|
987
1187
|
type: "problem",
|
|
988
1188
|
docs: {
|
|
@@ -1035,7 +1235,7 @@ var noObjectParametersRule = defineRule5({
|
|
|
1035
1235
|
});
|
|
1036
1236
|
|
|
1037
1237
|
// vendor/anti-slop/src/rules/no-reflect-apply.ts
|
|
1038
|
-
import { defineRule as
|
|
1238
|
+
import { defineRule as defineRule8 } from "@oxlint/plugins";
|
|
1039
1239
|
|
|
1040
1240
|
// vendor/anti-slop/src/shared/reflect-method.ts
|
|
1041
1241
|
function resolveVariable3(sourceCode, identifier) {
|
|
@@ -1066,7 +1266,7 @@ function isGlobalReflectMethodCall(sourceCode, callee, methodName) {
|
|
|
1066
1266
|
}
|
|
1067
1267
|
|
|
1068
1268
|
// vendor/anti-slop/src/rules/no-reflect-apply.ts
|
|
1069
|
-
var noReflectApplyRule =
|
|
1269
|
+
var noReflectApplyRule = defineRule8({
|
|
1070
1270
|
meta: {
|
|
1071
1271
|
type: "problem",
|
|
1072
1272
|
docs: {
|
|
@@ -1090,8 +1290,8 @@ var noReflectApplyRule = defineRule6({
|
|
|
1090
1290
|
});
|
|
1091
1291
|
|
|
1092
1292
|
// vendor/anti-slop/src/rules/no-reflect-get.ts
|
|
1093
|
-
import { defineRule as
|
|
1094
|
-
var noReflectGetRule =
|
|
1293
|
+
import { defineRule as defineRule9 } from "@oxlint/plugins";
|
|
1294
|
+
var noReflectGetRule = defineRule9({
|
|
1095
1295
|
meta: {
|
|
1096
1296
|
type: "problem",
|
|
1097
1297
|
docs: {
|
|
@@ -1115,7 +1315,7 @@ var noReflectGetRule = defineRule7({
|
|
|
1115
1315
|
});
|
|
1116
1316
|
|
|
1117
1317
|
// vendor/anti-slop/src/rules/no-runtime-typeof.ts
|
|
1118
|
-
import { defineRule as
|
|
1318
|
+
import { defineRule as defineRule10 } from "@oxlint/plugins";
|
|
1119
1319
|
function isRuntimeFunction(node) {
|
|
1120
1320
|
return node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression";
|
|
1121
1321
|
}
|
|
@@ -1138,7 +1338,7 @@ function isExistenceProbe(node) {
|
|
|
1138
1338
|
const other = parent.left === node ? parent.right : parent.left;
|
|
1139
1339
|
return other.type === "Literal" && other.value === "undefined";
|
|
1140
1340
|
}
|
|
1141
|
-
var noRuntimeTypeofRule =
|
|
1341
|
+
var noRuntimeTypeofRule = defineRule10({
|
|
1142
1342
|
meta: {
|
|
1143
1343
|
type: "problem",
|
|
1144
1344
|
docs: {
|
|
@@ -1172,7 +1372,7 @@ var noRuntimeTypeofRule = defineRule8({
|
|
|
1172
1372
|
});
|
|
1173
1373
|
|
|
1174
1374
|
// vendor/anti-slop/src/rules/no-shape-in-symbol-names.ts
|
|
1175
|
-
import { defineRule as
|
|
1375
|
+
import { defineRule as defineRule11 } from "@oxlint/plugins";
|
|
1176
1376
|
var FORBIDDEN_SYMBOL_NAME = "shape";
|
|
1177
1377
|
function containsForbiddenSymbolName(name) {
|
|
1178
1378
|
return name.toLowerCase().includes(FORBIDDEN_SYMBOL_NAME);
|
|
@@ -1183,7 +1383,7 @@ function isBorrowedMemberName(node) {
|
|
|
1183
1383
|
return false;
|
|
1184
1384
|
return parent.property === node && parent.computed === false;
|
|
1185
1385
|
}
|
|
1186
|
-
var noForbiddenTermInSymbolNamesRule =
|
|
1386
|
+
var noForbiddenTermInSymbolNamesRule = defineRule11({
|
|
1187
1387
|
meta: {
|
|
1188
1388
|
type: "problem",
|
|
1189
1389
|
docs: {
|
|
@@ -1212,12 +1412,12 @@ var noForbiddenTermInSymbolNamesRule = defineRule9({
|
|
|
1212
1412
|
});
|
|
1213
1413
|
|
|
1214
1414
|
// vendor/anti-slop/src/rules/no-unknown-parameters.ts
|
|
1215
|
-
import { defineRule as
|
|
1415
|
+
import { defineRule as defineRule12 } from "@oxlint/plugins";
|
|
1216
1416
|
function isTypePredicateSubject(owner, parameterName) {
|
|
1217
1417
|
const predicate = owner.returnType?.typeAnnotation;
|
|
1218
1418
|
return predicate?.type === "TSTypePredicate" && predicate.parameterName.type === "Identifier" && predicate.parameterName.name === parameterName;
|
|
1219
1419
|
}
|
|
1220
|
-
var noUnknownParametersRule =
|
|
1420
|
+
var noUnknownParametersRule = defineRule12({
|
|
1221
1421
|
meta: {
|
|
1222
1422
|
type: "problem",
|
|
1223
1423
|
docs: {
|
|
@@ -1261,8 +1461,8 @@ var noUnknownParametersRule = defineRule10({
|
|
|
1261
1461
|
});
|
|
1262
1462
|
|
|
1263
1463
|
// vendor/anti-slop/src/rules/no-unknown-returns.ts
|
|
1264
|
-
import { defineRule as
|
|
1265
|
-
var noUnknownReturnsRule =
|
|
1464
|
+
import { defineRule as defineRule13 } from "@oxlint/plugins";
|
|
1465
|
+
var noUnknownReturnsRule = defineRule13({
|
|
1266
1466
|
meta: {
|
|
1267
1467
|
type: "problem",
|
|
1268
1468
|
docs: {
|
|
@@ -1315,8 +1515,8 @@ var noUnknownReturnsRule = defineRule11({
|
|
|
1315
1515
|
});
|
|
1316
1516
|
|
|
1317
1517
|
// vendor/anti-slop/src/rules/no-unknown-type-aliases.ts
|
|
1318
|
-
import { defineRule as
|
|
1319
|
-
var noUnknownTypeAliasesRule =
|
|
1518
|
+
import { defineRule as defineRule14 } from "@oxlint/plugins";
|
|
1519
|
+
var noUnknownTypeAliasesRule = defineRule14({
|
|
1320
1520
|
meta: {
|
|
1321
1521
|
type: "problem",
|
|
1322
1522
|
docs: {
|
|
@@ -1354,7 +1554,7 @@ var noUnknownTypeAliasesRule = defineRule12({
|
|
|
1354
1554
|
});
|
|
1355
1555
|
|
|
1356
1556
|
// vendor/anti-slop/src/rules/no-unsafe-dictionary-type.ts
|
|
1357
|
-
import { defineRule as
|
|
1557
|
+
import { defineRule as defineRule15 } from "@oxlint/plugins";
|
|
1358
1558
|
var typeNodeKinds = new Set([
|
|
1359
1559
|
"JSDocNonNullableType",
|
|
1360
1560
|
"JSDocNullableType",
|
|
@@ -1441,7 +1641,7 @@ function shouldReportType(node, environment) {
|
|
|
1441
1641
|
}
|
|
1442
1642
|
return true;
|
|
1443
1643
|
}
|
|
1444
|
-
var noUnsafeDictionaryTypeRule =
|
|
1644
|
+
var noUnsafeDictionaryTypeRule = defineRule15({
|
|
1445
1645
|
meta: {
|
|
1446
1646
|
type: "problem",
|
|
1447
1647
|
docs: {
|
|
@@ -1483,7 +1683,7 @@ var noUnsafeDictionaryTypeRule = defineRule13({
|
|
|
1483
1683
|
});
|
|
1484
1684
|
|
|
1485
1685
|
// vendor/anti-slop/src/rules/no-widen-then-assert.ts
|
|
1486
|
-
import { defineRule as
|
|
1686
|
+
import { defineRule as defineRule16 } from "@oxlint/plugins";
|
|
1487
1687
|
var functionBoundaryTypes = new Set([
|
|
1488
1688
|
"ArrowFunctionExpression",
|
|
1489
1689
|
"FunctionDeclaration",
|
|
@@ -1679,7 +1879,7 @@ function assertionIsNarrower(sourceText, broadKind, evidence, assertedType) {
|
|
|
1679
1879
|
return isDefinitelyObjectType(assertedType);
|
|
1680
1880
|
return isDefinitelyNarrowerRecordType(assertedType);
|
|
1681
1881
|
}
|
|
1682
|
-
var noWidenThenAssertRule =
|
|
1882
|
+
var noWidenThenAssertRule = defineRule16({
|
|
1683
1883
|
meta: {
|
|
1684
1884
|
type: "problem",
|
|
1685
1885
|
docs: {
|
|
@@ -1719,7 +1919,7 @@ var noWidenThenAssertRule = defineRule14({
|
|
|
1719
1919
|
});
|
|
1720
1920
|
|
|
1721
1921
|
// vendor/anti-slop/src/rules/require-safety-comment-for-type-assertion.ts
|
|
1722
|
-
import { defineRule as
|
|
1922
|
+
import { defineRule as defineRule17 } from "@oxlint/plugins";
|
|
1723
1923
|
var DEFAULT_SAFETY_MARKERS = ["SAFETY"];
|
|
1724
1924
|
var commentOwnerKinds = new Set([
|
|
1725
1925
|
"ExpressionStatement",
|
|
@@ -1762,7 +1962,7 @@ function hasSafetyComment(sourceCode, node, pattern) {
|
|
|
1762
1962
|
current = current.parent;
|
|
1763
1963
|
}
|
|
1764
1964
|
}
|
|
1765
|
-
var requireSafetyCommentForTypeAssertionRule =
|
|
1965
|
+
var requireSafetyCommentForTypeAssertionRule = defineRule17({
|
|
1766
1966
|
meta: {
|
|
1767
1967
|
type: "problem",
|
|
1768
1968
|
docs: {
|
|
@@ -1815,6 +2015,8 @@ var requireSafetyCommentForTypeAssertionRule = defineRule15({
|
|
|
1815
2015
|
var antiSlopPlugin = eslintCompatPlugin({
|
|
1816
2016
|
meta: { name: "anti-slop" },
|
|
1817
2017
|
rules: {
|
|
2018
|
+
"no-array-filter-map": noArrayFilterMapRule,
|
|
2019
|
+
"no-reduce-accumulator-copy": noReduceAccumulatorCopyRule,
|
|
1818
2020
|
"no-chained-type-assertions": noChainedTypeAssertionsRule,
|
|
1819
2021
|
"no-conditional-empty-object-spread": noConditionalEmptyObjectSpreadRule,
|
|
1820
2022
|
"no-known-value-widening": noKnownValueWideningRule,
|
|
@@ -1837,7 +2039,7 @@ var src_default = antiSlopPlugin;
|
|
|
1837
2039
|
import { eslintCompatPlugin as eslintCompatPlugin2 } from "@oxlint/plugins";
|
|
1838
2040
|
|
|
1839
2041
|
// src/generic/rules/prefer-event-parameter-type.ts
|
|
1840
|
-
import { defineRule as
|
|
2042
|
+
import { defineRule as defineRule18 } from "@oxlint/plugins";
|
|
1841
2043
|
function nearestEnclosingFunction(node) {
|
|
1842
2044
|
let current = node.parent;
|
|
1843
2045
|
while (current) {
|
|
@@ -1864,7 +2066,7 @@ function assertedEventParameter(node) {
|
|
|
1864
2066
|
property
|
|
1865
2067
|
};
|
|
1866
2068
|
}
|
|
1867
|
-
var preferEventParameterTypeRule =
|
|
2069
|
+
var preferEventParameterTypeRule = defineRule18({
|
|
1868
2070
|
meta: {
|
|
1869
2071
|
type: "suggestion",
|
|
1870
2072
|
docs: {
|
|
@@ -1901,11 +2103,6 @@ var timmoPlugin = eslintCompatPlugin2({
|
|
|
1901
2103
|
});
|
|
1902
2104
|
var generic_default = timmoPlugin;
|
|
1903
2105
|
|
|
1904
|
-
// node_modules/oxlint/dist/index.js
|
|
1905
|
-
function defineConfig(config) {
|
|
1906
|
-
return config;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
2106
|
// src/configs/enable-plugin-rules.ts
|
|
1910
2107
|
function enablePluginRules(namespace, plugin) {
|
|
1911
2108
|
return Object.fromEntries(Object.keys(plugin.rules).sort().map((rule) => [`${namespace}/${rule}`, "error"]));
|