@interlace/eslint-devkit 1.5.0 → 1.6.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/package.json +15 -19
- package/src/aria-definitions.js +0 -14
- package/src/ast/ast-utils.js +0 -72
- package/src/ast/index.js +0 -6
- package/src/ast-node-types.d.ts +29 -0
- package/src/ast-node-types.js +174 -0
- package/src/index.d.ts +11 -2
- package/src/index.js +5 -38
- package/src/messaging/config.js +0 -88
- package/src/messaging/constants.js +20 -142
- package/src/messaging/formatters-ai.js +0 -89
- package/src/messaging/formatters-v2.js +0 -151
- package/src/messaging/formatters.js +2 -145
- package/src/messaging/index.js +0 -6
- package/src/messaging/types-v2.js +0 -5
- package/src/messaging/types.js +0 -5
- package/src/node/fs.js +0 -61
- package/src/node/index.js +0 -6
- package/src/node/os.js +0 -33
- package/src/node/path.js +0 -126
- package/src/resolver/dependency-analysis.js +64 -562
- package/src/resolver/index.js +0 -6
- package/src/resolver/resolver-adapter.js +0 -39
- package/src/resolver/resolver-detection.js +0 -48
- package/src/resolver/resolver.d.ts +11 -0
- package/src/resolver/resolver.js +49 -112
- package/src/resolver.js +0 -5
- package/src/rule-creation/index.js +0 -8
- package/src/rule-creation/mock-context.js +0 -9
- package/src/rule-creation/rule-creator.d.ts +59 -10
- package/src/rule-creation/rule-creator.js +64 -40
- package/src/rule-creation/sql-injection-rule.js +0 -52
- package/src/security/index.js +0 -6
- package/src/security/security-utils.js +9 -287
- package/src/types/index.js +0 -9
- package/src/types/meta-augmentation.js +0 -5
- package/src/types/type-utils.d.ts +1 -1
- package/src/types/type-utils.js +34 -145
- package/AGENTS.md +0 -151
- package/CHANGELOG.md +0 -181
package/src/types/type-utils.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
-
* MIT license that can be found in the LICENSE file.
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.getParserServices = getParserServices;
|
|
9
4
|
exports.hasParserServices = hasParserServices;
|
|
@@ -25,15 +20,20 @@ exports.isUnionOfLiterals = isUnionOfLiterals;
|
|
|
25
20
|
exports.isUnionOfStringLiterals = isUnionOfStringLiterals;
|
|
26
21
|
exports.getStringLiteralValues = getStringLiteralValues;
|
|
27
22
|
exports.isUnionOfSafeStringLiterals = isUnionOfSafeStringLiterals;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const TypeFlags = {
|
|
24
|
+
Any: 1,
|
|
25
|
+
Unknown: 2,
|
|
26
|
+
Undefined: 4,
|
|
27
|
+
Null: 8,
|
|
28
|
+
String: 32,
|
|
29
|
+
Number: 64,
|
|
30
|
+
Boolean: 256,
|
|
31
|
+
StringLiteral: 1024,
|
|
32
|
+
NumberLiteral: 2048,
|
|
33
|
+
BooleanLiteral: 8192,
|
|
34
|
+
Never: 262144,
|
|
35
|
+
};
|
|
35
36
|
function getParserServices(context) {
|
|
36
|
-
// Handle both ESLint 8 and ESLint 9 contexts
|
|
37
37
|
const parserServices = context.sourceCode?.parserServices ?? context.parserServices;
|
|
38
38
|
if (!parserServices ||
|
|
39
39
|
!parserServices.program ||
|
|
@@ -41,21 +41,14 @@ function getParserServices(context) {
|
|
|
41
41
|
throw new Error('You have used a rule which requires parserServices to be generated. ' +
|
|
42
42
|
'You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.');
|
|
43
43
|
}
|
|
44
|
-
// At this point we've verified the required properties exist, safe to cast
|
|
45
44
|
return parserServices;
|
|
46
45
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Check if parser services are available without throwing
|
|
49
|
-
*/
|
|
50
46
|
function hasParserServices(context) {
|
|
51
47
|
const parserServices = context.sourceCode?.parserServices ?? context.parserServices;
|
|
52
48
|
return !!(parserServices &&
|
|
53
49
|
parserServices.program &&
|
|
54
50
|
parserServices.esTreeNodeToTSNodeMap);
|
|
55
51
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Get the TypeScript type of an ESTree node
|
|
58
|
-
*/
|
|
59
52
|
function getTypeOfNode(node, parserServices) {
|
|
60
53
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
61
54
|
const program = parserServices.program;
|
|
@@ -65,11 +58,8 @@ function getTypeOfNode(node, parserServices) {
|
|
|
65
58
|
const checker = program.getTypeChecker();
|
|
66
59
|
return checker.getTypeAtLocation(tsNode);
|
|
67
60
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Check if a type is any type
|
|
70
|
-
*/
|
|
71
61
|
function isAnyType(type) {
|
|
72
|
-
if (type.flags &
|
|
62
|
+
if (type.flags & TypeFlags.Any) {
|
|
73
63
|
return true;
|
|
74
64
|
}
|
|
75
65
|
if (type.isUnion()) {
|
|
@@ -77,11 +67,8 @@ function isAnyType(type) {
|
|
|
77
67
|
}
|
|
78
68
|
return false;
|
|
79
69
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Check if a type is unknown type
|
|
82
|
-
*/
|
|
83
70
|
function isUnknownType(type) {
|
|
84
|
-
if (type.flags &
|
|
71
|
+
if (type.flags & TypeFlags.Unknown) {
|
|
85
72
|
return true;
|
|
86
73
|
}
|
|
87
74
|
if (type.isUnion()) {
|
|
@@ -89,31 +76,22 @@ function isUnknownType(type) {
|
|
|
89
76
|
}
|
|
90
77
|
return false;
|
|
91
78
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if a type is never type
|
|
94
|
-
*/
|
|
95
79
|
function isNeverType(type) {
|
|
96
|
-
return (type.flags &
|
|
80
|
+
return (type.flags & TypeFlags.Never) !== 0;
|
|
97
81
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if a type is null or undefined
|
|
100
|
-
*/
|
|
101
82
|
function isNullableType(type) {
|
|
102
83
|
if (type.isUnion()) {
|
|
103
|
-
return type.types.some((t) => (t.flags &
|
|
104
|
-
(t.flags &
|
|
84
|
+
return type.types.some((t) => (t.flags & TypeFlags.Null) !== 0 ||
|
|
85
|
+
(t.flags & TypeFlags.Undefined) !== 0);
|
|
105
86
|
}
|
|
106
|
-
return ((type.flags &
|
|
107
|
-
(type.flags &
|
|
87
|
+
return ((type.flags & TypeFlags.Null) !== 0 ||
|
|
88
|
+
(type.flags & TypeFlags.Undefined) !== 0);
|
|
108
89
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Check if a type is a string type
|
|
111
|
-
*/
|
|
112
90
|
function isStringType(type) {
|
|
113
|
-
if (type.flags &
|
|
91
|
+
if (type.flags & TypeFlags.String) {
|
|
114
92
|
return true;
|
|
115
93
|
}
|
|
116
|
-
if (type.flags &
|
|
94
|
+
if (type.flags & TypeFlags.StringLiteral) {
|
|
117
95
|
return true;
|
|
118
96
|
}
|
|
119
97
|
if (type.isUnion()) {
|
|
@@ -121,14 +99,11 @@ function isStringType(type) {
|
|
|
121
99
|
}
|
|
122
100
|
return false;
|
|
123
101
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Check if a type is a number type
|
|
126
|
-
*/
|
|
127
102
|
function isNumberType(type) {
|
|
128
|
-
if (type.flags &
|
|
103
|
+
if (type.flags & TypeFlags.Number) {
|
|
129
104
|
return true;
|
|
130
105
|
}
|
|
131
|
-
if (type.flags &
|
|
106
|
+
if (type.flags & TypeFlags.NumberLiteral) {
|
|
132
107
|
return true;
|
|
133
108
|
}
|
|
134
109
|
if (type.isUnion()) {
|
|
@@ -136,14 +111,11 @@ function isNumberType(type) {
|
|
|
136
111
|
}
|
|
137
112
|
return false;
|
|
138
113
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Check if a type is a boolean type
|
|
141
|
-
*/
|
|
142
114
|
function isBooleanType(type) {
|
|
143
|
-
if (type.flags &
|
|
115
|
+
if (type.flags & TypeFlags.Boolean) {
|
|
144
116
|
return true;
|
|
145
117
|
}
|
|
146
|
-
if (type.flags &
|
|
118
|
+
if (type.flags & TypeFlags.BooleanLiteral) {
|
|
147
119
|
return true;
|
|
148
120
|
}
|
|
149
121
|
if (type.isUnion()) {
|
|
@@ -151,9 +123,6 @@ function isBooleanType(type) {
|
|
|
151
123
|
}
|
|
152
124
|
return false;
|
|
153
125
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Check if a type is an array type
|
|
156
|
-
*/
|
|
157
126
|
function isArrayType(type, checker) {
|
|
158
127
|
const symbol = type.getSymbol();
|
|
159
128
|
if (!symbol) {
|
|
@@ -161,9 +130,6 @@ function isArrayType(type, checker) {
|
|
|
161
130
|
}
|
|
162
131
|
return symbol.getName() === 'Array' && checker.isArrayType(type);
|
|
163
132
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Check if a type is a promise type
|
|
166
|
-
*/
|
|
167
133
|
function isPromiseType(type) {
|
|
168
134
|
const symbol = type.getSymbol();
|
|
169
135
|
if (!symbol) {
|
|
@@ -171,9 +137,6 @@ function isPromiseType(type) {
|
|
|
171
137
|
}
|
|
172
138
|
return symbol.getName() === 'Promise';
|
|
173
139
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Get the type arguments of a generic type
|
|
176
|
-
*/
|
|
177
140
|
function getTypeArguments(type, checker) {
|
|
178
141
|
if (checker.isArrayType?.(type)) {
|
|
179
142
|
return checker.getTypeArguments(type);
|
|
@@ -184,9 +147,6 @@ function getTypeArguments(type, checker) {
|
|
|
184
147
|
}
|
|
185
148
|
return [];
|
|
186
149
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Check if a type satisfies a predicate (including union types)
|
|
189
|
-
*/
|
|
190
150
|
function typeMatchesPredicateRecursive(type, predicate) {
|
|
191
151
|
if (predicate(type)) {
|
|
192
152
|
return true;
|
|
@@ -199,97 +159,38 @@ function typeMatchesPredicateRecursive(type, predicate) {
|
|
|
199
159
|
}
|
|
200
160
|
return false;
|
|
201
161
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Check if a type is a string literal type (e.g., 'name', 'email')
|
|
204
|
-
*
|
|
205
|
-
* This is useful for detecting statically constrained property keys
|
|
206
|
-
* that are safe from object injection attacks.
|
|
207
|
-
*/
|
|
208
162
|
function isStringLiteralType(type) {
|
|
209
|
-
return (type.flags &
|
|
163
|
+
return (type.flags & TypeFlags.StringLiteral) !== 0;
|
|
210
164
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Check if a type is a number literal type (e.g., 1, 2, 3)
|
|
213
|
-
*/
|
|
214
165
|
function isNumberLiteralType(type) {
|
|
215
|
-
return (type.flags &
|
|
166
|
+
return (type.flags & TypeFlags.NumberLiteral) !== 0;
|
|
216
167
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Check if a type is a union of only literal types (string, number, or boolean literals)
|
|
219
|
-
*
|
|
220
|
-
* This is the key function for type-aware security rules.
|
|
221
|
-
* A union like 'name' | 'email' is statically constrained and safe,
|
|
222
|
-
* while string | number could be any value at runtime.
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* // Returns true - safe, statically constrained:
|
|
226
|
-
* type Key = 'name' | 'email' | 'age';
|
|
227
|
-
*
|
|
228
|
-
* // Returns false - unsafe, could be any string:
|
|
229
|
-
* type Key = string;
|
|
230
|
-
* type Key = string | number;
|
|
231
|
-
* type Key = 'name' | string; // string absorbs the literal
|
|
232
|
-
*/
|
|
233
168
|
function isUnionOfLiterals(type) {
|
|
234
|
-
// Single literal type
|
|
235
169
|
if (isStringLiteralType(type) || isNumberLiteralType(type)) {
|
|
236
170
|
return true;
|
|
237
171
|
}
|
|
238
|
-
|
|
239
|
-
if (type.flags & ts.TypeFlags.BooleanLiteral) {
|
|
172
|
+
if (type.flags & TypeFlags.BooleanLiteral) {
|
|
240
173
|
return true;
|
|
241
174
|
}
|
|
242
|
-
// Union type - check if ALL members are literals
|
|
243
175
|
if (type.isUnion()) {
|
|
244
176
|
return type.types.every((t) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(t.flags &
|
|
248
|
-
(t.flags & ts.TypeFlags.BooleanLiteral) !== 0);
|
|
177
|
+
return ((t.flags & TypeFlags.StringLiteral) !== 0 ||
|
|
178
|
+
(t.flags & TypeFlags.NumberLiteral) !== 0 ||
|
|
179
|
+
(t.flags & TypeFlags.BooleanLiteral) !== 0);
|
|
249
180
|
});
|
|
250
181
|
}
|
|
251
182
|
return false;
|
|
252
183
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Check if a type is a union of only string literals
|
|
255
|
-
*
|
|
256
|
-
* More specific version of isUnionOfLiterals that only allows string literals.
|
|
257
|
-
* This is useful for property key validation where only string keys are expected.
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* // Returns true:
|
|
261
|
-
* type Key = 'name' | 'email';
|
|
262
|
-
*
|
|
263
|
-
* // Returns false:
|
|
264
|
-
* type Key = 'name' | 1; // has number literal
|
|
265
|
-
* type Key = string;
|
|
266
|
-
*/
|
|
267
184
|
function isUnionOfStringLiterals(type) {
|
|
268
|
-
// Single string literal
|
|
269
185
|
if (isStringLiteralType(type)) {
|
|
270
186
|
return true;
|
|
271
187
|
}
|
|
272
|
-
// Union type - check if ALL members are string literals
|
|
273
188
|
if (type.isUnion()) {
|
|
274
189
|
return type.types.every((t) => isStringLiteralType(t));
|
|
275
190
|
}
|
|
276
191
|
return false;
|
|
277
192
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Get the literal values from a union of string literals
|
|
280
|
-
*
|
|
281
|
-
* Extracts the actual string values from a type like 'name' | 'email'
|
|
282
|
-
* Returns null if the type is not a union of string literals.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* // For type 'name' | 'email':
|
|
286
|
-
* getStringLiteralValues(type) // ['name', 'email']
|
|
287
|
-
*
|
|
288
|
-
* // For type string:
|
|
289
|
-
* getStringLiteralValues(type) // null
|
|
290
|
-
*/
|
|
291
193
|
function getStringLiteralValues(type) {
|
|
292
|
-
// Single string literal
|
|
293
194
|
if (isStringLiteralType(type)) {
|
|
294
195
|
const literalType = type;
|
|
295
196
|
if (typeof literalType.value === 'string') {
|
|
@@ -297,12 +198,11 @@ function getStringLiteralValues(type) {
|
|
|
297
198
|
}
|
|
298
199
|
return null;
|
|
299
200
|
}
|
|
300
|
-
// Union type - extract all string literal values
|
|
301
201
|
if (type.isUnion()) {
|
|
302
202
|
const values = [];
|
|
303
203
|
for (const t of type.types) {
|
|
304
204
|
if (!isStringLiteralType(t)) {
|
|
305
|
-
return null;
|
|
205
|
+
return null;
|
|
306
206
|
}
|
|
307
207
|
const literalType = t;
|
|
308
208
|
if (typeof literalType.value === 'string') {
|
|
@@ -313,21 +213,10 @@ function getStringLiteralValues(type) {
|
|
|
313
213
|
}
|
|
314
214
|
return null;
|
|
315
215
|
}
|
|
316
|
-
/**
|
|
317
|
-
* Check if a union of string literals contains any dangerous property names
|
|
318
|
-
*
|
|
319
|
-
* Even if a type is constrained to string literals, it could still be dangerous
|
|
320
|
-
* if it includes properties like '__proto__', 'constructor', or 'prototype'.
|
|
321
|
-
*
|
|
322
|
-
* @param type - The TypeScript type to check
|
|
323
|
-
* @param dangerousProperties - List of dangerous property names (defaults to common prototype pollution vectors)
|
|
324
|
-
* @returns true if the type is safe (no dangerous properties), false otherwise
|
|
325
|
-
*/
|
|
326
216
|
function isUnionOfSafeStringLiterals(type, dangerousProperties = ['__proto__', 'prototype', 'constructor']) {
|
|
327
217
|
const values = getStringLiteralValues(type);
|
|
328
218
|
if (!values) {
|
|
329
|
-
return false;
|
|
219
|
+
return false;
|
|
330
220
|
}
|
|
331
|
-
// Check if any literal value is dangerous
|
|
332
221
|
return !values.some((value) => dangerousProperties.includes(value));
|
|
333
222
|
}
|
package/AGENTS.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
> Context for AI coding agents working on @interlace/eslint-devkit
|
|
4
|
-
|
|
5
|
-
## Setup Commands
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Install dependencies (from monorepo root)
|
|
9
|
-
npm install
|
|
10
|
-
|
|
11
|
-
# Build this package
|
|
12
|
-
nx build eslint-devkit
|
|
13
|
-
|
|
14
|
-
# Run tests
|
|
15
|
-
nx test eslint-devkit
|
|
16
|
-
|
|
17
|
-
# Run tests with coverage
|
|
18
|
-
nx test eslint-devkit --coverage
|
|
19
|
-
|
|
20
|
-
# Lint this package
|
|
21
|
-
nx lint eslint-devkit
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Code Style
|
|
25
|
-
|
|
26
|
-
- TypeScript strict mode
|
|
27
|
-
- Export all public utilities from `src/index.ts`
|
|
28
|
-
- Use TSDoc comments for all public APIs
|
|
29
|
-
- Use `c8 ignore` comments with documented reasons for untestable code
|
|
30
|
-
- Tree-shakeable exports (no side effects)
|
|
31
|
-
|
|
32
|
-
## Testing Instructions
|
|
33
|
-
|
|
34
|
-
- Tests use Vitest
|
|
35
|
-
- Test files are in `__tests__/` directories or `*.test.ts` files
|
|
36
|
-
- Coverage target: ≥90% lines, ≥95% functions
|
|
37
|
-
- All tests must pass before committing
|
|
38
|
-
|
|
39
|
-
## Project Structure
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
src/
|
|
43
|
-
├── index.ts # Main exports
|
|
44
|
-
├── rule-creator/ # createRule, createRuleCreator
|
|
45
|
-
├── ast-utils/ # AST analysis utilities
|
|
46
|
-
├── type-utils/ # TypeScript type utilities
|
|
47
|
-
├── message-utils/ # formatLLMMessage and icons
|
|
48
|
-
└── types/ # Type definitions
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Package Purpose
|
|
52
|
-
|
|
53
|
-
Utilities for building **LLM-optimized ESLint rules**. This is the foundation package used by all security plugins in the monorepo. It provides standardized rule creation, AST utilities, type checking helpers, and message formatting.
|
|
54
|
-
|
|
55
|
-
## Core Exports
|
|
56
|
-
|
|
57
|
-
### Rule Creation
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { createRule, createRuleCreator } from '@interlace/eslint-devkit';
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### AST Utilities
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import {
|
|
67
|
-
isNodeOfType,
|
|
68
|
-
isFunctionNode,
|
|
69
|
-
isMemberExpression,
|
|
70
|
-
isCallExpression,
|
|
71
|
-
getIdentifierName,
|
|
72
|
-
getFunctionName,
|
|
73
|
-
getStaticValue,
|
|
74
|
-
isInsideNode,
|
|
75
|
-
getAncestorOfType,
|
|
76
|
-
} from '@interlace/eslint-devkit';
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Type Utilities
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
import {
|
|
83
|
-
hasParserServices,
|
|
84
|
-
getParserServices,
|
|
85
|
-
getTypeOfNode,
|
|
86
|
-
isStringType,
|
|
87
|
-
isNumberType,
|
|
88
|
-
isPromiseType,
|
|
89
|
-
isArrayType,
|
|
90
|
-
} from '@interlace/eslint-devkit';
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Message Formatting
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
import { formatLLMMessage, MessageIcons } from '@interlace/eslint-devkit';
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Type Re-exports
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
import { TSESLint, TSESTree, AST_NODE_TYPES } from '@interlace/eslint-devkit';
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Creating a New Rule
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
import {
|
|
109
|
-
createRule,
|
|
110
|
-
formatLLMMessage,
|
|
111
|
-
MessageIcons,
|
|
112
|
-
AST_NODE_TYPES,
|
|
113
|
-
} from '@interlace/eslint-devkit';
|
|
114
|
-
|
|
115
|
-
export const myRule = createRule({
|
|
116
|
-
name: 'my-rule',
|
|
117
|
-
meta: {
|
|
118
|
-
type: 'problem',
|
|
119
|
-
docs: { description: 'My rule description' },
|
|
120
|
-
hasSuggestions: true,
|
|
121
|
-
messages: {
|
|
122
|
-
error: formatLLMMessage({
|
|
123
|
-
icon: MessageIcons.SECURITY,
|
|
124
|
-
issueName: 'Security Issue',
|
|
125
|
-
cwe: 'CWE-XXX',
|
|
126
|
-
description: 'Description of the issue',
|
|
127
|
-
severity: 'HIGH',
|
|
128
|
-
fix: 'How to fix it',
|
|
129
|
-
documentationLink: 'https://...',
|
|
130
|
-
}),
|
|
131
|
-
},
|
|
132
|
-
schema: [],
|
|
133
|
-
},
|
|
134
|
-
defaultOptions: [],
|
|
135
|
-
create(context) {
|
|
136
|
-
return {
|
|
137
|
-
CallExpression(node) {
|
|
138
|
-
// Rule implementation
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## Best Practices
|
|
146
|
-
|
|
147
|
-
1. **Use AST_NODE_TYPES**: Always use `AST_NODE_TYPES.Identifier` instead of string `'Identifier'`
|
|
148
|
-
2. **Use formatLLMMessage**: All security messages should use the structured format
|
|
149
|
-
3. **Check parser services**: Always check `hasParserServices()` before using type utilities
|
|
150
|
-
4. **Single-pass traversal**: Rules should visit nodes once (O(n) complexity)
|
|
151
|
-
5. **Export rule options types**: Export the Options interface for TypeScript users
|
package/CHANGELOG.md
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
## [1.4.0] - 2026-05-03
|
|
2
|
-
|
|
3
|
-
## 1.5.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
Extract the raw-SQL-injection detector (CWE-89) into
|
|
8
|
-
`@interlace/eslint-devkit` as `createSqlInjectionRule`, so every driver plugin
|
|
9
|
-
can instantiate it with its own sinks and remediation copy.
|
|
10
|
-
|
|
11
|
-
Background: scanning OWASP Juice Shop with the recommended presets of
|
|
12
|
-
`secure-coding`, `node-security`, `express-security` and `mongodb-security`
|
|
13
|
-
produced zero findings on its two flagship SQL injections
|
|
14
|
-
(`routes/search.ts`, `routes/login.ts` — both `sequelize.query()` template
|
|
15
|
-
literals). The detection was never the problem: `pg/no-unsafe-query` matches
|
|
16
|
-
any `.query()` member call and flags both correctly. The problem is
|
|
17
|
-
distribution — nobody on Sequelize installs the Postgres plugin.
|
|
18
|
-
|
|
19
|
-
The factory takes the sink list, a SQL-keyword precision gate, and the
|
|
20
|
-
remediation copy, which is everything that actually differs between drivers.
|
|
21
|
-
`pg/no-unsafe-query` is now an instantiation of it: same rule id, message
|
|
22
|
-
ids, sink and behaviour, and all 28 pre-existing rule tests pass untouched.
|
|
23
|
-
|
|
24
|
-
Also raises the timeout on the `no-deprecated-plugin-references` guard in
|
|
25
|
-
devkit. Both layers shell out to a repo-wide `grep`, which cannot finish
|
|
26
|
-
inside vitest's 5s default once the suite has enough test files running in
|
|
27
|
-
parallel — it failed as a timeout, not a violation.
|
|
28
|
-
|
|
29
|
-
Driver-scoped plugins that instantiate the factory ship separately.
|
|
30
|
-
|
|
31
|
-
## 1.4.4
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- [#302](https://github.com/ofri-peretz/eslint/pull/302) [`09d2951`](https://github.com/ofri-peretz/eslint/commit/09d2951b3ac74efc9ba49b64e9089d66800b16cc) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Add the Interlace OG banner to the README, so the npm page matches every
|
|
36
|
-
published plugin in the ecosystem. devkit was the only published package
|
|
37
|
-
carrying the closing Interlace mark but no banner. README-only change — no
|
|
38
|
-
runtime, API, or type surface is affected; the release exists to get the
|
|
39
|
-
updated README onto npm, where it is baked in at publish time.
|
|
40
|
-
|
|
41
|
-
## 1.4.3
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- [#304](https://github.com/ofri-peretz/eslint/pull/304) [`e1cdf83`](https://github.com/ofri-peretz/eslint/commit/e1cdf83e3db761907f0ab06f7fc6c1f1da7513a5) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - README: call the plugin family "the Interlace eslint-plugins" instead of
|
|
46
|
-
`@interlace/eslint-plugin-*`.
|
|
47
|
-
|
|
48
|
-
The plugins publish unscoped — `eslint-plugin-jwt`, not
|
|
49
|
-
`@interlace/eslint-plugin-jwt` — so the scoped form named packages that do not
|
|
50
|
-
exist on npm. This is a docs-only change; no runtime behaviour is affected. It
|
|
51
|
-
ships as a patch so the corrected text reaches the package page on npm.
|
|
52
|
-
|
|
53
|
-
- [#294](https://github.com/ofri-peretz/eslint/pull/294) [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Rewrite `description` and `keywords` on every published package for npm search discovery. npm ranks on name, description, and keywords, and the registry only picks up these fields at publish — so this is metadata-only and takes effect for each package on its next release.
|
|
54
|
-
|
|
55
|
-
**Descriptions now lead with the search phrase.** Every one starts `ESLint plugin for <the thing you'd search>` instead of a brand-first or category-first framing, and names the concrete vulnerabilities the plugin actually detects. Three were corrected while doing so:
|
|
56
|
-
|
|
57
|
-
- `eslint-plugin-import-next` claimed "100x faster no-cycle detection". No 100x measurement exists: `CLAIMS.md` records **3.1x end-to-end** (8x in pure rule execution) on a 5,483-file React codebase, and the highest number in any benchmark result is 54.9x on the synthetic corpus. The description now states the real-codebase figure.
|
|
58
|
-
- `eslint-plugin-secure-coding` claimed SQL injection, XSS and CSRF coverage — none of which are its rules. It now names what it does detect: LDAP, XPath, XXE, GraphQL and template injection, unsafe deserialization, ReDoS, missing authentication, and PII in logs.
|
|
59
|
-
- `eslint-plugin-secure-coding` ("89 rules") and `eslint-plugin-react-a11y` ("37 rules") hard-coded rule counts that had drifted from reality. Counts are generated into `interlace-numbers.json`; hand-typed copies are removed rather than corrected.
|
|
60
|
-
|
|
61
|
-
**Keywords now match the vocabulary of the plugins that rank.** `eslint-plugin-security`, `eslint-plugin-jsx-a11y`, `eslint-plugin-n` and `eslint-plugin-import` all carry the `eslint` / `eslintplugin` / `eslint-plugin` trio — six of our packages were missing `eslintplugin`, and every one now carries all three plus `static-analysis`, `linting` and `code-quality`. Security plugins add `sast`, `appsec` and `vulnerability`; `node-security` and `secure-coding` also carry `nodesecurity`, the exact keyword `eslint-plugin-security` ranks on. Each plugin gained the CWE identifiers and attack names for what it detects (`cwe-78` command injection, `cwe-22` path traversal, `cwe-89` SQL injection, `cwe-79` XSS, `cwe-347` JWT algorithm confusion, `cwe-352` CSRF, `cwe-943` NoSQL injection), and `node-security` gained the crypto vocabulary it had been missing entirely despite absorbing the crypto rule set (`crypto`, `cryptography`, `weak-hash`, `md5`, `sha1`, `timing-attack`).
|
|
62
|
-
|
|
63
|
-
No rule behavior, exports, or configuration changes.
|
|
64
|
-
|
|
65
|
-
## 1.4.2
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- [#269](https://github.com/ofri-peretz/eslint/pull/269) [`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - docs: dual-logo README header (Interlace mark + ESLint mark side by side) and closing Interlace footer — refreshes the README rendered on npmjs.com. No runtime changes.
|
|
70
|
-
|
|
71
|
-
## 1.4.1
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- [#155](https://github.com/ofri-peretz/eslint/pull/155) [`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Fix `patternToRegex` (glob→regex) to escape **all** regex metacharacters, not just `.`. The previous chained `.replace()` left `\ + ( ) | [ ] { } ^ $` to leak through as regex syntax, so an ignore glob such as `a+b` or `(x)` compiled to a quantifier / capture group and matched the wrong files (CWE-116, surfaced by CodeQL `js/incomplete-sanitization`). The wildcard translation (`**`, `*`, `?`) is unchanged; a regression-lock test pins the metacharacter behavior.
|
|
76
|
-
|
|
77
|
-
### Changed
|
|
78
|
-
|
|
79
|
-
- Module resolver swapped from `enhanced-resolve` + `get-tsconfig` to [`oxc-resolver`](https://www.npmjs.com/package/oxc-resolver) (Rust NAPI, ~18-30× faster). Per-tsconfig caching for monorepo path-alias correctness across package boundaries.
|
|
80
|
-
- `peerDependenciesMeta` no longer lists `enhanced-resolve` and `get-tsconfig` (consumers don't need to peer-provide them; this is **technically breaking** but no consumer impact is expected).
|
|
81
|
-
|
|
82
|
-
### Added
|
|
83
|
-
|
|
84
|
-
- `oxc-resolver` is now a hard `dependencies` entry. Note for adopters: NAPI prebuilds cover common targets (Linux x64/arm64 glibc + musl, macOS x64/arm64, Windows x64); rare targets may need to fall back to a build step.
|
|
85
|
-
|
|
86
|
-
## [1.3.3] - 2026-02-08
|
|
87
|
-
|
|
88
|
-
This was a version bump only for eslint-devkit to align it with other projects, there were no code changes.
|
|
89
|
-
|
|
90
|
-
## [1.3.2] - 2026-02-06
|
|
91
|
-
|
|
92
|
-
This was a version bump only for eslint-devkit to align it with other projects, there were no code changes.
|
|
93
|
-
|
|
94
|
-
# Changelog
|
|
95
|
-
|
|
96
|
-
All notable changes to `@interlace/eslint-devkit` are documented here.
|
|
97
|
-
|
|
98
|
-
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and [SemVer](https://semver.org/spec/v2.0.0.html).
|
|
99
|
-
|
|
100
|
-
## [1.0.0] - 2025-11-30
|
|
101
|
-
|
|
102
|
-
### 🚀 Features
|
|
103
|
-
|
|
104
|
-
- Enhanced LLM message formatting utilities.
|
|
105
|
-
- Improved TypeScript typings for IDE support.
|
|
106
|
-
|
|
107
|
-
### 🩹 Fixes
|
|
108
|
-
|
|
109
|
-
- Compatibility fixes for TS strict mode.
|
|
110
|
-
- More accurate type guards for AST checking.
|
|
111
|
-
|
|
112
|
-
### 📌 Notes
|
|
113
|
-
|
|
114
|
-
- Package name aligned to `@interlace/eslint-devkit` (formerly eslint-plugin-utils).
|
|
115
|
-
|
|
116
|
-
### ❤️ Thank You
|
|
117
|
-
|
|
118
|
-
- Ofri Peretz
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## [0.3.0] - 2025-11-15
|
|
123
|
-
|
|
124
|
-
### 🚀 Features
|
|
125
|
-
|
|
126
|
-
- Enhanced type utilities.
|
|
127
|
-
- Improved AST helpers.
|
|
128
|
-
- Better LLM-oriented error messaging.
|
|
129
|
-
|
|
130
|
-
### 🩹 Fixes
|
|
131
|
-
|
|
132
|
-
- Type checking edge cases.
|
|
133
|
-
- Documentation improvements.
|
|
134
|
-
|
|
135
|
-
### ❤️ Thank You
|
|
136
|
-
|
|
137
|
-
- Ofri Peretz
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## [0.2.2] - 2025-11-07
|
|
142
|
-
|
|
143
|
-
### 🩹 Fixes
|
|
144
|
-
|
|
145
|
-
- Config fixes; removed codecov vite plugin.
|
|
146
|
-
- Adjusted ignore patterns in dependency checks.
|
|
147
|
-
- Added vitest to peerDependencies.
|
|
148
|
-
|
|
149
|
-
### ❤️ Thank You
|
|
150
|
-
|
|
151
|
-
- Ofri Peretz
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## [0.2.1] - 2025-11-07
|
|
156
|
-
|
|
157
|
-
### 🩹 Fixes
|
|
158
|
-
|
|
159
|
-
- Config and dependency-check adjustments.
|
|
160
|
-
|
|
161
|
-
### ❤️ Thank You
|
|
162
|
-
|
|
163
|
-
- Ofri Peretz
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## [0.2.0] - 2025-11-02
|
|
168
|
-
|
|
169
|
-
Version bump to align packages; no code changes.
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## [0.1.1] - 2025-11-02
|
|
174
|
-
|
|
175
|
-
Version bump to align packages; no code changes.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## [0.1.0] - 2025-11-02
|
|
180
|
-
|
|
181
|
-
Initial prerelease for the devkit utilities.
|