immosquare-cleaner 0.1.46 → 0.1.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/rubocop-3.3.4.yml +2 -0
- data/linters/rubocop.yml +2 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/LICENSE-MIT +21 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/README.md +412 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/index.d.ts +61 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/index.js +618 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/legacy.js +539 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/package.json +73 -0
- data/node_modules/@eslint/js/package.json +1 -1
- data/node_modules/@eslint/plugin-kit/LICENSE +201 -0
- data/node_modules/@eslint/plugin-kit/README.md +224 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs +555 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts +239 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/types.ts +7 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts +239 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/index.js +551 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts +6 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/types.ts +7 -0
- data/node_modules/@eslint/plugin-kit/package.json +62 -0
- data/node_modules/eslint/README.md +2 -2
- data/node_modules/eslint/lib/config/config.js +278 -0
- data/node_modules/eslint/lib/config/flat-config-array.js +3 -204
- data/node_modules/eslint/lib/languages/js/source-code/source-code.js +29 -94
- data/node_modules/eslint/lib/linter/apply-disable-directives.js +17 -28
- data/node_modules/eslint/lib/linter/file-context.js +134 -0
- data/node_modules/eslint/lib/linter/linter.js +37 -42
- data/node_modules/eslint/lib/rules/id-length.js +1 -0
- data/node_modules/eslint/lib/rules/no-invalid-regexp.js +34 -18
- data/node_modules/eslint/lib/rules/require-unicode-regexp.js +95 -14
- data/node_modules/eslint/lib/rules/utils/regular-expressions.js +11 -3
- data/node_modules/eslint/lib/types/index.d.ts +1635 -0
- data/node_modules/eslint/lib/types/rules/best-practices.d.ts +1075 -0
- data/node_modules/eslint/lib/types/rules/deprecated.d.ts +294 -0
- data/node_modules/eslint/lib/types/rules/ecmascript-6.d.ts +561 -0
- data/node_modules/eslint/lib/types/rules/index.d.ts +50 -0
- data/node_modules/eslint/lib/types/rules/node-commonjs.d.ts +160 -0
- data/node_modules/eslint/lib/types/rules/possible-errors.d.ts +598 -0
- data/node_modules/eslint/lib/types/rules/strict-mode.d.ts +38 -0
- data/node_modules/eslint/lib/types/rules/stylistic-issues.d.ts +1932 -0
- data/node_modules/eslint/lib/types/rules/variables.d.ts +221 -0
- data/node_modules/eslint/lib/types/use-at-your-own-risk.d.ts +85 -0
- data/node_modules/eslint/package.json +20 -8
- data/node_modules/ignore/index.d.ts +1 -1
- data/node_modules/ignore/index.js +25 -7
- data/node_modules/ignore/legacy.js +34 -14
- data/node_modules/ignore/package.json +12 -11
- data/node_modules/npm-check-updates/build/index.js +282 -282
- data/node_modules/npm-check-updates/build/index.js.map +1 -1
- data/node_modules/npm-check-updates/package.json +1 -1
- data/package.json +3 -3
- metadata +31 -4
- data/linters/rubocop-2.7.6.yml +0 -88
- data/node_modules/eslint/lib/linter/config-comment-parser.js +0 -169
@@ -0,0 +1,551 @@
|
|
1
|
+
// @ts-self-types="./index.d.ts"
|
2
|
+
import levn from 'levn';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @fileoverview Config Comment Parser
|
6
|
+
* @author Nicholas C. Zakas
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
//-----------------------------------------------------------------------------
|
11
|
+
// Type Definitions
|
12
|
+
//-----------------------------------------------------------------------------
|
13
|
+
|
14
|
+
/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */
|
15
|
+
/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */
|
16
|
+
/** @typedef {import("./types.ts").StringConfig} StringConfig */
|
17
|
+
/** @typedef {import("./types.ts").BooleanConfig} BooleanConfig */
|
18
|
+
|
19
|
+
//-----------------------------------------------------------------------------
|
20
|
+
// Helpers
|
21
|
+
//-----------------------------------------------------------------------------
|
22
|
+
|
23
|
+
const directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
24
|
+
const validSeverities = new Set([0, 1, 2, "off", "warn", "error"]);
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Determines if the severity in the rule configuration is valid.
|
28
|
+
* @param {RuleConfig} ruleConfig A rule's configuration.
|
29
|
+
*/
|
30
|
+
function isSeverityValid(ruleConfig) {
|
31
|
+
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
32
|
+
return validSeverities.has(severity);
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Determines if all severities in the rules configuration are valid.
|
37
|
+
* @param {RulesConfig} rulesConfig The rules configuration to check.
|
38
|
+
* @returns {boolean} `true` if all severities are valid, otherwise `false`.
|
39
|
+
*/
|
40
|
+
function isEverySeverityValid(rulesConfig) {
|
41
|
+
return Object.values(rulesConfig).every(isSeverityValid);
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Represents a directive comment.
|
46
|
+
*/
|
47
|
+
class DirectiveComment {
|
48
|
+
/**
|
49
|
+
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
50
|
+
* @type {string}
|
51
|
+
*/
|
52
|
+
label = "";
|
53
|
+
|
54
|
+
/**
|
55
|
+
* The value of the directive (the string after the label).
|
56
|
+
* @type {string}
|
57
|
+
*/
|
58
|
+
value = "";
|
59
|
+
|
60
|
+
/**
|
61
|
+
* The justification of the directive (the string after the --).
|
62
|
+
* @type {string}
|
63
|
+
*/
|
64
|
+
justification = "";
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Creates a new directive comment.
|
68
|
+
* @param {string} label The label of the directive.
|
69
|
+
* @param {string} value The value of the directive.
|
70
|
+
* @param {string} justification The justification of the directive.
|
71
|
+
*/
|
72
|
+
constructor(label, value, justification) {
|
73
|
+
this.label = label;
|
74
|
+
this.value = value;
|
75
|
+
this.justification = justification;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
//------------------------------------------------------------------------------
|
80
|
+
// Public Interface
|
81
|
+
//------------------------------------------------------------------------------
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Object to parse ESLint configuration comments.
|
85
|
+
*/
|
86
|
+
class ConfigCommentParser {
|
87
|
+
/**
|
88
|
+
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
89
|
+
* whitespace. Used for "global" comments.
|
90
|
+
* @param {string} string The string to parse.
|
91
|
+
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
92
|
+
*/
|
93
|
+
parseStringConfig(string) {
|
94
|
+
const items = /** @type {StringConfig} */ ({});
|
95
|
+
|
96
|
+
// Collapse whitespace around `:` and `,` to make parsing easier
|
97
|
+
const trimmedString = string.replace(/\s*([:,])\s*/gu, "$1");
|
98
|
+
|
99
|
+
trimmedString.split(/\s|,+/u).forEach(name => {
|
100
|
+
if (!name) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
// value defaults to null (if not provided), e.g: "foo" => ["foo", null]
|
105
|
+
const [key, value = null] = name.split(":");
|
106
|
+
|
107
|
+
items[key] = value;
|
108
|
+
});
|
109
|
+
|
110
|
+
return items;
|
111
|
+
}
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Parses a JSON-like config.
|
115
|
+
* @param {string} string The string to parse.
|
116
|
+
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
117
|
+
*/
|
118
|
+
parseJSONLikeConfig(string) {
|
119
|
+
// Parses a JSON-like comment by the same way as parsing CLI option.
|
120
|
+
try {
|
121
|
+
const items = levn.parse("Object", string) || {};
|
122
|
+
|
123
|
+
/*
|
124
|
+
* When the configuration has any invalid severities, it should be completely
|
125
|
+
* ignored. This is because the configuration is not valid and should not be
|
126
|
+
* applied.
|
127
|
+
*
|
128
|
+
* For example, the following configuration is invalid:
|
129
|
+
*
|
130
|
+
* "no-alert: 2 no-console: 2"
|
131
|
+
*
|
132
|
+
* This results in a configuration of { "no-alert": "2 no-console: 2" }, which is
|
133
|
+
* not valid. In this case, the configuration should be ignored.
|
134
|
+
*/
|
135
|
+
if (isEverySeverityValid(items)) {
|
136
|
+
return {
|
137
|
+
ok: true,
|
138
|
+
config: items,
|
139
|
+
};
|
140
|
+
}
|
141
|
+
} catch {
|
142
|
+
// levn parsing error: ignore to parse the string by a fallback.
|
143
|
+
}
|
144
|
+
|
145
|
+
/*
|
146
|
+
* Optionator cannot parse commaless notations.
|
147
|
+
* But we are supporting that. So this is a fallback for that.
|
148
|
+
*/
|
149
|
+
const normalizedString = string
|
150
|
+
.replace(/([-a-zA-Z0-9/]+):/gu, '"$1":')
|
151
|
+
.replace(/(\]|[0-9])\s+(?=")/u, "$1,");
|
152
|
+
|
153
|
+
try {
|
154
|
+
const items = JSON.parse(`{${normalizedString}}`);
|
155
|
+
|
156
|
+
return {
|
157
|
+
ok: true,
|
158
|
+
config: items,
|
159
|
+
};
|
160
|
+
} catch (ex) {
|
161
|
+
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
162
|
+
|
163
|
+
return {
|
164
|
+
ok: false,
|
165
|
+
error: {
|
166
|
+
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`,
|
167
|
+
},
|
168
|
+
};
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Parses a config of values separated by comma.
|
174
|
+
* @param {string} string The string to parse.
|
175
|
+
* @returns {BooleanConfig} Result map of values and true values
|
176
|
+
*/
|
177
|
+
parseListConfig(string) {
|
178
|
+
const items = /** @type {BooleanConfig} */ ({});
|
179
|
+
|
180
|
+
string.split(",").forEach(name => {
|
181
|
+
const trimmedName = name
|
182
|
+
.trim()
|
183
|
+
.replace(
|
184
|
+
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
185
|
+
"$<ruleId>",
|
186
|
+
);
|
187
|
+
|
188
|
+
if (trimmedName) {
|
189
|
+
items[trimmedName] = true;
|
190
|
+
}
|
191
|
+
});
|
192
|
+
|
193
|
+
return items;
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Extract the directive and the justification from a given directive comment and trim them.
|
198
|
+
* @param {string} value The comment text to extract.
|
199
|
+
* @returns {{directivePart: string, justificationPart: string}} The extracted directive and justification.
|
200
|
+
*/
|
201
|
+
#extractDirectiveComment(value) {
|
202
|
+
const match = /\s-{2,}\s/u.exec(value);
|
203
|
+
|
204
|
+
if (!match) {
|
205
|
+
return { directivePart: value.trim(), justificationPart: "" };
|
206
|
+
}
|
207
|
+
|
208
|
+
const directive = value.slice(0, match.index).trim();
|
209
|
+
const justification = value.slice(match.index + match[0].length).trim();
|
210
|
+
|
211
|
+
return { directivePart: directive, justificationPart: justification };
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
* Parses a directive comment into directive text and value.
|
216
|
+
* @param {string} string The string with the directive to be parsed.
|
217
|
+
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
218
|
+
*/
|
219
|
+
parseDirective(string) {
|
220
|
+
const { directivePart, justificationPart } =
|
221
|
+
this.#extractDirectiveComment(string);
|
222
|
+
const match = directivesPattern.exec(directivePart);
|
223
|
+
|
224
|
+
if (!match) {
|
225
|
+
return undefined;
|
226
|
+
}
|
227
|
+
|
228
|
+
const directiveText = match[1];
|
229
|
+
const directiveValue = directivePart.slice(
|
230
|
+
match.index + directiveText.length,
|
231
|
+
);
|
232
|
+
|
233
|
+
return new DirectiveComment(
|
234
|
+
directiveText,
|
235
|
+
directiveValue.trim(),
|
236
|
+
justificationPart,
|
237
|
+
);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
/**
|
242
|
+
* @fileoverview A collection of helper classes for implementing `SourceCode`.
|
243
|
+
* @author Nicholas C. Zakas
|
244
|
+
*/
|
245
|
+
|
246
|
+
/* eslint class-methods-use-this: off -- Required to complete interface. */
|
247
|
+
|
248
|
+
//-----------------------------------------------------------------------------
|
249
|
+
// Type Definitions
|
250
|
+
//-----------------------------------------------------------------------------
|
251
|
+
|
252
|
+
/** @typedef {import("@eslint/core").VisitTraversalStep} VisitTraversalStep */
|
253
|
+
/** @typedef {import("@eslint/core").CallTraversalStep} CallTraversalStep */
|
254
|
+
/** @typedef {import("@eslint/core").TextSourceCode} TextSourceCode */
|
255
|
+
/** @typedef {import("@eslint/core").TraversalStep} TraversalStep */
|
256
|
+
/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */
|
257
|
+
/** @typedef {import("@eslint/core").SourceLocationWithOffset} SourceLocationWithOffset */
|
258
|
+
/** @typedef {import("@eslint/core").SourceRange} SourceRange */
|
259
|
+
|
260
|
+
//-----------------------------------------------------------------------------
|
261
|
+
// Helpers
|
262
|
+
//-----------------------------------------------------------------------------
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Determines if a node has ESTree-style loc information.
|
266
|
+
* @param {object} node The node to check.
|
267
|
+
* @returns {node is {loc:SourceLocation}} `true` if the node has ESTree-style loc information, `false` if not.
|
268
|
+
*/
|
269
|
+
function hasESTreeStyleLoc(node) {
|
270
|
+
return "loc" in node;
|
271
|
+
}
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Determines if a node has position-style loc information.
|
275
|
+
* @param {object} node The node to check.
|
276
|
+
* @returns {node is {position:SourceLocation}} `true` if the node has position-style range information, `false` if not.
|
277
|
+
*/
|
278
|
+
function hasPosStyleLoc(node) {
|
279
|
+
return "position" in node;
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Determines if a node has ESTree-style range information.
|
284
|
+
* @param {object} node The node to check.
|
285
|
+
* @returns {node is {range:SourceRange}} `true` if the node has ESTree-style range information, `false` if not.
|
286
|
+
*/
|
287
|
+
function hasESTreeStyleRange(node) {
|
288
|
+
return "range" in node;
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Determines if a node has position-style range information.
|
293
|
+
* @param {object} node The node to check.
|
294
|
+
* @returns {node is {position:SourceLocationWithOffset}} `true` if the node has position-style range information, `false` if not.
|
295
|
+
*/
|
296
|
+
function hasPosStyleRange(node) {
|
297
|
+
return "position" in node;
|
298
|
+
}
|
299
|
+
|
300
|
+
//-----------------------------------------------------------------------------
|
301
|
+
// Exports
|
302
|
+
//-----------------------------------------------------------------------------
|
303
|
+
|
304
|
+
/**
|
305
|
+
* A class to represent a step in the traversal process where a node is visited.
|
306
|
+
* @implements {VisitTraversalStep}
|
307
|
+
*/
|
308
|
+
class VisitNodeStep {
|
309
|
+
/**
|
310
|
+
* The type of the step.
|
311
|
+
* @type {"visit"}
|
312
|
+
* @readonly
|
313
|
+
*/
|
314
|
+
type = "visit";
|
315
|
+
|
316
|
+
/**
|
317
|
+
* The kind of the step. Represents the same data as the `type` property
|
318
|
+
* but it's a number for performance.
|
319
|
+
* @type {1}
|
320
|
+
* @readonly
|
321
|
+
*/
|
322
|
+
kind = 1;
|
323
|
+
|
324
|
+
/**
|
325
|
+
* The target of the step.
|
326
|
+
* @type {object}
|
327
|
+
*/
|
328
|
+
target;
|
329
|
+
|
330
|
+
/**
|
331
|
+
* The phase of the step.
|
332
|
+
* @type {1|2}
|
333
|
+
*/
|
334
|
+
phase;
|
335
|
+
|
336
|
+
/**
|
337
|
+
* The arguments of the step.
|
338
|
+
* @type {Array<any>}
|
339
|
+
*/
|
340
|
+
args;
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Creates a new instance.
|
344
|
+
* @param {Object} options The options for the step.
|
345
|
+
* @param {object} options.target The target of the step.
|
346
|
+
* @param {1|2} options.phase The phase of the step.
|
347
|
+
* @param {Array<any>} options.args The arguments of the step.
|
348
|
+
*/
|
349
|
+
constructor({ target, phase, args }) {
|
350
|
+
this.target = target;
|
351
|
+
this.phase = phase;
|
352
|
+
this.args = args;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* A class to represent a step in the traversal process where a
|
358
|
+
* method is called.
|
359
|
+
* @implements {CallTraversalStep}
|
360
|
+
*/
|
361
|
+
class CallMethodStep {
|
362
|
+
/**
|
363
|
+
* The type of the step.
|
364
|
+
* @type {"call"}
|
365
|
+
* @readonly
|
366
|
+
*/
|
367
|
+
type = "call";
|
368
|
+
|
369
|
+
/**
|
370
|
+
* The kind of the step. Represents the same data as the `type` property
|
371
|
+
* but it's a number for performance.
|
372
|
+
* @type {2}
|
373
|
+
* @readonly
|
374
|
+
*/
|
375
|
+
kind = 2;
|
376
|
+
|
377
|
+
/**
|
378
|
+
* The name of the method to call.
|
379
|
+
* @type {string}
|
380
|
+
*/
|
381
|
+
target;
|
382
|
+
|
383
|
+
/**
|
384
|
+
* The arguments to pass to the method.
|
385
|
+
* @type {Array<any>}
|
386
|
+
*/
|
387
|
+
args;
|
388
|
+
|
389
|
+
/**
|
390
|
+
* Creates a new instance.
|
391
|
+
* @param {Object} options The options for the step.
|
392
|
+
* @param {string} options.target The target of the step.
|
393
|
+
* @param {Array<any>} options.args The arguments of the step.
|
394
|
+
*/
|
395
|
+
constructor({ target, args }) {
|
396
|
+
this.target = target;
|
397
|
+
this.args = args;
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Source Code Base Object
|
403
|
+
* @implements {TextSourceCode}
|
404
|
+
*/
|
405
|
+
class TextSourceCodeBase {
|
406
|
+
/**
|
407
|
+
* The lines of text in the source code.
|
408
|
+
* @type {Array<string>}
|
409
|
+
*/
|
410
|
+
#lines;
|
411
|
+
|
412
|
+
/**
|
413
|
+
* The AST of the source code.
|
414
|
+
* @type {object}
|
415
|
+
*/
|
416
|
+
ast;
|
417
|
+
|
418
|
+
/**
|
419
|
+
* The text of the source code.
|
420
|
+
* @type {string}
|
421
|
+
*/
|
422
|
+
text;
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Creates a new instance.
|
426
|
+
* @param {Object} options The options for the instance.
|
427
|
+
* @param {string} options.text The source code text.
|
428
|
+
* @param {object} options.ast The root AST node.
|
429
|
+
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
430
|
+
*/
|
431
|
+
constructor({ text, ast, lineEndingPattern = /\r?\n/u }) {
|
432
|
+
this.ast = ast;
|
433
|
+
this.text = text;
|
434
|
+
this.#lines = text.split(lineEndingPattern);
|
435
|
+
}
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Returns the loc information for the given node or token.
|
439
|
+
* @param {object} nodeOrToken The node or token to get the loc information for.
|
440
|
+
* @returns {SourceLocation} The loc information for the node or token.
|
441
|
+
*/
|
442
|
+
getLoc(nodeOrToken) {
|
443
|
+
if (hasESTreeStyleLoc(nodeOrToken)) {
|
444
|
+
return nodeOrToken.loc;
|
445
|
+
}
|
446
|
+
|
447
|
+
if (hasPosStyleLoc(nodeOrToken)) {
|
448
|
+
return nodeOrToken.position;
|
449
|
+
}
|
450
|
+
|
451
|
+
throw new Error(
|
452
|
+
"Custom getLoc() method must be implemented in the subclass.",
|
453
|
+
);
|
454
|
+
}
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Returns the range information for the given node or token.
|
458
|
+
* @param {object} nodeOrToken The node or token to get the range information for.
|
459
|
+
* @returns {SourceRange} The range information for the node or token.
|
460
|
+
*/
|
461
|
+
getRange(nodeOrToken) {
|
462
|
+
if (hasESTreeStyleRange(nodeOrToken)) {
|
463
|
+
return nodeOrToken.range;
|
464
|
+
}
|
465
|
+
|
466
|
+
if (hasPosStyleRange(nodeOrToken)) {
|
467
|
+
return [
|
468
|
+
nodeOrToken.position.start.offset,
|
469
|
+
nodeOrToken.position.end.offset,
|
470
|
+
];
|
471
|
+
}
|
472
|
+
|
473
|
+
throw new Error(
|
474
|
+
"Custom getRange() method must be implemented in the subclass.",
|
475
|
+
);
|
476
|
+
}
|
477
|
+
|
478
|
+
/* eslint-disable no-unused-vars -- Required to complete interface. */
|
479
|
+
/**
|
480
|
+
* Returns the parent of the given node.
|
481
|
+
* @param {object} node The node to get the parent of.
|
482
|
+
* @returns {object|undefined} The parent of the node.
|
483
|
+
*/
|
484
|
+
getParent(node) {
|
485
|
+
throw new Error("Not implemented.");
|
486
|
+
}
|
487
|
+
/* eslint-enable no-unused-vars -- Required to complete interface. */
|
488
|
+
|
489
|
+
/**
|
490
|
+
* Gets all the ancestors of a given node
|
491
|
+
* @param {object} node The node
|
492
|
+
* @returns {Array<object>} All the ancestor nodes in the AST, not including the provided node, starting
|
493
|
+
* from the root node at index 0 and going inwards to the parent node.
|
494
|
+
* @throws {TypeError} When `node` is missing.
|
495
|
+
*/
|
496
|
+
getAncestors(node) {
|
497
|
+
if (!node) {
|
498
|
+
throw new TypeError("Missing required argument: node.");
|
499
|
+
}
|
500
|
+
|
501
|
+
const ancestorsStartingAtParent = [];
|
502
|
+
|
503
|
+
for (
|
504
|
+
let ancestor = this.getParent(node);
|
505
|
+
ancestor;
|
506
|
+
ancestor = this.getParent(ancestor)
|
507
|
+
) {
|
508
|
+
ancestorsStartingAtParent.push(ancestor);
|
509
|
+
}
|
510
|
+
|
511
|
+
return ancestorsStartingAtParent.reverse();
|
512
|
+
}
|
513
|
+
|
514
|
+
/**
|
515
|
+
* Gets the source code for the given node.
|
516
|
+
* @param {object} [node] The AST node to get the text for.
|
517
|
+
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
518
|
+
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
519
|
+
* @returns {string} The text representing the AST node.
|
520
|
+
* @public
|
521
|
+
*/
|
522
|
+
getText(node, beforeCount, afterCount) {
|
523
|
+
if (node) {
|
524
|
+
const range = this.getRange(node);
|
525
|
+
return this.text.slice(
|
526
|
+
Math.max(range[0] - (beforeCount || 0), 0),
|
527
|
+
range[1] + (afterCount || 0),
|
528
|
+
);
|
529
|
+
}
|
530
|
+
return this.text;
|
531
|
+
}
|
532
|
+
|
533
|
+
/**
|
534
|
+
* Gets the entire source text split into an array of lines.
|
535
|
+
* @returns {Array<string>} The source text as an array of lines.
|
536
|
+
* @public
|
537
|
+
*/
|
538
|
+
get lines() {
|
539
|
+
return this.#lines;
|
540
|
+
}
|
541
|
+
|
542
|
+
/**
|
543
|
+
* Traverse the source code and return the steps that were taken.
|
544
|
+
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
545
|
+
*/
|
546
|
+
traverse() {
|
547
|
+
throw new Error("Not implemented.");
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
export { CallMethodStep, ConfigCommentParser, TextSourceCodeBase, VisitNodeStep };
|
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"name": "@eslint/plugin-kit",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "Utilities for building ESLint plugins.",
|
5
|
+
"author": "Nicholas C. Zakas",
|
6
|
+
"type": "module",
|
7
|
+
"main": "dist/esm/index.js",
|
8
|
+
"types": "dist/esm/index.d.ts",
|
9
|
+
"exports": {
|
10
|
+
"require": {
|
11
|
+
"types": "./dist/cjs/index.d.cts",
|
12
|
+
"default": "./dist/cjs/index.cjs"
|
13
|
+
},
|
14
|
+
"import": {
|
15
|
+
"types": "./dist/esm/index.d.ts",
|
16
|
+
"default": "./dist/esm/index.js"
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"files": [
|
20
|
+
"dist"
|
21
|
+
],
|
22
|
+
"publishConfig": {
|
23
|
+
"access": "public"
|
24
|
+
},
|
25
|
+
"repository": {
|
26
|
+
"type": "git",
|
27
|
+
"url": "git+https://github.com/eslint/rewrite.git"
|
28
|
+
},
|
29
|
+
"bugs": {
|
30
|
+
"url": "https://github.com/eslint/rewrite/issues"
|
31
|
+
},
|
32
|
+
"homepage": "https://github.com/eslint/rewrite#readme",
|
33
|
+
"scripts": {
|
34
|
+
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
35
|
+
"build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"",
|
36
|
+
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
37
|
+
"test:jsr": "npx jsr@latest publish --dry-run",
|
38
|
+
"pretest": "npm run build",
|
39
|
+
"test": "mocha tests/",
|
40
|
+
"test:coverage": "c8 npm test"
|
41
|
+
},
|
42
|
+
"keywords": [
|
43
|
+
"eslint",
|
44
|
+
"eslintplugin",
|
45
|
+
"eslint-plugin"
|
46
|
+
],
|
47
|
+
"license": "Apache-2.0",
|
48
|
+
"devDependencies": {
|
49
|
+
"@eslint/core": "^0.5.0",
|
50
|
+
"c8": "^9.1.0",
|
51
|
+
"mocha": "^10.4.0",
|
52
|
+
"rollup": "^4.16.2",
|
53
|
+
"rollup-plugin-copy": "^3.5.0",
|
54
|
+
"typescript": "^5.4.5"
|
55
|
+
},
|
56
|
+
"engines": {
|
57
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
58
|
+
},
|
59
|
+
"dependencies": {
|
60
|
+
"levn": "^0.4.1"
|
61
|
+
}
|
62
|
+
}
|
@@ -297,9 +297,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
297
297
|
<!--sponsorsstart-->
|
298
298
|
<h3>Platinum Sponsors</h3>
|
299
299
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
300
|
-
<p><a href="
|
300
|
+
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://opensource.siemens.com"><img src="https://avatars.githubusercontent.com/u/624020?v=4" alt="Siemens" height="96"></a></p><h3>Silver Sponsors</h3>
|
301
301
|
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
|
302
|
-
<p><a href="https://www.
|
302
|
+
<p><a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
|
303
303
|
<!--sponsorsend-->
|
304
304
|
|
305
305
|
<!--techsponsorsstart-->
|