@opendesignai/harness 0.2.0-alpha.0 → 0.4.0-alpha.0
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 +90 -44
- package/dist/THIRD-PARTY-LICENSES.md +63 -0
- package/dist/child-env-cPBUueQI.mjs +17 -0
- package/dist/cli.mjs +4916 -209
- package/dist/config.d.mts +68 -0
- package/dist/config.mjs +12 -0
- package/dist/eslint-comments.mjs +1679 -4
- package/dist/hook.d.mts +19 -0
- package/dist/hook.mjs +9843 -0
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +283 -27
- package/dist/report.d.mts +40 -0
- package/dist/report.mjs +34 -0
- package/docs/adopting.md +107 -11
- package/docs/agent-setup.md +21 -0
- package/docs/agents.md +42 -0
- package/docs/comments.md +33 -0
- package/docs/decisions/0001-oxlint.md +28 -1
- package/docs/decisions/0002-react-compiler-rules.md +39 -0
- package/docs/decisions/0004-type-aware-rules.md +43 -0
- package/docs/decisions/0005-test-weakening-rules.md +28 -0
- package/docs/diagnostics.md +58 -0
- package/docs/hooks.md +152 -36
- package/docs/ratchet.md +23 -21
- package/docs/rules/no-commented-out-code.md +47 -0
- package/docs/rules/no-swallowed-catch.md +18 -7
- package/docs/size.md +3 -1
- package/docs/verify.md +80 -0
- package/package.json +30 -6
- package/presets/react-compiler.json +2 -1
- package/presets/rules/base.json +5 -0
- package/presets/strict-types.json +5 -0
- package/presets/testing.json +22 -0
- package/presets/type-aware.json +69 -0
- package/skills/od-feature-intake/SKILL.md +22 -0
- package/skills/od-pre-pr-review/SKILL.md +46 -0
- package/dist/cli.d.mts +0 -1
- package/dist/eslint-comments.d.mts +0 -40
- package/dist/paths-DBoYPrGy.mjs +0 -59
package/dist/eslint-comments.mjs
CHANGED
|
@@ -1,5 +1,1678 @@
|
|
|
1
|
-
import
|
|
2
|
-
//
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
desc = __getOwnPropDesc(from, key);
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
16
|
+
enumerable: !desc || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
27
|
+
// node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js
|
|
28
|
+
var require_escape_string_regexp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
29
|
+
module.exports = (string) => {
|
|
30
|
+
if (typeof string !== "string") throw new TypeError("Expected a string");
|
|
31
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
32
|
+
};
|
|
33
|
+
}));
|
|
34
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/internal/utils.js
|
|
35
|
+
/**
|
|
36
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
37
|
+
* See LICENSE file in root directory for full license.
|
|
38
|
+
*/
|
|
39
|
+
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
40
|
+
const escapeStringRegexp = require_escape_string_regexp();
|
|
41
|
+
const LINE_PATTERN = /[^\r\n\u2028\u2029]*(?:\r\n|[\r\n\u2028\u2029]|$)/gu;
|
|
42
|
+
const DIRECTIVE_PATTERN = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u;
|
|
43
|
+
const LINE_COMMENT_PATTERN = /^eslint-disable-(next-)?line$/u;
|
|
44
|
+
module.exports = {
|
|
45
|
+
/**
|
|
46
|
+
* Make the location ignoring `eslint-disable` comments.
|
|
47
|
+
*
|
|
48
|
+
* @param {object} location - The location to convert.
|
|
49
|
+
* @returns {object} Converted location.
|
|
50
|
+
*/
|
|
51
|
+
toForceLocation(location) {
|
|
52
|
+
return {
|
|
53
|
+
start: {
|
|
54
|
+
line: location.start.line,
|
|
55
|
+
column: -1
|
|
56
|
+
},
|
|
57
|
+
end: location.end
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Calculate the location of the given rule in the given comment token.
|
|
62
|
+
*
|
|
63
|
+
* @param {Partial<import("@eslint/core").RuleContext>} context - The rule context code.
|
|
64
|
+
* @param {Token} comment - The comment token to calculate.
|
|
65
|
+
* @param {string|null} ruleId - The rule name to calculate.
|
|
66
|
+
* @returns {object} The location of the given information.
|
|
67
|
+
*/
|
|
68
|
+
toRuleIdLocation(context, comment, ruleId) {
|
|
69
|
+
const commentLoc = getLoc(context, comment);
|
|
70
|
+
if (ruleId == null) return module.exports.toForceLocation(commentLoc);
|
|
71
|
+
const lines = comment.value.match(LINE_PATTERN);
|
|
72
|
+
const ruleIdPattern = new RegExp(`([\\s,]|^)${escapeStringRegexp(ruleId)}(?:[\\s,]|$)`, "u");
|
|
73
|
+
{
|
|
74
|
+
const m = ruleIdPattern.exec(lines[0]);
|
|
75
|
+
if (m != null) {
|
|
76
|
+
const start = commentLoc.start;
|
|
77
|
+
return {
|
|
78
|
+
start: {
|
|
79
|
+
line: start.line,
|
|
80
|
+
column: 2 + start.column + m.index + m[1].length
|
|
81
|
+
},
|
|
82
|
+
end: {
|
|
83
|
+
line: start.line,
|
|
84
|
+
column: 2 + start.column + m.index + m[1].length + ruleId.length
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (let i = 1; i < lines.length; ++i) {
|
|
90
|
+
const m = ruleIdPattern.exec(lines[i]);
|
|
91
|
+
if (m != null) {
|
|
92
|
+
const start = commentLoc.start;
|
|
93
|
+
return {
|
|
94
|
+
start: {
|
|
95
|
+
line: start.line + i,
|
|
96
|
+
column: m.index + m[1].length
|
|
97
|
+
},
|
|
98
|
+
end: {
|
|
99
|
+
line: start.line + i,
|
|
100
|
+
column: m.index + m[1].length + ruleId.length
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/*istanbul ignore next : foolproof */
|
|
106
|
+
return commentLoc;
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Checks `a` is less than `b` or `a` equals `b`.
|
|
110
|
+
*
|
|
111
|
+
* @param {{line: number, column: number}} a - A location to compare.
|
|
112
|
+
* @param {{line: number, column: number}} b - Another location to compare.
|
|
113
|
+
* @returns {boolean} `true` if `a` is less than `b` or `a` equals `b`.
|
|
114
|
+
*/
|
|
115
|
+
lte(a, b) {
|
|
116
|
+
return a.line < b.line || a.line === b.line && a.column <= b.column;
|
|
117
|
+
},
|
|
118
|
+
/**
|
|
119
|
+
* Parse the given comment token as a directive comment.
|
|
120
|
+
*
|
|
121
|
+
* @param {Token} comment - The comment token to parse.
|
|
122
|
+
* @param {Set<string>} additionalDirectives - Additionally allowed directives.
|
|
123
|
+
* @returns {{kind: string, value: string, description: string | null}|null} The parsed data of the given comment. If `null`, it is not a directive comment.
|
|
124
|
+
*/
|
|
125
|
+
parseDirectiveComment(comment, additionalDirectives) {
|
|
126
|
+
const parsed = parseDirectiveText(comment.value, additionalDirectives);
|
|
127
|
+
if (!parsed) return null;
|
|
128
|
+
const lineCommentSupported = additionalDirectives && additionalDirectives.includes(parsed.kind) || LINE_COMMENT_PATTERN.test(parsed.kind);
|
|
129
|
+
if (comment.type === "Line" && !lineCommentSupported) return null;
|
|
130
|
+
if (parsed.kind === "eslint-disable-line" && comment.loc.start.line !== comment.loc.end.line) return null;
|
|
131
|
+
return parsed;
|
|
132
|
+
},
|
|
133
|
+
parseDirectiveText,
|
|
134
|
+
getLoc
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Parse the given text as a directive comment.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} textToParse - The text to parse.
|
|
140
|
+
* @param {Set<string>} [additionalDirectives] - Additionally allowed directives.
|
|
141
|
+
* @returns {{kind: string, value: string, description: string | null}|null} The parsed data of the given comment. If `null`, it is not a directive comment.
|
|
142
|
+
*/
|
|
143
|
+
function parseDirectiveText(textToParse, additionalDirectives) {
|
|
144
|
+
const { text, description } = divideDirectiveComment(textToParse);
|
|
145
|
+
let match = DIRECTIVE_PATTERN.exec(text);
|
|
146
|
+
let eslint = false;
|
|
147
|
+
if (match) eslint = true;
|
|
148
|
+
else {
|
|
149
|
+
if (additionalDirectives && additionalDirectives.length) match = new RegExp(`^(${additionalDirectives.map((directive) => escapeStringRegexp(directive)).join("|")})(?:\\s|$)`, "u").exec(text);
|
|
150
|
+
if (!match) return null;
|
|
151
|
+
}
|
|
152
|
+
const directiveText = match[1];
|
|
153
|
+
return {
|
|
154
|
+
kind: directiveText,
|
|
155
|
+
value: text.slice(match.index + directiveText.length).trim(),
|
|
156
|
+
description,
|
|
157
|
+
eslint
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Divides and trims description text and directive comments.
|
|
162
|
+
* @param {string} value The comment text to strip.
|
|
163
|
+
* @returns {{text: string, description: string | null}} The stripped text.
|
|
164
|
+
*/
|
|
165
|
+
function divideDirectiveComment(value) {
|
|
166
|
+
const divided = value.split(/\s-{2,}\s/u);
|
|
167
|
+
return {
|
|
168
|
+
text: divided[0].trim(),
|
|
169
|
+
description: divided.length > 1 ? divided[1].trim() : null
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get source code location from the given node.
|
|
174
|
+
*
|
|
175
|
+
* @param {Partial<import("@eslint/core").RuleContext>} context - The rule context code.
|
|
176
|
+
* @param {unknown} nodeOrToken - The node or token to get.
|
|
177
|
+
* @returns {object} The source code location.
|
|
178
|
+
*/
|
|
179
|
+
function getLoc(context, nodeOrToken) {
|
|
180
|
+
const sourceCode = context.sourceCode || context.getSourceCode && context.getSourceCode();
|
|
181
|
+
return sourceCode && typeof sourceCode.getLoc === "function" ? sourceCode.getLoc(nodeOrToken) : nodeOrToken.loc;
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/internal/disabled-area.js
|
|
185
|
+
/**
|
|
186
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
187
|
+
* See LICENSE file in root directory for full license.
|
|
188
|
+
*/
|
|
189
|
+
var require_disabled_area = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
190
|
+
const utils = require_utils$1();
|
|
191
|
+
const DELIMITER = /[\s,]+/gu;
|
|
192
|
+
const pool = /* @__PURE__ */ new WeakMap();
|
|
193
|
+
var DisabledArea = class {
|
|
194
|
+
/**
|
|
195
|
+
* Constructor.
|
|
196
|
+
*/
|
|
197
|
+
constructor() {
|
|
198
|
+
this.areas = [];
|
|
199
|
+
this.duplicateDisableDirectives = [];
|
|
200
|
+
this.unusedEnableDirectives = [];
|
|
201
|
+
this.numberOfRelatedDisableDirectives = /* @__PURE__ */ new Map();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Make disabled area.
|
|
205
|
+
*
|
|
206
|
+
* @param {Token} comment - The comment token to disable.
|
|
207
|
+
* @param {object} location - The start location to disable.
|
|
208
|
+
* @param {string[]|null} ruleIds - The ruleId names to disable.
|
|
209
|
+
* @param {string} kind - The kind of disable-comments.
|
|
210
|
+
* @returns {void}
|
|
211
|
+
* @protected
|
|
212
|
+
*/
|
|
213
|
+
_disable(comment, location, ruleIds, kind) {
|
|
214
|
+
if (ruleIds) for (const ruleId of ruleIds) {
|
|
215
|
+
if (this._getArea(ruleId, location) != null) this.duplicateDisableDirectives.push({
|
|
216
|
+
comment,
|
|
217
|
+
ruleId
|
|
218
|
+
});
|
|
219
|
+
this.areas.push({
|
|
220
|
+
comment,
|
|
221
|
+
ruleId,
|
|
222
|
+
kind,
|
|
223
|
+
start: location,
|
|
224
|
+
end: null
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
if (this._getArea(null, location) != null) this.duplicateDisableDirectives.push({
|
|
229
|
+
comment,
|
|
230
|
+
ruleId: null
|
|
231
|
+
});
|
|
232
|
+
this.areas.push({
|
|
233
|
+
comment,
|
|
234
|
+
ruleId: null,
|
|
235
|
+
kind,
|
|
236
|
+
start: location,
|
|
237
|
+
end: null
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Close disabled area.
|
|
243
|
+
*
|
|
244
|
+
* @param {Token} comment - The comment token to enable.
|
|
245
|
+
* @param {object} location - The start location to enable.
|
|
246
|
+
* @param {string[]|null} ruleIds - The ruleId names to enable.
|
|
247
|
+
* @param {string} kind - The kind of disable-comments.
|
|
248
|
+
* @returns {void}
|
|
249
|
+
* @protected
|
|
250
|
+
*/
|
|
251
|
+
_enable(comment, location, ruleIds, kind) {
|
|
252
|
+
const relatedDisableDirectives = /* @__PURE__ */ new Set();
|
|
253
|
+
if (ruleIds) for (const ruleId of ruleIds) {
|
|
254
|
+
let used = false;
|
|
255
|
+
for (let i = this.areas.length - 1; i >= 0; --i) {
|
|
256
|
+
const area = this.areas[i];
|
|
257
|
+
if (area.end === null && area.kind === kind && area.ruleId === ruleId) {
|
|
258
|
+
relatedDisableDirectives.add(area.comment);
|
|
259
|
+
area.end = location;
|
|
260
|
+
used = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (!used) this.unusedEnableDirectives.push({
|
|
264
|
+
comment,
|
|
265
|
+
ruleId
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
let used = false;
|
|
270
|
+
for (let i = this.areas.length - 1; i >= 0; --i) {
|
|
271
|
+
const area = this.areas[i];
|
|
272
|
+
if (area.end === null && area.kind === kind) {
|
|
273
|
+
relatedDisableDirectives.add(area.comment);
|
|
274
|
+
area.end = location;
|
|
275
|
+
used = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!used) this.unusedEnableDirectives.push({
|
|
279
|
+
comment,
|
|
280
|
+
ruleId: null
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
this.numberOfRelatedDisableDirectives.set(comment, relatedDisableDirectives.size);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Gets the area of the given ruleId and location.
|
|
287
|
+
*
|
|
288
|
+
* @param {string|null} ruleId - The ruleId name to get.
|
|
289
|
+
* @param {object} location - The location to get.
|
|
290
|
+
* @returns {object|null} The area of the given ruleId and location.
|
|
291
|
+
* @private
|
|
292
|
+
*/
|
|
293
|
+
_getArea(ruleId, location) {
|
|
294
|
+
for (let i = this.areas.length - 1; i >= 0; --i) {
|
|
295
|
+
const area = this.areas[i];
|
|
296
|
+
if ((area.ruleId === null || area.ruleId === ruleId) && utils.lte(area.start, location) && (area.end === null || utils.lte(location, area.end))) return area;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
var DisabledAreaForLanguagePlugin = class extends DisabledArea {
|
|
302
|
+
/**
|
|
303
|
+
* Scan the source code and setup disabled area list.
|
|
304
|
+
*
|
|
305
|
+
* @param {import('@eslint/core').TextSourceCode} sourceCode - The source code to scan.
|
|
306
|
+
* @returns {void}
|
|
307
|
+
*/
|
|
308
|
+
_scan(sourceCode) {
|
|
309
|
+
const disableDirectives = sourceCode.getDisableDirectives();
|
|
310
|
+
for (const directive of disableDirectives.directives) {
|
|
311
|
+
if (![
|
|
312
|
+
"disable",
|
|
313
|
+
"enable",
|
|
314
|
+
"disable-line",
|
|
315
|
+
"disable-next-line"
|
|
316
|
+
].includes(directive.type)) continue;
|
|
317
|
+
const ruleIds = directive.value ? directive.value.split(DELIMITER) : null;
|
|
318
|
+
const loc = sourceCode.getLoc(directive.node);
|
|
319
|
+
if (directive.type === "disable") this._disable(directive.node, loc.start, ruleIds, "block");
|
|
320
|
+
else if (directive.type === "enable") this._enable(directive.node, loc.start, ruleIds, "block");
|
|
321
|
+
else if (directive.type === "disable-line") {
|
|
322
|
+
const line = loc.start.line;
|
|
323
|
+
const start = {
|
|
324
|
+
line,
|
|
325
|
+
column: 0
|
|
326
|
+
};
|
|
327
|
+
const end = {
|
|
328
|
+
line: line + 1,
|
|
329
|
+
column: -1
|
|
330
|
+
};
|
|
331
|
+
this._disable(directive.node, start, ruleIds, "line");
|
|
332
|
+
this._enable(directive.node, end, ruleIds, "line");
|
|
333
|
+
} else if (directive.type === "disable-next-line") {
|
|
334
|
+
const line = loc.start.line;
|
|
335
|
+
const start = {
|
|
336
|
+
line: line + 1,
|
|
337
|
+
column: 0
|
|
338
|
+
};
|
|
339
|
+
const end = {
|
|
340
|
+
line: line + 2,
|
|
341
|
+
column: -1
|
|
342
|
+
};
|
|
343
|
+
this._disable(directive.node, start, ruleIds, "line");
|
|
344
|
+
this._enable(directive.node, end, ruleIds, "line");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var DisabledAreaForLegacy = class extends DisabledArea {
|
|
350
|
+
/**
|
|
351
|
+
* Scan the source code and setup disabled area list.
|
|
352
|
+
*
|
|
353
|
+
* @param {eslint.SourceCode} sourceCode - The source code to scan.
|
|
354
|
+
* @returns {void}
|
|
355
|
+
*/
|
|
356
|
+
_scan(sourceCode) {
|
|
357
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
358
|
+
const directiveComment = utils.parseDirectiveComment(comment);
|
|
359
|
+
if (directiveComment == null) continue;
|
|
360
|
+
const kind = directiveComment.kind;
|
|
361
|
+
if (![
|
|
362
|
+
"eslint-disable",
|
|
363
|
+
"eslint-enable",
|
|
364
|
+
"eslint-disable-line",
|
|
365
|
+
"eslint-disable-next-line"
|
|
366
|
+
].includes(kind)) continue;
|
|
367
|
+
const ruleIds = directiveComment.value ? directiveComment.value.split(DELIMITER) : null;
|
|
368
|
+
if (kind === "eslint-disable") this._disable(comment, comment.loc.start, ruleIds, "block");
|
|
369
|
+
else if (kind === "eslint-enable") this._enable(comment, comment.loc.start, ruleIds, "block");
|
|
370
|
+
else if (kind === "eslint-disable-line") {
|
|
371
|
+
const line = comment.loc.start.line;
|
|
372
|
+
const start = {
|
|
373
|
+
line,
|
|
374
|
+
column: 0
|
|
375
|
+
};
|
|
376
|
+
const end = {
|
|
377
|
+
line: line + 1,
|
|
378
|
+
column: -1
|
|
379
|
+
};
|
|
380
|
+
this._disable(comment, start, ruleIds, "line");
|
|
381
|
+
this._enable(comment, end, ruleIds, "line");
|
|
382
|
+
} else if (kind === "eslint-disable-next-line") {
|
|
383
|
+
const line = comment.loc.start.line;
|
|
384
|
+
const start = {
|
|
385
|
+
line: line + 1,
|
|
386
|
+
column: 0
|
|
387
|
+
};
|
|
388
|
+
const end = {
|
|
389
|
+
line: line + 2,
|
|
390
|
+
column: -1
|
|
391
|
+
};
|
|
392
|
+
this._disable(comment, start, ruleIds, "line");
|
|
393
|
+
this._enable(comment, end, ruleIds, "line");
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
module.exports = {
|
|
399
|
+
/**
|
|
400
|
+
* Get singleton instance for the given rule context.
|
|
401
|
+
*
|
|
402
|
+
* @param {import("@eslint/core").RuleContext} context - The rule context code to get.
|
|
403
|
+
* @returns {DisabledArea} The singleton object for the rule context.
|
|
404
|
+
*/
|
|
405
|
+
getDisabledArea(context) {
|
|
406
|
+
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
407
|
+
let retv = pool.get(sourceCode.ast);
|
|
408
|
+
if (retv == null) {
|
|
409
|
+
retv = typeof sourceCode.getDisableDirectives === "function" ? new DisabledAreaForLanguagePlugin() : new DisabledAreaForLegacy();
|
|
410
|
+
retv._scan(sourceCode);
|
|
411
|
+
pool.set(sourceCode.ast, retv);
|
|
412
|
+
}
|
|
413
|
+
return retv;
|
|
414
|
+
} };
|
|
415
|
+
}));
|
|
416
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/disable-enable-pair.js
|
|
417
|
+
/**
|
|
418
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
419
|
+
* See LICENSE file in root directory for full license.
|
|
420
|
+
*/
|
|
421
|
+
var require_disable_enable_pair = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
422
|
+
const { getDisabledArea } = require_disabled_area();
|
|
423
|
+
const utils = require_utils$1();
|
|
424
|
+
module.exports = {
|
|
425
|
+
meta: {
|
|
426
|
+
docs: {
|
|
427
|
+
description: "require a `eslint-enable` comment for every `eslint-disable` comment",
|
|
428
|
+
category: "Best Practices",
|
|
429
|
+
recommended: true,
|
|
430
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html"
|
|
431
|
+
},
|
|
432
|
+
fixable: null,
|
|
433
|
+
messages: {
|
|
434
|
+
missingPair: "Requires 'eslint-enable' directive.",
|
|
435
|
+
missingRulePair: "Requires 'eslint-enable' directive for '{{ruleId}}'."
|
|
436
|
+
},
|
|
437
|
+
schema: [{
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: { allowWholeFile: { type: "boolean" } },
|
|
440
|
+
additionalProperties: false
|
|
441
|
+
}],
|
|
442
|
+
type: "suggestion"
|
|
443
|
+
},
|
|
444
|
+
create(context) {
|
|
445
|
+
const allowWholeFile = context.options[0] && context.options[0].allowWholeFile;
|
|
446
|
+
const disabledArea = getDisabledArea(context);
|
|
447
|
+
/** @type {import('@eslint/core').TextSourceCode} */
|
|
448
|
+
// istanbul ignore next -- ESLint < 9
|
|
449
|
+
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
450
|
+
const firstToken = sourceCode.ast && sourceCode.ast.tokens && sourceCode.ast.tokens[0];
|
|
451
|
+
if (allowWholeFile && !firstToken) return {};
|
|
452
|
+
for (const area of disabledArea.areas) {
|
|
453
|
+
if (area.end != null) continue;
|
|
454
|
+
if (allowWholeFile && utils.lte(area.start, utils.getLoc(context, firstToken).start)) continue;
|
|
455
|
+
context.report({
|
|
456
|
+
loc: utils.toRuleIdLocation(context, area.comment, area.ruleId),
|
|
457
|
+
messageId: area.ruleId ? "missingRulePair" : "missingPair",
|
|
458
|
+
data: area
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return {};
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}));
|
|
465
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-aggregating-enable.js
|
|
466
|
+
/**
|
|
467
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
468
|
+
* See LICENSE file in root directory for full license.
|
|
469
|
+
*/
|
|
470
|
+
var require_no_aggregating_enable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
471
|
+
const { getDisabledArea } = require_disabled_area();
|
|
472
|
+
const utils = require_utils$1();
|
|
473
|
+
module.exports = {
|
|
474
|
+
meta: {
|
|
475
|
+
docs: {
|
|
476
|
+
description: "disallow a `eslint-enable` comment for multiple `eslint-disable` comments",
|
|
477
|
+
category: "Best Practices",
|
|
478
|
+
recommended: true,
|
|
479
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html"
|
|
480
|
+
},
|
|
481
|
+
fixable: null,
|
|
482
|
+
messages: { aggregatingEnable: "This `eslint-enable` comment affects {{count}} `eslint-disable` comments. An `eslint-enable` comment should be for an `eslint-disable` comment." },
|
|
483
|
+
schema: [],
|
|
484
|
+
type: "suggestion"
|
|
485
|
+
},
|
|
486
|
+
create(context) {
|
|
487
|
+
const disabledArea = getDisabledArea(context);
|
|
488
|
+
for (const entry of disabledArea.numberOfRelatedDisableDirectives) {
|
|
489
|
+
const comment = entry[0];
|
|
490
|
+
const count = entry[1];
|
|
491
|
+
if (count >= 2) context.report({
|
|
492
|
+
loc: utils.toForceLocation(utils.getLoc(context, comment)),
|
|
493
|
+
messageId: "aggregatingEnable",
|
|
494
|
+
data: { count }
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return {};
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}));
|
|
501
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-duplicate-disable.js
|
|
502
|
+
/**
|
|
503
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
504
|
+
* See LICENSE file in root directory for full license.
|
|
505
|
+
*/
|
|
506
|
+
var require_no_duplicate_disable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
507
|
+
const { getDisabledArea } = require_disabled_area();
|
|
508
|
+
const utils = require_utils$1();
|
|
509
|
+
module.exports = {
|
|
510
|
+
meta: {
|
|
511
|
+
docs: {
|
|
512
|
+
description: "disallow duplicate `eslint-disable` comments",
|
|
513
|
+
category: "Best Practices",
|
|
514
|
+
recommended: true,
|
|
515
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html"
|
|
516
|
+
},
|
|
517
|
+
fixable: null,
|
|
518
|
+
messages: {
|
|
519
|
+
duplicate: "ESLint rules have been disabled already.",
|
|
520
|
+
duplicateRule: "'{{ruleId}}' rule has been disabled already."
|
|
521
|
+
},
|
|
522
|
+
schema: [],
|
|
523
|
+
type: "problem"
|
|
524
|
+
},
|
|
525
|
+
create(context) {
|
|
526
|
+
const disabledArea = getDisabledArea(context);
|
|
527
|
+
for (const item of disabledArea.duplicateDisableDirectives) context.report({
|
|
528
|
+
loc: utils.toRuleIdLocation(context, item.comment, item.ruleId),
|
|
529
|
+
messageId: item.ruleId ? "duplicateRule" : "duplicate",
|
|
530
|
+
data: item
|
|
531
|
+
});
|
|
532
|
+
return {};
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}));
|
|
536
|
+
// node_modules/.pnpm/ignore@7.0.17/node_modules/ignore/index.js
|
|
537
|
+
var require_ignore = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
538
|
+
function makeArray(subject) {
|
|
539
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
540
|
+
}
|
|
541
|
+
const UNDEFINED = void 0;
|
|
542
|
+
const EMPTY = "";
|
|
543
|
+
const SPACE = " ";
|
|
544
|
+
const ESCAPE = "\\";
|
|
545
|
+
const REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
546
|
+
const BOM = "";
|
|
547
|
+
const REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
|
|
548
|
+
const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
549
|
+
const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
550
|
+
const REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
551
|
+
const DOUBLE_SLASH = "//";
|
|
552
|
+
const SLASH_CODE = 47;
|
|
553
|
+
const DOT_CODE = 46;
|
|
554
|
+
const SLASH = "/";
|
|
555
|
+
let TMP_KEY_IGNORE = "node-ignore";
|
|
556
|
+
/* istanbul ignore else */
|
|
557
|
+
if (typeof Symbol !== "undefined") TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
558
|
+
const KEY_IGNORE = TMP_KEY_IGNORE;
|
|
559
|
+
const define = (object, key, value) => {
|
|
560
|
+
Object.defineProperty(object, key, { value });
|
|
561
|
+
return value;
|
|
562
|
+
};
|
|
563
|
+
const RETURN_FALSE = () => false;
|
|
564
|
+
const POSIX_CLASSES = {
|
|
565
|
+
alnum: "0-9A-Za-z",
|
|
566
|
+
alpha: "A-Za-z",
|
|
567
|
+
blank: " \\t",
|
|
568
|
+
cntrl: "\\x00-\\x1f\\x7f",
|
|
569
|
+
digit: "0-9",
|
|
570
|
+
graph: "!-.0-~",
|
|
571
|
+
lower: "a-z",
|
|
572
|
+
print: " -.0-~",
|
|
573
|
+
punct: "!-.:-@\\[-`{-~",
|
|
574
|
+
space: " \\t\\n\\r",
|
|
575
|
+
upper: "A-Z",
|
|
576
|
+
xdigit: "0-9A-Fa-f"
|
|
577
|
+
};
|
|
578
|
+
const CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
579
|
+
const escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
580
|
+
const NON_SLASH = "(?!\\/)";
|
|
581
|
+
const classSource = (negated, body) => {
|
|
582
|
+
if (negated) return `[^\\/${body}]`;
|
|
583
|
+
const source = `[${body}]`;
|
|
584
|
+
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
585
|
+
};
|
|
586
|
+
const scanBracket = (pattern, start) => {
|
|
587
|
+
const { length } = pattern;
|
|
588
|
+
let index = start + 1;
|
|
589
|
+
let negated = EMPTY;
|
|
590
|
+
const lead = pattern[index];
|
|
591
|
+
if (lead === "!" || lead === "^") {
|
|
592
|
+
negated = "^";
|
|
593
|
+
index++;
|
|
594
|
+
}
|
|
595
|
+
let body = EMPTY;
|
|
596
|
+
let prev = EMPTY;
|
|
597
|
+
for (;;) {
|
|
598
|
+
const char = pattern[index];
|
|
599
|
+
if (char === UNDEFINED) return null;
|
|
600
|
+
if (char === ESCAPE) {
|
|
601
|
+
const escaped = pattern[++index];
|
|
602
|
+
body += escapeMember(escaped);
|
|
603
|
+
prev = escaped;
|
|
604
|
+
} else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
|
|
605
|
+
index++;
|
|
606
|
+
let to = pattern[index];
|
|
607
|
+
if (to === ESCAPE) to = pattern[index += 1];
|
|
608
|
+
if (prev <= to) body += `-${escapeMember(to)}`;
|
|
609
|
+
prev = EMPTY;
|
|
610
|
+
} else if (char === "[" && pattern[index + 1] === ":") {
|
|
611
|
+
const nameStart = index + 2;
|
|
612
|
+
let end = nameStart;
|
|
613
|
+
while (end < length && pattern[end] !== "]") end++;
|
|
614
|
+
if (end === length) return null;
|
|
615
|
+
if (end > nameStart && pattern[end - 1] === ":") {
|
|
616
|
+
const name = pattern.slice(nameStart, end - 1);
|
|
617
|
+
if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) return null;
|
|
618
|
+
body += POSIX_CLASSES[name];
|
|
619
|
+
prev = EMPTY;
|
|
620
|
+
index = end;
|
|
621
|
+
} else {
|
|
622
|
+
body += escapeMember("[");
|
|
623
|
+
prev = "[";
|
|
624
|
+
index = nameStart - 2;
|
|
625
|
+
}
|
|
626
|
+
} else {
|
|
627
|
+
body += escapeMember(char);
|
|
628
|
+
prev = char;
|
|
629
|
+
}
|
|
630
|
+
index++;
|
|
631
|
+
if (pattern[index] === "]") return {
|
|
632
|
+
end: index,
|
|
633
|
+
source: classSource(negated, body)
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
const NEVER_MATCH = "[]";
|
|
638
|
+
const PLACEHOLDER = "\0";
|
|
639
|
+
const REGEX_RESTORE_PLACEHOLDER = new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g");
|
|
640
|
+
const TRAILING_WILDCARD = "";
|
|
641
|
+
const TRAILING_DOUBLESTAR = "";
|
|
642
|
+
const isReserved = (char) => char === PLACEHOLDER || char === TRAILING_WILDCARD || char === TRAILING_DOUBLESTAR;
|
|
643
|
+
const extractBrackets = (pattern) => {
|
|
644
|
+
const sources = [];
|
|
645
|
+
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
646
|
+
const { length } = pattern;
|
|
647
|
+
let out = EMPTY;
|
|
648
|
+
let index = 0;
|
|
649
|
+
while (index < length) {
|
|
650
|
+
const char = pattern[index];
|
|
651
|
+
if (char === ESCAPE) {
|
|
652
|
+
const escaped = pattern[index + 1];
|
|
653
|
+
if (escaped === SLASH && index + 2 === length) out += hold(NEVER_MATCH);
|
|
654
|
+
else if (escaped === "*" || escaped === "[" || escaped === SPACE) out += pattern.slice(index, index + 2);
|
|
655
|
+
else out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : isReserved(escaped) ? `[${escaped}]` : escaped);
|
|
656
|
+
index += 2;
|
|
657
|
+
} else if (isReserved(char)) {
|
|
658
|
+
out += hold(`[${char}]`);
|
|
659
|
+
index++;
|
|
660
|
+
} else if (char === "[") {
|
|
661
|
+
const scanned = scanBracket(pattern, index);
|
|
662
|
+
if (scanned === null) {
|
|
663
|
+
out += hold(NEVER_MATCH);
|
|
664
|
+
index = length;
|
|
665
|
+
} else {
|
|
666
|
+
out += hold(scanned.source);
|
|
667
|
+
index = scanned.end + 1;
|
|
668
|
+
}
|
|
669
|
+
} else {
|
|
670
|
+
out += char;
|
|
671
|
+
index++;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return {
|
|
675
|
+
source: out,
|
|
676
|
+
sources
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
const DIRECT = null;
|
|
680
|
+
const REGEX_INNER_SLASH = /\/(?!$)/;
|
|
681
|
+
const WILDCARD = "[^\\/]*";
|
|
682
|
+
const REPLACERS = [
|
|
683
|
+
[
|
|
684
|
+
/(\\+)( ?)/g,
|
|
685
|
+
(_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE : run,
|
|
686
|
+
"\\ "
|
|
687
|
+
],
|
|
688
|
+
[
|
|
689
|
+
/(^|\/)\*{3,}(?=\/|$)/g,
|
|
690
|
+
(_, start) => `${start}**`,
|
|
691
|
+
"*"
|
|
692
|
+
],
|
|
693
|
+
[/[\\$.|*+(){^]/g, (match) => `\\${match}`],
|
|
694
|
+
[
|
|
695
|
+
/(?!\\)\?/g,
|
|
696
|
+
() => "[^/]",
|
|
697
|
+
"?"
|
|
698
|
+
],
|
|
699
|
+
[
|
|
700
|
+
/^\//,
|
|
701
|
+
() => "^",
|
|
702
|
+
SLASH
|
|
703
|
+
],
|
|
704
|
+
[
|
|
705
|
+
/\//g,
|
|
706
|
+
() => "\\/",
|
|
707
|
+
SLASH
|
|
708
|
+
],
|
|
709
|
+
[
|
|
710
|
+
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
711
|
+
() => "(?:^|\\/)",
|
|
712
|
+
"*"
|
|
713
|
+
],
|
|
714
|
+
[DIRECT, (source, pattern) => {
|
|
715
|
+
if (!source || source[0] === "^" || source[0] === "(") return source;
|
|
716
|
+
return (!REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^") + source;
|
|
717
|
+
}],
|
|
718
|
+
[
|
|
719
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
720
|
+
(_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
721
|
+
"*"
|
|
722
|
+
],
|
|
723
|
+
[
|
|
724
|
+
/(^|[^\\])(?:\\\*)+(?!$)/g,
|
|
725
|
+
(_, p1) => p1 + WILDCARD,
|
|
726
|
+
"*"
|
|
727
|
+
],
|
|
728
|
+
[
|
|
729
|
+
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
730
|
+
(match, p1, p2) => p2 === EMPTY ? p1 + TRAILING_WILDCARD : match,
|
|
731
|
+
"*"
|
|
732
|
+
],
|
|
733
|
+
[
|
|
734
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
735
|
+
() => ESCAPE,
|
|
736
|
+
"\\\\"
|
|
737
|
+
],
|
|
738
|
+
[
|
|
739
|
+
/\\\\/g,
|
|
740
|
+
() => ESCAPE,
|
|
741
|
+
"\\\\"
|
|
742
|
+
],
|
|
743
|
+
[
|
|
744
|
+
/\\\[([^\]/]*?)($|\])/g,
|
|
745
|
+
(match, range, close) => `\\[${range}${close}`,
|
|
746
|
+
"["
|
|
747
|
+
],
|
|
748
|
+
[DIRECT, (source) => {
|
|
749
|
+
const last = source[source.length - 1];
|
|
750
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) return source;
|
|
751
|
+
return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
752
|
+
}]
|
|
753
|
+
];
|
|
754
|
+
const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
755
|
+
const MODE_IGNORE = "regex";
|
|
756
|
+
const MODE_CHECK_IGNORE = "checkRegex";
|
|
757
|
+
const replaceTrailingWildcard = (_, p1) => {
|
|
758
|
+
return `${p1 ? `${p1}[^/]+` : "[^/]*"}(?=$|\\/$)`;
|
|
759
|
+
};
|
|
760
|
+
const REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
761
|
+
const replaceTrailingDoublestar = () => "[\\s\\S]";
|
|
762
|
+
const separatorAfter = (run, at) => {
|
|
763
|
+
let separator = EMPTY;
|
|
764
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) separator += run[index].single;
|
|
765
|
+
return separator;
|
|
766
|
+
};
|
|
767
|
+
const pinWildcards = (source) => {
|
|
768
|
+
if (source.indexOf(WILDCARD) < 0) return source;
|
|
769
|
+
const tokens = [];
|
|
770
|
+
const { length } = source;
|
|
771
|
+
let index = 0;
|
|
772
|
+
while (index < length) {
|
|
773
|
+
const char = source[index];
|
|
774
|
+
if (source.startsWith(WILDCARD, index)) {
|
|
775
|
+
tokens.push({ wildcard: true });
|
|
776
|
+
index += 6;
|
|
777
|
+
} else if (char === "[") {
|
|
778
|
+
let end = index + 1;
|
|
779
|
+
if (source[end] === "^") end++;
|
|
780
|
+
if (source[end] === "]") end++;
|
|
781
|
+
while (end < length && source[end] !== "]") end += source[end] === ESCAPE ? 2 : 1;
|
|
782
|
+
end++;
|
|
783
|
+
tokens.push({ single: source.slice(index, end) });
|
|
784
|
+
index = end;
|
|
785
|
+
} else if (char === ESCAPE) {
|
|
786
|
+
tokens.push({ single: source.slice(index, index + 2) });
|
|
787
|
+
index += 2;
|
|
788
|
+
} else if (char === "(") {
|
|
789
|
+
let depth = 0;
|
|
790
|
+
let end = index;
|
|
791
|
+
do {
|
|
792
|
+
if (source[end] === ESCAPE) end++;
|
|
793
|
+
else if (source[end] === "(") depth++;
|
|
794
|
+
else if (source[end] === ")") depth--;
|
|
795
|
+
end++;
|
|
796
|
+
} while (end < length && depth > 0);
|
|
797
|
+
if ("*+?".indexOf(source[end]) >= 0) end++;
|
|
798
|
+
tokens.push({ boundary: source.slice(index, end) });
|
|
799
|
+
index = end;
|
|
800
|
+
} else if (char === "^" || char === "$") {
|
|
801
|
+
tokens.push({ boundary: char });
|
|
802
|
+
index++;
|
|
803
|
+
} else {
|
|
804
|
+
tokens.push({ single: char });
|
|
805
|
+
index++;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
let out = EMPTY;
|
|
809
|
+
let run = [];
|
|
810
|
+
const flush = () => {
|
|
811
|
+
let lastWildcard;
|
|
812
|
+
run.forEach((token, at) => {
|
|
813
|
+
if (token.wildcard) lastWildcard = at;
|
|
814
|
+
});
|
|
815
|
+
run.forEach((token, at) => {
|
|
816
|
+
if (!token.wildcard) {
|
|
817
|
+
out += token.single;
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
821
|
+
});
|
|
822
|
+
run = [];
|
|
823
|
+
};
|
|
824
|
+
tokens.forEach((token) => {
|
|
825
|
+
if (token.boundary === void 0) {
|
|
826
|
+
run.push(token);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
flush();
|
|
830
|
+
out += token.boundary;
|
|
831
|
+
});
|
|
832
|
+
flush();
|
|
833
|
+
return out;
|
|
834
|
+
};
|
|
835
|
+
const makeRegexPrefix = (pattern) => {
|
|
836
|
+
if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) pattern = "**";
|
|
837
|
+
const { source, sources } = extractBrackets(pattern);
|
|
838
|
+
const replaced = REPLACERS.reduce((prev, [matcher, replacer, required]) => {
|
|
839
|
+
if (matcher === DIRECT) return replacer(prev, pattern);
|
|
840
|
+
if (required !== UNDEFINED && prev.indexOf(required) < 0) return prev;
|
|
841
|
+
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
842
|
+
}, source);
|
|
843
|
+
return sources.length ? replaced.replace(REGEX_RESTORE_PLACEHOLDER, (match, index) => sources[index]) : replaced;
|
|
844
|
+
};
|
|
845
|
+
const checkSourceOf = (body, prefix) => {
|
|
846
|
+
if (body[body.length - 1] === SLASH) prefix = makeRegexPrefix(body.slice(0, -1));
|
|
847
|
+
const head = prefix.slice(0, -1);
|
|
848
|
+
const last = prefix[prefix.length - 1];
|
|
849
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? head : NEVER_MATCH;
|
|
850
|
+
};
|
|
851
|
+
const matchesBasename = (body) => {
|
|
852
|
+
const index = body.indexOf(SLASH);
|
|
853
|
+
return index < 0 || index === body.length - 1;
|
|
854
|
+
};
|
|
855
|
+
const basenameOf = (path) => {
|
|
856
|
+
const end = path.length - 1;
|
|
857
|
+
const index = path.lastIndexOf(SLASH, path[end] === SLASH ? end - 1 : end);
|
|
858
|
+
return index < 0 ? path : path.slice(index + 1);
|
|
859
|
+
};
|
|
860
|
+
const parentOf = (path) => {
|
|
861
|
+
if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
|
|
862
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
863
|
+
slices.pop();
|
|
864
|
+
return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
|
|
865
|
+
}
|
|
866
|
+
const end = path.length - 1;
|
|
867
|
+
const cut = path.lastIndexOf(SLASH, path.charCodeAt(end) === SLASH_CODE ? end - 1 : end);
|
|
868
|
+
return cut < 0 ? EMPTY : path.slice(0, cut + 1);
|
|
869
|
+
};
|
|
870
|
+
const isString = (subject) => typeof subject === "string";
|
|
871
|
+
const checkPattern = (pattern) => pattern && isString(pattern);
|
|
872
|
+
const splitPattern = (pattern) => (pattern[pattern.length - 1] === "\r" ? pattern.slice(0, -1) : pattern).split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
873
|
+
var IgnoreRule = class {
|
|
874
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
875
|
+
this.pattern = pattern;
|
|
876
|
+
this.mark = mark;
|
|
877
|
+
this.negative = negative;
|
|
878
|
+
define(this, "body", body);
|
|
879
|
+
define(this, "ignoreCase", ignoreCase);
|
|
880
|
+
define(this, "regexPrefix", prefix);
|
|
881
|
+
}
|
|
882
|
+
get _basenameOnly() {
|
|
883
|
+
return define(this, "_basenameOnly", matchesBasename(this.body));
|
|
884
|
+
}
|
|
885
|
+
get regex() {
|
|
886
|
+
const key = "_regex";
|
|
887
|
+
if (this[key]) return this[key];
|
|
888
|
+
return this._make(MODE_IGNORE, key);
|
|
889
|
+
}
|
|
890
|
+
get checkRegex() {
|
|
891
|
+
const key = "_checkRegex";
|
|
892
|
+
if (this[key]) return this[key];
|
|
893
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
894
|
+
}
|
|
895
|
+
_make(mode, key) {
|
|
896
|
+
const str = pinWildcards(mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix));
|
|
897
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
898
|
+
return define(this, key, regex);
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
const hasTrailingBackslash = (str) => {
|
|
902
|
+
let count = 0;
|
|
903
|
+
while (str[str.length - count - 1] === ESCAPE) count++;
|
|
904
|
+
return count % 2 === 1;
|
|
905
|
+
};
|
|
906
|
+
const trimEnd = (body, stripLineEnd) => {
|
|
907
|
+
let lineEnd = body.length;
|
|
908
|
+
let end;
|
|
909
|
+
for (;;) {
|
|
910
|
+
if (stripLineEnd && body[lineEnd - 1] === "\r") lineEnd--;
|
|
911
|
+
end = lineEnd;
|
|
912
|
+
while (body[end - 1] === SPACE) end--;
|
|
913
|
+
if (!stripLineEnd || body[end - 1] !== "\n") break;
|
|
914
|
+
lineEnd = end - 1;
|
|
915
|
+
}
|
|
916
|
+
if (end === lineEnd) return body.slice(0, lineEnd);
|
|
917
|
+
let backslashes = 0;
|
|
918
|
+
while (body[end - backslashes - 1] === ESCAPE) backslashes++;
|
|
919
|
+
return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
|
|
920
|
+
};
|
|
921
|
+
const createRule = (pattern, mark, ignoreCase, stripLineEnd, stripBOM) => {
|
|
922
|
+
let body = stripBOM && pattern[0] === BOM ? pattern.slice(1) : pattern;
|
|
923
|
+
if (body[0] === "#") return;
|
|
924
|
+
let negative = false;
|
|
925
|
+
if (body[0] === "!") {
|
|
926
|
+
negative = true;
|
|
927
|
+
body = body.slice(1);
|
|
928
|
+
}
|
|
929
|
+
const last = body[body.length - 1];
|
|
930
|
+
if (last === SPACE || stripLineEnd && (last === "\r" || last === "\n")) body = trimEnd(body, stripLineEnd);
|
|
931
|
+
if (!body || hasTrailingBackslash(body)) return;
|
|
932
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
933
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
934
|
+
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
935
|
+
};
|
|
936
|
+
var RuleManager = class {
|
|
937
|
+
constructor(ignoreCase) {
|
|
938
|
+
this._ignoreCase = ignoreCase;
|
|
939
|
+
this._rules = [];
|
|
940
|
+
this._basenameCount = 0;
|
|
941
|
+
}
|
|
942
|
+
_add(pattern, index) {
|
|
943
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
944
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
945
|
+
this._basenameCount += pattern._rules._basenameCount;
|
|
946
|
+
this._added = true;
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const isStr = isString(pattern);
|
|
950
|
+
const raw = isStr ? pattern : pattern.pattern;
|
|
951
|
+
const rule = checkPattern(raw) && createRule(raw, isStr ? UNDEFINED : pattern.mark, this._ignoreCase, !this._split, this._stripBOM && !index);
|
|
952
|
+
if (rule) {
|
|
953
|
+
this._added = true;
|
|
954
|
+
this._rules.push(rule);
|
|
955
|
+
if (matchesBasename(rule.body)) this._basenameCount++;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
add(pattern) {
|
|
959
|
+
this._added = false;
|
|
960
|
+
this._split = isString(pattern);
|
|
961
|
+
this._stripBOM = !this._split || pattern[0] === BOM;
|
|
962
|
+
makeArray(this._split ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
963
|
+
if (this._added) this._literalRules = UNDEFINED;
|
|
964
|
+
return this._added;
|
|
965
|
+
}
|
|
966
|
+
testLiteral(path) {
|
|
967
|
+
const rules = this._literalRules || (this._literalRules = this._rules.filter(({ body }) => body[body.length - (body[body.length - 1] === SLASH ? 2 : 1)] === "*"));
|
|
968
|
+
let ignored = false;
|
|
969
|
+
let unignored = false;
|
|
970
|
+
let matchedRule;
|
|
971
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
972
|
+
const rule = rules[index];
|
|
973
|
+
if (rule.checkRegex.test(path)) {
|
|
974
|
+
ignored = !rule.negative;
|
|
975
|
+
unignored = rule.negative;
|
|
976
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
const ret = {
|
|
981
|
+
ignored,
|
|
982
|
+
unignored
|
|
983
|
+
};
|
|
984
|
+
if (matchedRule) ret.rule = matchedRule;
|
|
985
|
+
return ret;
|
|
986
|
+
}
|
|
987
|
+
test(path, mode) {
|
|
988
|
+
const rules = this._rules;
|
|
989
|
+
const { length } = rules;
|
|
990
|
+
const shortcut = this._basenameCount * 2 >= length;
|
|
991
|
+
const basename = shortcut ? basenameOf(path) : path;
|
|
992
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
993
|
+
const rule = rules[index];
|
|
994
|
+
if (rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
|
|
995
|
+
const { negative } = rule;
|
|
996
|
+
const ret = {
|
|
997
|
+
ignored: !negative,
|
|
998
|
+
unignored: negative
|
|
999
|
+
};
|
|
1000
|
+
if (!negative) ret.rule = rule;
|
|
1001
|
+
return ret;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
return {
|
|
1005
|
+
ignored: false,
|
|
1006
|
+
unignored: false
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
const throwError = (message, Ctor) => {
|
|
1011
|
+
throw new Ctor(message);
|
|
1012
|
+
};
|
|
1013
|
+
const checkPath = (path, originalPath, doThrow) => {
|
|
1014
|
+
if (!isString(path)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
1015
|
+
if (!path) return doThrow(`path must not be empty`, TypeError);
|
|
1016
|
+
if (checkPath.isNotRelative(path)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
1017
|
+
return true;
|
|
1018
|
+
};
|
|
1019
|
+
const isNotRelative = (path) => {
|
|
1020
|
+
const first = path.charCodeAt(0);
|
|
1021
|
+
if (first === SLASH_CODE) return true;
|
|
1022
|
+
if (first !== DOT_CODE) return false;
|
|
1023
|
+
if (path.length === 1) return true;
|
|
1024
|
+
const second = path.charCodeAt(1);
|
|
1025
|
+
if (second === SLASH_CODE) return true;
|
|
1026
|
+
if (second !== DOT_CODE) return false;
|
|
1027
|
+
return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
|
|
1028
|
+
};
|
|
1029
|
+
checkPath.isNotRelative = isNotRelative;
|
|
1030
|
+
/* istanbul ignore next */
|
|
1031
|
+
checkPath.convert = (p) => p;
|
|
1032
|
+
const convertPath = (target) => isString(target) && checkPath.convert(target);
|
|
1033
|
+
var Ignore = class {
|
|
1034
|
+
constructor({ ignorecase = true, ignoreCase = ignorecase, allowRelativePaths = false } = {}) {
|
|
1035
|
+
define(this, KEY_IGNORE, true);
|
|
1036
|
+
this._rules = new RuleManager(ignoreCase);
|
|
1037
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
1038
|
+
this._initCache();
|
|
1039
|
+
}
|
|
1040
|
+
_initCache() {
|
|
1041
|
+
this._ignoreCache = Object.create(null);
|
|
1042
|
+
this._testCache = Object.create(null);
|
|
1043
|
+
}
|
|
1044
|
+
add(pattern) {
|
|
1045
|
+
if (this._rules.add(pattern)) this._initCache();
|
|
1046
|
+
return this;
|
|
1047
|
+
}
|
|
1048
|
+
addPattern(pattern) {
|
|
1049
|
+
return this.add(pattern);
|
|
1050
|
+
}
|
|
1051
|
+
_test(originalPath, cache, path) {
|
|
1052
|
+
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
1053
|
+
return path ? this._t(path, cache) : {
|
|
1054
|
+
ignored: false,
|
|
1055
|
+
unignored: false
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
checkIgnore(target) {
|
|
1059
|
+
const path = convertPath(target);
|
|
1060
|
+
if (!path || path.charCodeAt(path.length - 1) !== SLASH_CODE) return this._test(target, this._testCache, path);
|
|
1061
|
+
const dir = this._t(path, this._testCache);
|
|
1062
|
+
if (dir.ignored) return dir;
|
|
1063
|
+
const literal = this._rules.testLiteral(path);
|
|
1064
|
+
return literal.ignored || literal.unignored ? literal : dir;
|
|
1065
|
+
}
|
|
1066
|
+
_t(path, cache) {
|
|
1067
|
+
const cached = cache[path];
|
|
1068
|
+
if (cached) return cached;
|
|
1069
|
+
const parentPath = parentOf(path);
|
|
1070
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
1071
|
+
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, MODE_IGNORE);
|
|
1072
|
+
}
|
|
1073
|
+
ignores(path) {
|
|
1074
|
+
return this._test(path, this._ignoreCache, convertPath(path)).ignored;
|
|
1075
|
+
}
|
|
1076
|
+
createFilter() {
|
|
1077
|
+
return (path) => !this.ignores(path);
|
|
1078
|
+
}
|
|
1079
|
+
filter(paths) {
|
|
1080
|
+
return makeArray(paths).filter(this.createFilter());
|
|
1081
|
+
}
|
|
1082
|
+
test(path) {
|
|
1083
|
+
return this._test(path, this._testCache, convertPath(path));
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
const factory = (options) => new Ignore(options);
|
|
1087
|
+
const isPathValid = (path) => checkPath(convertPath(path), path, RETURN_FALSE);
|
|
1088
|
+
/* istanbul ignore next */
|
|
1089
|
+
const setupWindows = () => {
|
|
1090
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
1091
|
+
checkPath.convert = makePosix;
|
|
1092
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
1093
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
1094
|
+
};
|
|
1095
|
+
/* istanbul ignore next */
|
|
1096
|
+
if (typeof process !== "undefined" && process.platform === "win32") setupWindows();
|
|
1097
|
+
module.exports = factory;
|
|
1098
|
+
factory.default = factory;
|
|
1099
|
+
module.exports.isPathValid = isPathValid;
|
|
1100
|
+
define(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
1101
|
+
}));
|
|
1102
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-restricted-disable.js
|
|
1103
|
+
/**
|
|
1104
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1105
|
+
* See LICENSE file in root directory for full license.
|
|
1106
|
+
*/
|
|
1107
|
+
var require_no_restricted_disable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1108
|
+
const ignore = require_ignore();
|
|
1109
|
+
const { getDisabledArea } = require_disabled_area();
|
|
1110
|
+
const utils = require_utils$1();
|
|
1111
|
+
module.exports = {
|
|
1112
|
+
meta: {
|
|
1113
|
+
docs: {
|
|
1114
|
+
description: "disallow `eslint-disable` comments about specific rules",
|
|
1115
|
+
category: "Stylistic Issues",
|
|
1116
|
+
recommended: false,
|
|
1117
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html"
|
|
1118
|
+
},
|
|
1119
|
+
fixable: null,
|
|
1120
|
+
messages: { disallow: "Disabling '{{ruleId}}' is not allowed." },
|
|
1121
|
+
schema: {
|
|
1122
|
+
type: "array",
|
|
1123
|
+
items: { type: "string" },
|
|
1124
|
+
uniqueItems: true
|
|
1125
|
+
},
|
|
1126
|
+
type: "suggestion"
|
|
1127
|
+
},
|
|
1128
|
+
create(context) {
|
|
1129
|
+
const disabledArea = getDisabledArea(context);
|
|
1130
|
+
if (context.options.length === 0) return {};
|
|
1131
|
+
const ig = ignore();
|
|
1132
|
+
for (const pattern of context.options) ig.add(pattern);
|
|
1133
|
+
for (const area of disabledArea.areas) if (area.ruleId == null || ig.ignores(area.ruleId)) context.report({
|
|
1134
|
+
loc: utils.toRuleIdLocation(context, area.comment, area.ruleId),
|
|
1135
|
+
messageId: "disallow",
|
|
1136
|
+
data: { ruleId: area.ruleId || String(context.options) }
|
|
1137
|
+
});
|
|
1138
|
+
return {};
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
}));
|
|
1142
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/internal/get-all-directive-comments.js
|
|
1143
|
+
var require_get_all_directive_comments = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1144
|
+
const utils = require_utils$1();
|
|
1145
|
+
/**
|
|
1146
|
+
* @typedef {object} DirectiveComment
|
|
1147
|
+
* @property {string} kind The kind of directive comment.
|
|
1148
|
+
* @property {string} [value] The directive value if it is `eslint-` comment.
|
|
1149
|
+
* @property {string} description The description of the directive comment.
|
|
1150
|
+
* @property {object} node The node of the directive comment.
|
|
1151
|
+
* @property {boolean} eslint Whether this is an ESLint directive or not.
|
|
1152
|
+
* @property {import("@eslint/core").SourceRange} range The range of the directive comment.
|
|
1153
|
+
* @property {import("@eslint/core").SourceLocation} loc The location of the directive comment.
|
|
1154
|
+
*/
|
|
1155
|
+
const pool = /* @__PURE__ */ new WeakMap();
|
|
1156
|
+
/**
|
|
1157
|
+
* Build a stable cache key for an `additionalDirectives` list. Order and
|
|
1158
|
+
* duplicates do not affect the parse result, so they are normalized away
|
|
1159
|
+
* to let equivalent lists share a cache entry.
|
|
1160
|
+
*
|
|
1161
|
+
* @param {string[]} [additionalDirectives] - Additionally allowed directives.
|
|
1162
|
+
* @returns {string} The cache key (`""` when there are no additional directives).
|
|
1163
|
+
*/
|
|
1164
|
+
function toAdditionalDirectivesCacheKey(additionalDirectives) {
|
|
1165
|
+
return additionalDirectives && additionalDirectives.length ? JSON.stringify([...new Set(additionalDirectives)].sort()) : "";
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* @param {import('eslint').SourceCode} sourceCode - The source code to scan.
|
|
1169
|
+
* @param {string[]} [additionalDirectives] - Additionally allowed directives.
|
|
1170
|
+
* @returns {DirectiveComment[]} The directive comments.
|
|
1171
|
+
*/
|
|
1172
|
+
function getAllDirectiveCommentsFromAllComments(sourceCode, additionalDirectives) {
|
|
1173
|
+
return (sourceCode.getAllComments ? sourceCode.getAllComments() : sourceCode.comments || sourceCode.ast && sourceCode.ast.comments ||
|
|
1174
|
+
// istanbul ignore next -- Non-JS whose comments we cannot detect
|
|
1175
|
+
[]).map((comment) => ({
|
|
1176
|
+
comment,
|
|
1177
|
+
directiveComment: utils.parseDirectiveComment(comment, additionalDirectives)
|
|
1178
|
+
})).filter(({ directiveComment }) => Boolean(directiveComment)).map(({ comment, directiveComment }) => ({
|
|
1179
|
+
kind: directiveComment.kind,
|
|
1180
|
+
value: directiveComment.value,
|
|
1181
|
+
description: directiveComment.description,
|
|
1182
|
+
eslint: directiveComment.eslint,
|
|
1183
|
+
node: comment,
|
|
1184
|
+
range: comment.range,
|
|
1185
|
+
loc: comment.loc
|
|
1186
|
+
}));
|
|
1187
|
+
}
|
|
1188
|
+
// istanbul ignore next 72 -- ESLint 9+
|
|
1189
|
+
/**
|
|
1190
|
+
* @param {import('@eslint/core').TextSourceCode} sourceCode - The source code to scan.
|
|
1191
|
+
* @returns {DirectiveComment[]} The directive comments.
|
|
1192
|
+
*/
|
|
1193
|
+
function getAllDirectiveCommentsFromInlineConfigNodes(sourceCode) {
|
|
1194
|
+
const result = sourceCode.getDisableDirectives().directives.map((directive) => ({
|
|
1195
|
+
kind: `eslint-${directive.type}`,
|
|
1196
|
+
value: directive.value,
|
|
1197
|
+
description: directive.justification,
|
|
1198
|
+
node: directive.node,
|
|
1199
|
+
range: sourceCode.getRange(directive.node),
|
|
1200
|
+
eslint: true,
|
|
1201
|
+
get loc() {
|
|
1202
|
+
return sourceCode.getLoc(directive.node);
|
|
1203
|
+
}
|
|
1204
|
+
}));
|
|
1205
|
+
return result.concat(sourceCode.getInlineConfigNodes().map((node) => ({
|
|
1206
|
+
node,
|
|
1207
|
+
range: sourceCode.getRange(node)
|
|
1208
|
+
})).filter(({ range }) => !result.some((comment) => comment.range[0] <= range[1] && range[0] <= comment.range[1])).map(({ node, range }) => {
|
|
1209
|
+
const commentValue = extractCommentContent(sourceCode.text.slice(range[0], range[1]));
|
|
1210
|
+
return {
|
|
1211
|
+
directiveComment: utils.parseDirectiveText(commentValue),
|
|
1212
|
+
node,
|
|
1213
|
+
range
|
|
1214
|
+
};
|
|
1215
|
+
}).filter(({ directiveComment }) => directiveComment != null && ![
|
|
1216
|
+
"eslint-disable",
|
|
1217
|
+
"eslint-disable-line",
|
|
1218
|
+
"eslint-disable-next-line",
|
|
1219
|
+
"eslint-enable"
|
|
1220
|
+
].includes(directiveComment.kind)).map(({ directiveComment, node, range }) => ({
|
|
1221
|
+
kind: directiveComment.kind,
|
|
1222
|
+
value: directiveComment.value,
|
|
1223
|
+
description: directiveComment.description,
|
|
1224
|
+
node,
|
|
1225
|
+
range,
|
|
1226
|
+
get loc() {
|
|
1227
|
+
return sourceCode.getLoc(node);
|
|
1228
|
+
}
|
|
1229
|
+
})));
|
|
1230
|
+
}
|
|
1231
|
+
// istanbul ignore next 16 -- ESLint 9+
|
|
1232
|
+
function extractCommentContent(text) {
|
|
1233
|
+
return text.startsWith("/*") && text.endsWith("*/") ? text.slice(2, -2) : text.startsWith("//") ? text.slice(2) : text.startsWith("<!--") && text.endsWith("-->") ? text.slice(4, -3) : text.startsWith("###") && text.endsWith("###") ? text.slice(3, -3) : text.startsWith("#") ? text.slice(1) : text;
|
|
1234
|
+
}
|
|
1235
|
+
module.exports = {
|
|
1236
|
+
/**
|
|
1237
|
+
* Get all directive comments for the given rule context.
|
|
1238
|
+
*
|
|
1239
|
+
* @param {import("@eslint/core").RuleContext} context - The rule context to get.
|
|
1240
|
+
* @param {string[]} [additionalDirectives] - Additionally allowed directives.
|
|
1241
|
+
* @returns {DirectiveComment[]} The all directive comments object for the rule context.
|
|
1242
|
+
*/
|
|
1243
|
+
getAllDirectiveComments(context, additionalDirectives) {
|
|
1244
|
+
// istanbul ignore next -- ESLint < 8
|
|
1245
|
+
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
1246
|
+
let astCache = pool.get(sourceCode.ast);
|
|
1247
|
+
if (astCache == null) {
|
|
1248
|
+
astCache = /* @__PURE__ */ new Map();
|
|
1249
|
+
pool.set(sourceCode.ast, astCache);
|
|
1250
|
+
}
|
|
1251
|
+
const cacheKey = toAdditionalDirectivesCacheKey(additionalDirectives);
|
|
1252
|
+
let result = astCache.get(cacheKey);
|
|
1253
|
+
if (result == null) {
|
|
1254
|
+
result = typeof sourceCode.getInlineConfigNodes === "function" && typeof sourceCode.getDisableDirectives === "function" && (!sourceCode.getAllComments && !sourceCode.comments && (!sourceCode.ast || !sourceCode.ast.comments) || (!additionalDirectives || !additionalDirectives.length) &&
|
|
1255
|
+
// istanbul ignore next -- For JS API, we want ESLint-specific messages
|
|
1256
|
+
!sourceCode.getAllComments) ? getAllDirectiveCommentsFromInlineConfigNodes(sourceCode) : getAllDirectiveCommentsFromAllComments(sourceCode, additionalDirectives);
|
|
1257
|
+
astCache.set(cacheKey, result);
|
|
1258
|
+
}
|
|
1259
|
+
return result;
|
|
1260
|
+
} };
|
|
1261
|
+
}));
|
|
1262
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-unlimited-disable.js
|
|
1263
|
+
/**
|
|
1264
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1265
|
+
* See LICENSE file in root directory for full license.
|
|
1266
|
+
*/
|
|
1267
|
+
var require_no_unlimited_disable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1268
|
+
const { getAllDirectiveComments } = require_get_all_directive_comments();
|
|
1269
|
+
const utils = require_utils$1();
|
|
1270
|
+
module.exports = {
|
|
1271
|
+
meta: {
|
|
1272
|
+
docs: {
|
|
1273
|
+
description: "disallow `eslint-disable` comments without rule names",
|
|
1274
|
+
category: "Best Practices",
|
|
1275
|
+
recommended: true,
|
|
1276
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html"
|
|
1277
|
+
},
|
|
1278
|
+
fixable: null,
|
|
1279
|
+
messages: { unexpected: "Unexpected unlimited '{{kind}}' comment. Specify some rule names to disable." },
|
|
1280
|
+
schema: [],
|
|
1281
|
+
type: "suggestion"
|
|
1282
|
+
},
|
|
1283
|
+
create(context) {
|
|
1284
|
+
for (const directiveComment of getAllDirectiveComments(context)) {
|
|
1285
|
+
const kind = directiveComment.kind;
|
|
1286
|
+
if (kind !== "eslint-disable" && kind !== "eslint-disable-line" && kind !== "eslint-disable-next-line") continue;
|
|
1287
|
+
if (!directiveComment.value) context.report({
|
|
1288
|
+
loc: utils.toForceLocation(directiveComment.loc),
|
|
1289
|
+
messageId: "unexpected",
|
|
1290
|
+
data: { kind: directiveComment.kind }
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
return {};
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
}));
|
|
1297
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/internal/get-linters.js
|
|
1298
|
+
/**
|
|
1299
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1300
|
+
* See LICENSE file in root directory for full license.
|
|
1301
|
+
*/
|
|
1302
|
+
var require_get_linters = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1303
|
+
const path = __require("path");
|
|
1304
|
+
const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}`;
|
|
1305
|
+
module.exports = () => {
|
|
1306
|
+
const eslintPaths = new Set(Object.keys(__require.cache).filter((id) => id.includes(needle)).map((id) => id.slice(0, id.indexOf(needle) + needle.length)));
|
|
1307
|
+
const linters = [];
|
|
1308
|
+
for (const eslintPath of eslintPaths) try {
|
|
1309
|
+
const linter = __require(eslintPath).Linter;
|
|
1310
|
+
if (linter) linters.push(linter);
|
|
1311
|
+
} catch (error) {
|
|
1312
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
1313
|
+
}
|
|
1314
|
+
return linters;
|
|
1315
|
+
};
|
|
1316
|
+
}));
|
|
1317
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/utils/patch.js
|
|
1318
|
+
/**
|
|
1319
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1320
|
+
* See LICENSE file in root directory for full license.
|
|
1321
|
+
*/
|
|
1322
|
+
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1323
|
+
const getLinters = require_get_linters();
|
|
1324
|
+
const { toRuleIdLocation } = require_utils$1();
|
|
1325
|
+
const quotedName = /'(.+?)'/u;
|
|
1326
|
+
/**
|
|
1327
|
+
* Get the severity of a given rule.
|
|
1328
|
+
* @param {object} config The config object to check.
|
|
1329
|
+
* @param {string} ruleId The rule ID to check.
|
|
1330
|
+
* @returns {number} The severity of the rule.
|
|
1331
|
+
*/
|
|
1332
|
+
function getSeverity(config, ruleId) {
|
|
1333
|
+
const rules = config && config.rules;
|
|
1334
|
+
const ruleOptions = rules && rules[ruleId];
|
|
1335
|
+
switch (Array.isArray(ruleOptions) ? ruleOptions[0] : ruleOptions) {
|
|
1336
|
+
case 2:
|
|
1337
|
+
case "error": return 2;
|
|
1338
|
+
case 1:
|
|
1339
|
+
case "warn": return 1;
|
|
1340
|
+
default: return 0;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Get the comment which is at a given message location.
|
|
1345
|
+
* @param {Message} message The message to get.
|
|
1346
|
+
* @param {SourceCode|undefined} sourceCode The source code object to get.
|
|
1347
|
+
* @returns {Comment|undefined} The gotten comment.
|
|
1348
|
+
*/
|
|
1349
|
+
function getCommentAt(message, sourceCode) {
|
|
1350
|
+
if (sourceCode != null) {
|
|
1351
|
+
const loc = {
|
|
1352
|
+
line: message.line,
|
|
1353
|
+
column: message.column - 1
|
|
1354
|
+
};
|
|
1355
|
+
const index = sourceCode.getIndexFromLoc(loc);
|
|
1356
|
+
const comment = sourceCode.getTokenByRangeStart(index, { includeComments: true });
|
|
1357
|
+
if (comment != null && (comment.type === "Line" || comment.type === "Block")) return comment;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Check whether a given message is a `reportUnusedDisableDirectives` error.
|
|
1362
|
+
* @param {Message} message The message.
|
|
1363
|
+
* @returns {boolean} `true` if the message is a `reportUnusedDisableDirectives` error.
|
|
1364
|
+
*/
|
|
1365
|
+
function isUnusedDisableDirectiveError(message) {
|
|
1366
|
+
return !message.fatal && !message.ruleId && message.message.includes("eslint-disable");
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Create `@eslint-community/eslint-comments/no-unused-disable` error.
|
|
1370
|
+
* @param {string} ruleId The ruleId.
|
|
1371
|
+
* @param {number} severity The severity of the rule.
|
|
1372
|
+
* @param {Message} message The original message.
|
|
1373
|
+
* @param {Comment|undefined} comment The directive comment.
|
|
1374
|
+
* @returns {Message} The created error.
|
|
1375
|
+
*/
|
|
1376
|
+
function createNoUnusedDisableError(ruleId, severity, message, comment) {
|
|
1377
|
+
const clone = Object.assign({}, message);
|
|
1378
|
+
const match = quotedName.exec(message.message);
|
|
1379
|
+
const targetRuleId = match && match[1];
|
|
1380
|
+
clone.ruleId = ruleId;
|
|
1381
|
+
clone.severity = severity;
|
|
1382
|
+
clone.message = targetRuleId ? `'${targetRuleId}' rule is disabled but never reported.` : "ESLint rules are disabled but never reported.";
|
|
1383
|
+
clone.suggestions = [];
|
|
1384
|
+
if (comment != null) {
|
|
1385
|
+
if (targetRuleId) {
|
|
1386
|
+
const loc = toRuleIdLocation({}, comment, targetRuleId);
|
|
1387
|
+
clone.line = loc.start.line;
|
|
1388
|
+
clone.column = loc.start.column + 1;
|
|
1389
|
+
clone.endLine = loc.end.line;
|
|
1390
|
+
clone.endColumn = loc.end.column + 1;
|
|
1391
|
+
} else {
|
|
1392
|
+
clone.endLine = comment.loc.end.line;
|
|
1393
|
+
clone.endColumn = comment.loc.end.column + 1;
|
|
1394
|
+
}
|
|
1395
|
+
if (!comment.value.includes(",") && !comment.value.includes("--")) clone.suggestions = [{
|
|
1396
|
+
desc: "Remove `eslint-disable` comment.",
|
|
1397
|
+
fix: {
|
|
1398
|
+
range: comment.range,
|
|
1399
|
+
text: comment.value.includes("\n") ? "\n" : ""
|
|
1400
|
+
}
|
|
1401
|
+
}];
|
|
1402
|
+
}
|
|
1403
|
+
return clone;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Convert `reportUnusedDisableDirectives` errors to `@eslint-community/eslint-comments/no-unused-disable` errors.
|
|
1407
|
+
* @param {Message[]} messages The original messages.
|
|
1408
|
+
* @param {SourceCode|undefined} sourceCode The source code object.
|
|
1409
|
+
* @param {string} ruleId The rule ID to convert.
|
|
1410
|
+
* @param {number} severity The severity of the rule.
|
|
1411
|
+
* @param {boolean} keepAsIs The flag to keep original errors as is.
|
|
1412
|
+
* @returns {Message[]} The converted messages.
|
|
1413
|
+
*/
|
|
1414
|
+
function convert(messages, sourceCode, ruleId, severity, keepAsIs) {
|
|
1415
|
+
for (let i = messages.length - 1; i >= 0; --i) {
|
|
1416
|
+
const message = messages[i];
|
|
1417
|
+
if (!isUnusedDisableDirectiveError(message)) continue;
|
|
1418
|
+
const newMessage = createNoUnusedDisableError(ruleId, severity, message, getCommentAt(message, sourceCode));
|
|
1419
|
+
if (keepAsIs) messages.splice(i + 1, 0, newMessage);
|
|
1420
|
+
else messages.splice(i, 1, newMessage);
|
|
1421
|
+
}
|
|
1422
|
+
return messages;
|
|
1423
|
+
}
|
|
1424
|
+
module.exports = (ruleId = "@eslint-community/eslint-comments/no-unused-disable") => {
|
|
1425
|
+
for (const Linter of getLinters()) {
|
|
1426
|
+
const verify0 = Linter.prototype._verifyWithoutProcessors;
|
|
1427
|
+
Object.defineProperty(Linter.prototype, "_verifyWithoutProcessors", {
|
|
1428
|
+
value: function _verifyWithoutProcessors(textOrSourceCode, config, filenameOrOptions) {
|
|
1429
|
+
const severity = getSeverity(config, ruleId);
|
|
1430
|
+
if (severity === 0) return verify0.call(this, textOrSourceCode, config, filenameOrOptions);
|
|
1431
|
+
const options = typeof filenameOrOptions === "string" ? { filename: filenameOrOptions } : filenameOrOptions || {};
|
|
1432
|
+
const reportUnusedDisableDirectives = Boolean(options.reportUnusedDisableDirectives);
|
|
1433
|
+
return convert(verify0.call(this, textOrSourceCode, config, Object.assign({}, options, { reportUnusedDisableDirectives: true })), this.getSourceCode(), ruleId, severity, reportUnusedDisableDirectives);
|
|
1434
|
+
},
|
|
1435
|
+
configurable: true,
|
|
1436
|
+
writable: true
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
}));
|
|
1441
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-unused-disable.js
|
|
1442
|
+
/**
|
|
1443
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1444
|
+
* See LICENSE file in root directory for full license.
|
|
1445
|
+
*/
|
|
1446
|
+
var require_no_unused_disable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1447
|
+
require_patch()();
|
|
1448
|
+
module.exports = {
|
|
1449
|
+
meta: {
|
|
1450
|
+
/** @type {import("@eslint/core").DeprecatedInfo} */
|
|
1451
|
+
deprecated: {
|
|
1452
|
+
availableUntil: "5.0.0",
|
|
1453
|
+
deprecatedSince: "4.7.0",
|
|
1454
|
+
message: "ESLint now has built-in functionality to report unused `eslint-disable` comments",
|
|
1455
|
+
replacedBy: [{
|
|
1456
|
+
message: "You can now use ESLint's built-in `linterOptions.reportUnusedDisabledDirectives` to report unused `eslint-disable` comments",
|
|
1457
|
+
url: "https://eslint.org/docs/latest/use/configure/configuration-files#reporting-unused-disable-directives"
|
|
1458
|
+
}]
|
|
1459
|
+
},
|
|
1460
|
+
docs: {
|
|
1461
|
+
description: "disallow unused `eslint-disable` comments",
|
|
1462
|
+
category: "Best Practices",
|
|
1463
|
+
recommended: false,
|
|
1464
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html"
|
|
1465
|
+
},
|
|
1466
|
+
fixable: null,
|
|
1467
|
+
messages: {},
|
|
1468
|
+
schema: [],
|
|
1469
|
+
type: "problem"
|
|
1470
|
+
},
|
|
1471
|
+
create() {
|
|
1472
|
+
return {};
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
}));
|
|
1476
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-unused-enable.js
|
|
1477
|
+
/**
|
|
1478
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1479
|
+
* See LICENSE file in root directory for full license.
|
|
1480
|
+
*/
|
|
1481
|
+
var require_no_unused_enable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1482
|
+
const { getDisabledArea } = require_disabled_area();
|
|
1483
|
+
const utils = require_utils$1();
|
|
1484
|
+
module.exports = {
|
|
1485
|
+
meta: {
|
|
1486
|
+
docs: {
|
|
1487
|
+
description: "disallow unused `eslint-enable` comments",
|
|
1488
|
+
category: "Best Practices",
|
|
1489
|
+
recommended: true,
|
|
1490
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html"
|
|
1491
|
+
},
|
|
1492
|
+
fixable: null,
|
|
1493
|
+
messages: {
|
|
1494
|
+
unused: "ESLint rules are re-enabled but those have not been disabled.",
|
|
1495
|
+
unusedRule: "'{{ruleId}}' rule is re-enabled but it has not been disabled."
|
|
1496
|
+
},
|
|
1497
|
+
schema: [],
|
|
1498
|
+
type: "problem"
|
|
1499
|
+
},
|
|
1500
|
+
create(context) {
|
|
1501
|
+
const disabledArea = getDisabledArea(context);
|
|
1502
|
+
for (const item of disabledArea.unusedEnableDirectives) context.report({
|
|
1503
|
+
loc: utils.toRuleIdLocation(context, item.comment, item.ruleId),
|
|
1504
|
+
messageId: item.ruleId ? "unusedRule" : "unused",
|
|
1505
|
+
data: item
|
|
1506
|
+
});
|
|
1507
|
+
return {};
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
}));
|
|
1511
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/no-use.js
|
|
1512
|
+
/**
|
|
1513
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
1514
|
+
* See LICENSE file in root directory for full license.
|
|
1515
|
+
*/
|
|
1516
|
+
var require_no_use = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1517
|
+
const { getAllDirectiveComments } = require_get_all_directive_comments();
|
|
1518
|
+
const utils = require_utils$1();
|
|
1519
|
+
module.exports = {
|
|
1520
|
+
meta: {
|
|
1521
|
+
docs: {
|
|
1522
|
+
description: "disallow ESLint directive-comments",
|
|
1523
|
+
category: "Stylistic Issues",
|
|
1524
|
+
recommended: false,
|
|
1525
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-use.html"
|
|
1526
|
+
},
|
|
1527
|
+
fixable: null,
|
|
1528
|
+
messages: {
|
|
1529
|
+
disallowEslint: "Unexpected ESLint directive comment.",
|
|
1530
|
+
disallow: "Unexpected directive comment."
|
|
1531
|
+
},
|
|
1532
|
+
schema: [{
|
|
1533
|
+
type: "object",
|
|
1534
|
+
properties: {
|
|
1535
|
+
additionalDirectives: {
|
|
1536
|
+
type: "array",
|
|
1537
|
+
items: { type: "string" },
|
|
1538
|
+
uniqueItems: true
|
|
1539
|
+
},
|
|
1540
|
+
allow: {
|
|
1541
|
+
type: "array",
|
|
1542
|
+
items: { type: "string" },
|
|
1543
|
+
uniqueItems: true
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
additionalProperties: false
|
|
1547
|
+
}],
|
|
1548
|
+
type: "suggestion"
|
|
1549
|
+
},
|
|
1550
|
+
create(context) {
|
|
1551
|
+
const allowed = new Set(context.options[0] && context.options[0].allow || []);
|
|
1552
|
+
const additionalDirectives = context.options[0] && context.options[0].additionalDirectives || [];
|
|
1553
|
+
for (const directiveComment of getAllDirectiveComments(context, additionalDirectives)) if (!allowed.has(directiveComment.kind)) {
|
|
1554
|
+
if (!directiveComment.eslint) context.report({
|
|
1555
|
+
loc: utils.toForceLocation(directiveComment.loc),
|
|
1556
|
+
messageId: "disallow"
|
|
1557
|
+
});
|
|
1558
|
+
else context.report({
|
|
1559
|
+
loc: utils.toForceLocation(directiveComment.loc),
|
|
1560
|
+
messageId: "disallowEslint"
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
return {};
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
}));
|
|
1567
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules/require-description.js
|
|
1568
|
+
/**
|
|
1569
|
+
* @author Yosuke Ota <https://github.com/ota-meshi>
|
|
1570
|
+
* See LICENSE file in root directory for full license.
|
|
1571
|
+
*/
|
|
1572
|
+
var require_require_description = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1573
|
+
const { getAllDirectiveComments } = require_get_all_directive_comments();
|
|
1574
|
+
const utils = require_utils$1();
|
|
1575
|
+
module.exports = {
|
|
1576
|
+
meta: {
|
|
1577
|
+
docs: {
|
|
1578
|
+
description: "require include descriptions in ESLint directive-comments",
|
|
1579
|
+
category: "Stylistic Issues",
|
|
1580
|
+
recommended: false,
|
|
1581
|
+
url: "https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/require-description.html"
|
|
1582
|
+
},
|
|
1583
|
+
fixable: null,
|
|
1584
|
+
messages: { missingDescription: "Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary." },
|
|
1585
|
+
schema: [{
|
|
1586
|
+
type: "object",
|
|
1587
|
+
properties: {
|
|
1588
|
+
additionalDirectives: {
|
|
1589
|
+
type: "array",
|
|
1590
|
+
items: { type: "string" }
|
|
1591
|
+
},
|
|
1592
|
+
ignore: {
|
|
1593
|
+
type: "array",
|
|
1594
|
+
items: { enum: [
|
|
1595
|
+
"eslint",
|
|
1596
|
+
"eslint-disable",
|
|
1597
|
+
"eslint-disable-line",
|
|
1598
|
+
"eslint-disable-next-line",
|
|
1599
|
+
"eslint-enable",
|
|
1600
|
+
"eslint-env",
|
|
1601
|
+
"exported",
|
|
1602
|
+
"global",
|
|
1603
|
+
"globals"
|
|
1604
|
+
] },
|
|
1605
|
+
additionalItems: false,
|
|
1606
|
+
uniqueItems: true
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
additionalProperties: false
|
|
1610
|
+
}],
|
|
1611
|
+
type: "suggestion"
|
|
1612
|
+
},
|
|
1613
|
+
create(context) {
|
|
1614
|
+
const ignores = new Set(context.options[0] && context.options[0].ignore || []);
|
|
1615
|
+
const additionalDirectives = context.options[0] && context.options[0].additionalDirectives || [];
|
|
1616
|
+
for (const directiveComment of getAllDirectiveComments(context, additionalDirectives)) {
|
|
1617
|
+
if (ignores.has(directiveComment.kind)) continue;
|
|
1618
|
+
if (!directiveComment.description) context.report({
|
|
1619
|
+
loc: utils.toForceLocation(directiveComment.loc),
|
|
1620
|
+
messageId: "missingDescription"
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
return {};
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
}));
|
|
1627
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/rules.js
|
|
1628
|
+
/** DON'T EDIT THIS FILE; was created by scripts. */
|
|
1629
|
+
var require_rules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1630
|
+
module.exports = {
|
|
1631
|
+
"disable-enable-pair": require_disable_enable_pair(),
|
|
1632
|
+
"no-aggregating-enable": require_no_aggregating_enable(),
|
|
1633
|
+
"no-duplicate-disable": require_no_duplicate_disable(),
|
|
1634
|
+
"no-restricted-disable": require_no_restricted_disable(),
|
|
1635
|
+
"no-unlimited-disable": require_no_unlimited_disable(),
|
|
1636
|
+
"no-unused-disable": require_no_unused_disable(),
|
|
1637
|
+
"no-unused-enable": require_no_unused_enable(),
|
|
1638
|
+
"no-use": require_no_use(),
|
|
1639
|
+
"require-description": require_require_description()
|
|
1640
|
+
};
|
|
1641
|
+
}));
|
|
1642
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/utils.js
|
|
1643
|
+
/** DON'T EDIT THIS FILE; was created by scripts. */
|
|
1644
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1645
|
+
module.exports = { patch: require_patch() };
|
|
1646
|
+
}));
|
|
1647
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/configs/recommended.js
|
|
1648
|
+
/** DON'T EDIT THIS FILE; was created by scripts. */
|
|
1649
|
+
var require_recommended = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1650
|
+
module.exports = {
|
|
1651
|
+
plugins: ["@eslint-community/eslint-comments"],
|
|
1652
|
+
rules: {
|
|
1653
|
+
"@eslint-community/eslint-comments/disable-enable-pair": "error",
|
|
1654
|
+
"@eslint-community/eslint-comments/no-aggregating-enable": "error",
|
|
1655
|
+
"@eslint-community/eslint-comments/no-duplicate-disable": "error",
|
|
1656
|
+
"@eslint-community/eslint-comments/no-unlimited-disable": "error",
|
|
1657
|
+
"@eslint-community/eslint-comments/no-unused-enable": "error"
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
}));
|
|
1661
|
+
// node_modules/.pnpm/@eslint-community+eslint-plugin-eslint-comments@4.8.1_eslint@10.16.0_jiti@2.7.0_/node_modules/@eslint-community/eslint-plugin-eslint-comments/lib/configs.js
|
|
1662
|
+
/** DON'T EDIT THIS FILE; was created by scripts. */
|
|
1663
|
+
var require_configs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1664
|
+
module.exports = { recommended: require_recommended() };
|
|
1665
|
+
}));
|
|
1666
|
+
// src/eslint-comments/wrapper.ts
|
|
1667
|
+
var import_eslint_plugin_eslint_comments = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1668
|
+
const rules = require_rules();
|
|
1669
|
+
const utils = require_utils();
|
|
1670
|
+
module.exports = {
|
|
1671
|
+
configs: require_configs(),
|
|
1672
|
+
rules,
|
|
1673
|
+
utils
|
|
1674
|
+
};
|
|
1675
|
+
})))(), 1);
|
|
3
1676
|
const IS_UNICODE_WS = /^\p{White_Space}$/u;
|
|
4
1677
|
const TRIM_UNICODE_WS = /^\p{White_Space}+|\p{White_Space}+$/gu;
|
|
5
1678
|
const DIRECTIVE_LABEL = /^\p{White_Space}*(eslint|oxlint)-(disable-next-line|disable-line|disable|enable)(?=\p{White_Space}|$)/u;
|
|
@@ -140,6 +1813,7 @@ function wrapRule(rule) {
|
|
|
140
1813
|
}
|
|
141
1814
|
};
|
|
142
1815
|
}
|
|
1816
|
+
/** `no-restricted-disable` with the guard pre-scan and the directive sanitizer. */
|
|
143
1817
|
function guardNoRestrictedDisable(rule) {
|
|
144
1818
|
const wrapped = wrapRule(rule);
|
|
145
1819
|
const meta = {
|
|
@@ -175,8 +1849,9 @@ function guardNoRestrictedDisable(rule) {
|
|
|
175
1849
|
}
|
|
176
1850
|
};
|
|
177
1851
|
}
|
|
1852
|
+
// src/eslint-comments/index.ts
|
|
178
1853
|
const plugin = {
|
|
179
1854
|
meta: { name: "eslint-comments" },
|
|
180
|
-
rules: Object.fromEntries(Object.entries(
|
|
1855
|
+
rules: Object.fromEntries(Object.entries(import_eslint_plugin_eslint_comments.default.rules).map(([name, rule]) => [name, name === "no-restricted-disable" ? guardNoRestrictedDisable(rule) : wrapRule(rule)]))
|
|
181
1856
|
};
|
|
182
|
-
export {
|
|
1857
|
+
export { plugin as default };
|