@dcf-micro/eslint-config 5.0.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.
Files changed (46) hide show
  1. package/dist/chunks/eslint-plugin-prettier.mjs +1716 -0
  2. package/dist/chunks/index.mjs +1341 -0
  3. package/dist/chunks/index10.mjs +39595 -0
  4. package/dist/chunks/index11.mjs +24 -0
  5. package/dist/chunks/index12.mjs +75273 -0
  6. package/dist/chunks/index13.mjs +55129 -0
  7. package/dist/chunks/index14.mjs +24 -0
  8. package/dist/chunks/index15.mjs +1441 -0
  9. package/dist/chunks/index2.mjs +31864 -0
  10. package/dist/chunks/index3.mjs +8154 -0
  11. package/dist/chunks/index4.mjs +24 -0
  12. package/dist/chunks/index5.mjs +44093 -0
  13. package/dist/chunks/index6.mjs +10371 -0
  14. package/dist/chunks/index7.mjs +21890 -0
  15. package/dist/chunks/index8.mjs +14424 -0
  16. package/dist/chunks/index9.mjs +194 -0
  17. package/dist/chunks/jiti.mjs +320 -0
  18. package/dist/index.d.mts +3897 -0
  19. package/dist/index.d.ts +3897 -0
  20. package/dist/index.mjs +4 -0
  21. package/dist/shared/eslint-config.BDBLGvXj.mjs +5282 -0
  22. package/dist/shared/eslint-config.BEdqg1el.mjs +12256 -0
  23. package/dist/shared/eslint-config.BKmXKm8B.mjs +5533 -0
  24. package/dist/shared/eslint-config.BjUMgISS.mjs +9012 -0
  25. package/dist/shared/eslint-config.Bk-3rH6Y.mjs +1355 -0
  26. package/dist/shared/eslint-config.BytuZ0Ec.mjs +20 -0
  27. package/dist/shared/eslint-config.C1V0I4Np.mjs +16900 -0
  28. package/dist/shared/eslint-config.CGxZQKHV.mjs +2091 -0
  29. package/dist/shared/eslint-config.COweQ1RR.mjs +5 -0
  30. package/dist/shared/eslint-config.CSnk9Q4w.mjs +9339 -0
  31. package/dist/shared/eslint-config.CWvTq0mr.mjs +2914 -0
  32. package/dist/shared/eslint-config.Ca4PTK8E.mjs +646 -0
  33. package/dist/shared/eslint-config.CmPTszkJ.mjs +3583 -0
  34. package/dist/shared/eslint-config.CqEANaNA.mjs +139622 -0
  35. package/dist/shared/eslint-config.CsePEcYJ.mjs +71 -0
  36. package/dist/shared/eslint-config.Cw6mETSZ.mjs +2580 -0
  37. package/dist/shared/eslint-config.DTVnsecK.mjs +1751 -0
  38. package/dist/shared/eslint-config.DWoU09EE.mjs +6958 -0
  39. package/dist/shared/eslint-config.DZvqTQUU.mjs +3818 -0
  40. package/dist/shared/eslint-config.Dhg7lT0g.mjs +1807 -0
  41. package/dist/shared/eslint-config.Du5y5qmf.mjs +200673 -0
  42. package/dist/shared/eslint-config.FKVuBSa4.mjs +394 -0
  43. package/dist/shared/eslint-config.I8d-HnmI.mjs +2654 -0
  44. package/dist/shared/eslint-config.YntqsQY1.mjs +40 -0
  45. package/dist/shared/eslint-config.uGTBNMD0.mjs +687 -0
  46. package/package.json +56 -0
@@ -0,0 +1,1341 @@
1
+ import { g as getDefaultExportFromCjs } from '../shared/eslint-config.BDBLGvXj.mjs';
2
+ import { r as requireEscapeStringRegexp } from '../shared/eslint-config.BytuZ0Ec.mjs';
3
+ import { r as requireIgnore } from '../shared/eslint-config.Ca4PTK8E.mjs';
4
+ import { c as commonjsRequire } from '../shared/eslint-config.COweQ1RR.mjs';
5
+ import require$$0 from 'path';
6
+
7
+ function _mergeNamespaces(n, m) {
8
+ for (var i = 0; i < m.length; i++) {
9
+ const e = m[i];
10
+ if (typeof e !== 'string' && !Array.isArray(e)) { for (const k in e) {
11
+ if (k !== 'default' && !(k in n)) {
12
+ n[k] = e[k];
13
+ }
14
+ } }
15
+ }
16
+ return n;
17
+ }
18
+
19
+ /** DON'T EDIT THIS FILE; was created by scripts. */
20
+
21
+ var recommended;
22
+ var hasRequiredRecommended;
23
+
24
+ function requireRecommended () {
25
+ if (hasRequiredRecommended) return recommended;
26
+ hasRequiredRecommended = 1;
27
+
28
+ recommended = {
29
+ plugins: ["eslint-comments"],
30
+ rules: {
31
+ "eslint-comments/disable-enable-pair": "error",
32
+ "eslint-comments/no-aggregating-enable": "error",
33
+ "eslint-comments/no-duplicate-disable": "error",
34
+ "eslint-comments/no-unlimited-disable": "error",
35
+ "eslint-comments/no-unused-enable": "error",
36
+ },
37
+ };
38
+ return recommended;
39
+ }
40
+
41
+ /** DON'T EDIT THIS FILE; was created by scripts. */
42
+
43
+ var configs;
44
+ var hasRequiredConfigs;
45
+
46
+ function requireConfigs () {
47
+ if (hasRequiredConfigs) return configs;
48
+ hasRequiredConfigs = 1;
49
+
50
+ configs = {
51
+ recommended: requireRecommended(),
52
+ };
53
+ return configs;
54
+ }
55
+
56
+ var utils$1 = {exports: {}};
57
+
58
+ /**
59
+ * @author Toru Nagashima <https://github.com/mysticatea>
60
+ * See LICENSE file in root directory for full license.
61
+ */
62
+
63
+ var hasRequiredUtils$1;
64
+
65
+ function requireUtils$1 () {
66
+ if (hasRequiredUtils$1) return utils$1.exports;
67
+ hasRequiredUtils$1 = 1;
68
+ (function (module) {
69
+
70
+ const escapeStringRegexp = requireEscapeStringRegexp();
71
+ const LINE_PATTERN = /[^\r\n\u2028\u2029]*(?:\r\n|[\r\n\u2028\u2029]|$)/gu;
72
+
73
+ const DIRECTIVE_PATTERN = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u;
74
+ const LINE_COMMENT_PATTERN = /^eslint-disable-(next-)?line$/u;
75
+
76
+ module.exports = {
77
+ /**
78
+ * Make the location ignoring `eslint-disable` comments.
79
+ *
80
+ * @param {object} location - The location to convert.
81
+ * @returns {object} Converted location.
82
+ */
83
+ toForceLocation(location) {
84
+ return {
85
+ start: {
86
+ line: location.start.line,
87
+ column: -1,
88
+ },
89
+ end: location.end,
90
+ }
91
+ },
92
+
93
+ /**
94
+ * Calculate the location of the given rule in the given comment token.
95
+ *
96
+ * @param {Token} comment - The comment token to calculate.
97
+ * @param {string|null} ruleId - The rule name to calculate.
98
+ * @returns {object} The location of the given information.
99
+ */
100
+ toRuleIdLocation(comment, ruleId) {
101
+ if (ruleId == null) {
102
+ return module.exports.toForceLocation(comment.loc)
103
+ }
104
+
105
+ const lines = comment.value.match(LINE_PATTERN);
106
+ //eslint-disable-next-line require-unicode-regexp
107
+ const ruleIdPattern = new RegExp(
108
+ `([\\s,]|^)${escapeStringRegexp(ruleId)}(?:[\\s,]|$)`
109
+ );
110
+
111
+ {
112
+ const m = ruleIdPattern.exec(lines[0]);
113
+ if (m != null) {
114
+ const start = comment.loc.start;
115
+ return {
116
+ start: {
117
+ line: start.line,
118
+ column: 2 + start.column + m.index + m[1].length,
119
+ },
120
+ end: {
121
+ line: start.line,
122
+ column:
123
+ 2 +
124
+ start.column +
125
+ m.index +
126
+ m[1].length +
127
+ ruleId.length,
128
+ },
129
+ }
130
+ }
131
+ }
132
+
133
+ for (let i = 1; i < lines.length; ++i) {
134
+ const m = ruleIdPattern.exec(lines[i]);
135
+ if (m != null) {
136
+ const start = comment.loc.start;
137
+ return {
138
+ start: {
139
+ line: start.line + i,
140
+ column: m.index + m[1].length,
141
+ },
142
+ end: {
143
+ line: start.line + i,
144
+ column: m.index + m[1].length + ruleId.length,
145
+ },
146
+ }
147
+ }
148
+ }
149
+
150
+ /*istanbul ignore next : foolproof */
151
+ return comment.loc
152
+ },
153
+
154
+ /**
155
+ * Checks `a` is less than `b` or `a` equals `b`.
156
+ *
157
+ * @param {{line: number, column: number}} a - A location to compare.
158
+ * @param {{line: number, column: number}} b - Another location to compare.
159
+ * @returns {boolean} `true` if `a` is less than `b` or `a` equals `b`.
160
+ */
161
+ lte(a, b) {
162
+ return a.line < b.line || (a.line === b.line && a.column <= b.column)
163
+ },
164
+
165
+ /**
166
+ * Parse the given comment token as a directive comment.
167
+ *
168
+ * @param {Token} comment - The comment token to parse.
169
+ * @returns {{kind: string, value: string, description: string | null}|null} The parsed data of the given comment. If `null`, it is not a directive comment.
170
+ */
171
+ parseDirectiveComment(comment) {
172
+ const { text, description } = divideDirectiveComment(comment.value);
173
+ const match = DIRECTIVE_PATTERN.exec(text);
174
+
175
+ if (!match) {
176
+ return null
177
+ }
178
+ const directiveText = match[1];
179
+ const lineCommentSupported = LINE_COMMENT_PATTERN.test(directiveText);
180
+
181
+ if (comment.type === "Line" && !lineCommentSupported) {
182
+ return null
183
+ }
184
+
185
+ if (
186
+ lineCommentSupported &&
187
+ comment.loc.start.line !== comment.loc.end.line
188
+ ) {
189
+ // disable-line comment should not span multiple lines.
190
+ return null
191
+ }
192
+
193
+ const directiveValue = text.slice(match.index + directiveText.length);
194
+
195
+ return {
196
+ kind: directiveText,
197
+ value: directiveValue.trim(),
198
+ description,
199
+ }
200
+ },
201
+ };
202
+
203
+ /**
204
+ * Divides and trims description text and directive comments.
205
+ * @param {string} value The comment text to strip.
206
+ * @returns {{text: string, description: string | null}} The stripped text.
207
+ */
208
+ function divideDirectiveComment(value) {
209
+ const divided = value.split(/\s-{2,}\s/u);
210
+ const text = divided[0].trim();
211
+ return {
212
+ text,
213
+ description: divided.length > 1 ? divided[1].trim() : null,
214
+ }
215
+ }
216
+ } (utils$1));
217
+ return utils$1.exports;
218
+ }
219
+
220
+ /**
221
+ * @author Toru Nagashima <https://github.com/mysticatea>
222
+ * See LICENSE file in root directory for full license.
223
+ */
224
+
225
+ var disabledArea;
226
+ var hasRequiredDisabledArea;
227
+
228
+ function requireDisabledArea () {
229
+ if (hasRequiredDisabledArea) return disabledArea;
230
+ hasRequiredDisabledArea = 1;
231
+
232
+ const utils = requireUtils$1();
233
+ const DELIMITER = /[\s,]+/gu;
234
+ const pool = new WeakMap();
235
+
236
+ disabledArea = class DisabledArea {
237
+ /**
238
+ * Get singleton instance for the given source code.
239
+ *
240
+ * @param {eslint.SourceCode} sourceCode - The source code to get.
241
+ * @returns {DisabledArea} The singleton object for the source code.
242
+ */
243
+ static get(sourceCode) {
244
+ let retv = pool.get(sourceCode.ast);
245
+
246
+ if (retv == null) {
247
+ retv = new DisabledArea();
248
+ retv._scan(sourceCode);
249
+ pool.set(sourceCode.ast, retv);
250
+ }
251
+
252
+ return retv
253
+ }
254
+
255
+ /**
256
+ * Constructor.
257
+ */
258
+ constructor() {
259
+ this.areas = [];
260
+ this.duplicateDisableDirectives = [];
261
+ this.unusedEnableDirectives = [];
262
+ this.numberOfRelatedDisableDirectives = new Map();
263
+ }
264
+
265
+ /**
266
+ * Make disabled area.
267
+ *
268
+ * @param {Token} comment - The comment token to disable.
269
+ * @param {object} location - The start location to disable.
270
+ * @param {string[]|null} ruleIds - The ruleId names to disable.
271
+ * @param {string} kind - The kind of disable-comments.
272
+ * @returns {void}
273
+ * @private
274
+ */
275
+ _disable(comment, location, ruleIds, kind) {
276
+ if (ruleIds) {
277
+ for (const ruleId of ruleIds) {
278
+ if (this._getArea(ruleId, location) != null) {
279
+ this.duplicateDisableDirectives.push({ comment, ruleId });
280
+ }
281
+
282
+ this.areas.push({
283
+ comment,
284
+ ruleId,
285
+ kind,
286
+ start: location,
287
+ end: null,
288
+ });
289
+ }
290
+ } else {
291
+ if (this._getArea(null, location) != null) {
292
+ this.duplicateDisableDirectives.push({ comment, ruleId: null });
293
+ }
294
+
295
+ this.areas.push({
296
+ comment,
297
+ ruleId: null,
298
+ kind,
299
+ start: location,
300
+ end: null,
301
+ });
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Close disabled area.
307
+ *
308
+ * @param {Token} comment - The comment token to enable.
309
+ * @param {object} location - The start location to enable.
310
+ * @param {string[]|null} ruleIds - The ruleId names to enable.
311
+ * @param {string} kind - The kind of disable-comments.
312
+ * @returns {void}
313
+ * @private
314
+ */
315
+ _enable(comment, location, ruleIds, kind) {
316
+ const relatedDisableDirectives = new Set();
317
+
318
+ if (ruleIds) {
319
+ for (const ruleId of ruleIds) {
320
+ let used = false;
321
+
322
+ for (let i = this.areas.length - 1; i >= 0; --i) {
323
+ const area = this.areas[i];
324
+
325
+ if (
326
+ area.end === null &&
327
+ area.kind === kind &&
328
+ area.ruleId === ruleId
329
+ ) {
330
+ relatedDisableDirectives.add(area.comment);
331
+ area.end = location;
332
+ used = true;
333
+ }
334
+ }
335
+
336
+ if (!used) {
337
+ this.unusedEnableDirectives.push({ comment, ruleId });
338
+ }
339
+ }
340
+ } else {
341
+ let used = false;
342
+
343
+ for (let i = this.areas.length - 1; i >= 0; --i) {
344
+ const area = this.areas[i];
345
+
346
+ if (area.end === null && area.kind === kind) {
347
+ relatedDisableDirectives.add(area.comment);
348
+ area.end = location;
349
+ used = true;
350
+ }
351
+ }
352
+
353
+ if (!used) {
354
+ this.unusedEnableDirectives.push({ comment, ruleId: null });
355
+ }
356
+ }
357
+
358
+ this.numberOfRelatedDisableDirectives.set(
359
+ comment,
360
+ relatedDisableDirectives.size
361
+ );
362
+ }
363
+
364
+ /**
365
+ * Gets the area of the given ruleId and location.
366
+ *
367
+ * @param {string|null} ruleId - The ruleId name to get.
368
+ * @param {object} location - The location to get.
369
+ * @returns {object|null} The area of the given ruleId and location.
370
+ * @private
371
+ */
372
+ _getArea(ruleId, location) {
373
+ for (let i = this.areas.length - 1; i >= 0; --i) {
374
+ const area = this.areas[i];
375
+
376
+ if (
377
+ (area.ruleId === null || area.ruleId === ruleId) &&
378
+ utils.lte(area.start, location) &&
379
+ (area.end === null || utils.lte(location, area.end))
380
+ ) {
381
+ return area
382
+ }
383
+ }
384
+
385
+ return null
386
+ }
387
+
388
+ /**
389
+ * Scan the source code and setup disabled area list.
390
+ *
391
+ * @param {eslint.SourceCode} sourceCode - The source code to scan.
392
+ * @returns {void}
393
+ * @private
394
+ */
395
+ _scan(sourceCode) {
396
+ for (const comment of sourceCode.getAllComments()) {
397
+ const directiveComment = utils.parseDirectiveComment(comment);
398
+ if (directiveComment == null) {
399
+ continue
400
+ }
401
+
402
+ const kind = directiveComment.kind;
403
+ if (
404
+ kind !== "eslint-disable" &&
405
+ kind !== "eslint-enable" &&
406
+ kind !== "eslint-disable-line" &&
407
+ kind !== "eslint-disable-next-line"
408
+ ) {
409
+ continue
410
+ }
411
+ const ruleIds = directiveComment.value
412
+ ? directiveComment.value.split(DELIMITER)
413
+ : null;
414
+
415
+ if (kind === "eslint-disable") {
416
+ this._disable(comment, comment.loc.start, ruleIds, "block");
417
+ } else if (kind === "eslint-enable") {
418
+ this._enable(comment, comment.loc.start, ruleIds, "block");
419
+ } else if (kind === "eslint-disable-line") {
420
+ const line = comment.loc.start.line;
421
+ const start = { line, column: 0 };
422
+ const end = { line: line + 1, column: -1 };
423
+
424
+ this._disable(comment, start, ruleIds, "line");
425
+ this._enable(comment, end, ruleIds, "line");
426
+ } else if (kind === "eslint-disable-next-line") {
427
+ const line = comment.loc.start.line;
428
+ const start = { line: line + 1, column: 0 };
429
+ const end = { line: line + 2, column: -1 };
430
+
431
+ this._disable(comment, start, ruleIds, "line");
432
+ this._enable(comment, end, ruleIds, "line");
433
+ }
434
+ }
435
+ }
436
+ };
437
+ return disabledArea;
438
+ }
439
+
440
+ /**
441
+ * @author Toru Nagashima <https://github.com/mysticatea>
442
+ * See LICENSE file in root directory for full license.
443
+ */
444
+
445
+ var disableEnablePair;
446
+ var hasRequiredDisableEnablePair;
447
+
448
+ function requireDisableEnablePair () {
449
+ if (hasRequiredDisableEnablePair) return disableEnablePair;
450
+ hasRequiredDisableEnablePair = 1;
451
+
452
+ const DisabledArea = requireDisabledArea();
453
+ const utils = requireUtils$1();
454
+
455
+ disableEnablePair = {
456
+ meta: {
457
+ docs: {
458
+ description:
459
+ "require a `eslint-enable` comment for every `eslint-disable` comment",
460
+ category: "Best Practices",
461
+ recommended: true,
462
+ url:
463
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html",
464
+ },
465
+ fixable: null,
466
+ schema: [
467
+ {
468
+ type: "object",
469
+ properties: {
470
+ allowWholeFile: {
471
+ type: "boolean",
472
+ },
473
+ },
474
+ additionalProperties: false,
475
+ },
476
+ ],
477
+ type: "suggestion",
478
+ },
479
+
480
+ create(context) {
481
+ const allowWholeFile =
482
+ context.options[0] && context.options[0].allowWholeFile;
483
+ const sourceCode = context.getSourceCode();
484
+ const disabledArea = DisabledArea.get(sourceCode);
485
+
486
+ return {
487
+ Program(node) {
488
+ if (allowWholeFile && node.body.length === 0) {
489
+ return
490
+ }
491
+
492
+ for (const area of disabledArea.areas) {
493
+ if (area.end != null) {
494
+ continue
495
+ }
496
+ if (
497
+ allowWholeFile &&
498
+ utils.lte(area.start, node.loc.start)
499
+ ) {
500
+ continue
501
+ }
502
+
503
+ context.report({
504
+ loc: utils.toRuleIdLocation(area.comment, area.ruleId),
505
+ message: area.ruleId
506
+ ? "Requires 'eslint-enable' directive for '{{ruleId}}'."
507
+ : "Requires 'eslint-enable' directive.",
508
+ data: area,
509
+ });
510
+ }
511
+ },
512
+ }
513
+ },
514
+ };
515
+ return disableEnablePair;
516
+ }
517
+
518
+ /**
519
+ * @author Toru Nagashima <https://github.com/mysticatea>
520
+ * See LICENSE file in root directory for full license.
521
+ */
522
+
523
+ var noAggregatingEnable;
524
+ var hasRequiredNoAggregatingEnable;
525
+
526
+ function requireNoAggregatingEnable () {
527
+ if (hasRequiredNoAggregatingEnable) return noAggregatingEnable;
528
+ hasRequiredNoAggregatingEnable = 1;
529
+
530
+ const DisabledArea = requireDisabledArea();
531
+ const utils = requireUtils$1();
532
+
533
+ noAggregatingEnable = {
534
+ meta: {
535
+ docs: {
536
+ description:
537
+ "disallow a `eslint-enable` comment for multiple `eslint-disable` comments",
538
+ category: "Best Practices",
539
+ recommended: true,
540
+ url:
541
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable.html",
542
+ },
543
+ fixable: null,
544
+ schema: [],
545
+ type: "suggestion",
546
+ },
547
+
548
+ create(context) {
549
+ const sourceCode = context.getSourceCode();
550
+ const disabledArea = DisabledArea.get(sourceCode);
551
+
552
+ return {
553
+ Program() {
554
+ for (const entry of disabledArea.numberOfRelatedDisableDirectives) {
555
+ const comment = entry[0];
556
+ const count = entry[1];
557
+
558
+ if (count >= 2) {
559
+ context.report({
560
+ loc: utils.toForceLocation(comment.loc),
561
+ message:
562
+ "This `eslint-enable` comment affects {{count}} `eslint-disable` comments. An `eslint-enable` comment should be for an `eslint-disable` comment.",
563
+ data: { count },
564
+ });
565
+ }
566
+ }
567
+ },
568
+ }
569
+ },
570
+ };
571
+ return noAggregatingEnable;
572
+ }
573
+
574
+ /**
575
+ * @author Toru Nagashima <https://github.com/mysticatea>
576
+ * See LICENSE file in root directory for full license.
577
+ */
578
+
579
+ var noDuplicateDisable;
580
+ var hasRequiredNoDuplicateDisable;
581
+
582
+ function requireNoDuplicateDisable () {
583
+ if (hasRequiredNoDuplicateDisable) return noDuplicateDisable;
584
+ hasRequiredNoDuplicateDisable = 1;
585
+
586
+ const DisabledArea = requireDisabledArea();
587
+ const utils = requireUtils$1();
588
+
589
+ noDuplicateDisable = {
590
+ meta: {
591
+ docs: {
592
+ description: "disallow duplicate `eslint-disable` comments",
593
+ category: "Best Practices",
594
+ recommended: true,
595
+ url:
596
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable.html",
597
+ },
598
+ fixable: null,
599
+ schema: [],
600
+ type: "problem",
601
+ },
602
+
603
+ create(context) {
604
+ const sourceCode = context.getSourceCode();
605
+ const disabledArea = DisabledArea.get(sourceCode);
606
+
607
+ return {
608
+ Program() {
609
+ for (const item of disabledArea.duplicateDisableDirectives) {
610
+ context.report({
611
+ loc: utils.toRuleIdLocation(item.comment, item.ruleId),
612
+ message: item.ruleId
613
+ ? "'{{ruleId}}' rule has been disabled already."
614
+ : "ESLint rules have been disabled already.",
615
+ data: item,
616
+ });
617
+ }
618
+ },
619
+ }
620
+ },
621
+ };
622
+ return noDuplicateDisable;
623
+ }
624
+
625
+ /**
626
+ * @author Toru Nagashima <https://github.com/mysticatea>
627
+ * See LICENSE file in root directory for full license.
628
+ */
629
+
630
+ var noRestrictedDisable;
631
+ var hasRequiredNoRestrictedDisable;
632
+
633
+ function requireNoRestrictedDisable () {
634
+ if (hasRequiredNoRestrictedDisable) return noRestrictedDisable;
635
+ hasRequiredNoRestrictedDisable = 1;
636
+
637
+ const ignore = requireIgnore();
638
+ const DisabledArea = requireDisabledArea();
639
+ const utils = requireUtils$1();
640
+
641
+ noRestrictedDisable = {
642
+ meta: {
643
+ docs: {
644
+ description:
645
+ "disallow `eslint-disable` comments about specific rules",
646
+ category: "Stylistic Issues",
647
+ recommended: false,
648
+ url:
649
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-restricted-disable.html",
650
+ },
651
+ fixable: null,
652
+ schema: {
653
+ type: "array",
654
+ items: { type: "string" },
655
+ uniqueItems: true,
656
+ },
657
+ type: "suggestion",
658
+ },
659
+
660
+ create(context) {
661
+ const sourceCode = context.getSourceCode();
662
+ const disabledArea = DisabledArea.get(sourceCode);
663
+
664
+ if (context.options.length === 0) {
665
+ return {}
666
+ }
667
+
668
+ const ig = ignore();
669
+ for (const pattern of context.options) {
670
+ ig.add(pattern);
671
+ }
672
+
673
+ return {
674
+ Program() {
675
+ for (const area of disabledArea.areas) {
676
+ if (area.ruleId == null || ig.ignores(area.ruleId)) {
677
+ context.report({
678
+ loc: utils.toRuleIdLocation(
679
+ area.comment,
680
+ area.ruleId
681
+ ),
682
+ message: "Disabling '{{ruleId}}' is not allowed.",
683
+ data: {
684
+ ruleId: area.ruleId || String(context.options),
685
+ },
686
+ });
687
+ }
688
+ }
689
+ },
690
+ }
691
+ },
692
+ };
693
+ return noRestrictedDisable;
694
+ }
695
+
696
+ /**
697
+ * @author Toru Nagashima <https://github.com/mysticatea>
698
+ * See LICENSE file in root directory for full license.
699
+ */
700
+
701
+ var noUnlimitedDisable;
702
+ var hasRequiredNoUnlimitedDisable;
703
+
704
+ function requireNoUnlimitedDisable () {
705
+ if (hasRequiredNoUnlimitedDisable) return noUnlimitedDisable;
706
+ hasRequiredNoUnlimitedDisable = 1;
707
+
708
+ const utils = requireUtils$1();
709
+
710
+ noUnlimitedDisable = {
711
+ meta: {
712
+ docs: {
713
+ description:
714
+ "disallow `eslint-disable` comments without rule names",
715
+ category: "Best Practices",
716
+ recommended: true,
717
+ url:
718
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable.html",
719
+ },
720
+ fixable: null,
721
+ schema: [],
722
+ type: "suggestion",
723
+ },
724
+
725
+ create(context) {
726
+ const sourceCode = context.getSourceCode();
727
+
728
+ return {
729
+ Program() {
730
+ for (const comment of sourceCode.getAllComments()) {
731
+ const directiveComment = utils.parseDirectiveComment(
732
+ comment
733
+ );
734
+ if (directiveComment == null) {
735
+ continue
736
+ }
737
+
738
+ const kind = directiveComment.kind;
739
+ if (
740
+ kind !== "eslint-disable" &&
741
+ kind !== "eslint-disable-line" &&
742
+ kind !== "eslint-disable-next-line"
743
+ ) {
744
+ continue
745
+ }
746
+ if (!directiveComment.value) {
747
+ context.report({
748
+ loc: utils.toForceLocation(comment.loc),
749
+ message:
750
+ "Unexpected unlimited '{{kind}}' comment. Specify some rule names to disable.",
751
+ data: { kind: directiveComment.kind },
752
+ });
753
+ }
754
+ }
755
+ },
756
+ }
757
+ },
758
+ };
759
+ return noUnlimitedDisable;
760
+ }
761
+
762
+ /**
763
+ * @author Toru Nagashima <https://github.com/mysticatea>
764
+ * See LICENSE file in root directory for full license.
765
+ */
766
+
767
+ var getLinters;
768
+ var hasRequiredGetLinters;
769
+
770
+ function requireGetLinters () {
771
+ if (hasRequiredGetLinters) return getLinters;
772
+ hasRequiredGetLinters = 1;
773
+
774
+ const path = require$$0;
775
+ const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}`;
776
+
777
+ getLinters = () => {
778
+ const eslintPaths = new Set(
779
+ Object.keys(require.cache)
780
+ .filter(id => id.includes(needle))
781
+ .map(id => id.slice(0, id.indexOf(needle) + needle.length))
782
+ );
783
+ const linters = [];
784
+
785
+ for (const eslintPath of eslintPaths) {
786
+ try {
787
+ const linter = commonjsRequire(eslintPath).Linter;
788
+
789
+ if (linter) {
790
+ linters.push(linter);
791
+ }
792
+ } catch (error) {
793
+ if (error.code !== "MODULE_NOT_FOUND") {
794
+ throw error
795
+ }
796
+ }
797
+ }
798
+
799
+ return linters
800
+ };
801
+ return getLinters;
802
+ }
803
+
804
+ /**
805
+ * @author Toru Nagashima <https://github.com/mysticatea>
806
+ * See LICENSE file in root directory for full license.
807
+ */
808
+
809
+ var patch;
810
+ var hasRequiredPatch;
811
+
812
+ function requirePatch () {
813
+ if (hasRequiredPatch) return patch;
814
+ hasRequiredPatch = 1;
815
+
816
+ const getLinters = requireGetLinters();
817
+ const { toRuleIdLocation } = requireUtils$1();
818
+ const quotedName = /'(.+?)'/u;
819
+
820
+ /**
821
+ * Get the severity of a given rule.
822
+ * @param {object} config The config object to check.
823
+ * @param {string} ruleId The rule ID to check.
824
+ * @returns {number} The severity of the rule.
825
+ */
826
+ function getSeverity(config, ruleId) {
827
+ const rules = config && config.rules;
828
+ const ruleOptions = rules && rules[ruleId];
829
+ const severity = Array.isArray(ruleOptions) ? ruleOptions[0] : ruleOptions;
830
+
831
+ switch (severity) {
832
+ case 2:
833
+ case "error":
834
+ return 2
835
+
836
+ case 1:
837
+ case "warn":
838
+ return 1
839
+
840
+ default:
841
+ return 0
842
+ }
843
+ }
844
+
845
+ /**
846
+ * Get the comment which is at a given message location.
847
+ * @param {Message} message The message to get.
848
+ * @param {SourceCode|undefined} sourceCode The source code object to get.
849
+ * @returns {Comment|undefined} The gotten comment.
850
+ */
851
+ function getCommentAt(message, sourceCode) {
852
+ if (sourceCode != null) {
853
+ const loc = { line: message.line, column: message.column - 1 };
854
+ const index = sourceCode.getIndexFromLoc(loc);
855
+ const options = { includeComments: true };
856
+ const comment = sourceCode.getTokenByRangeStart(index, options);
857
+ if (
858
+ comment != null &&
859
+ (comment.type === "Line" || comment.type === "Block")
860
+ ) {
861
+ return comment
862
+ }
863
+ }
864
+ return undefined
865
+ }
866
+
867
+ /**
868
+ * Check whether a given message is a `reportUnusedDisableDirectives` error.
869
+ * @param {Message} message The message.
870
+ * @returns {boolean} `true` if the message is a `reportUnusedDisableDirectives` error.
871
+ */
872
+ function isUnusedDisableDirectiveError(message) {
873
+ return (
874
+ !message.fatal &&
875
+ !message.ruleId &&
876
+ message.message.includes("eslint-disable")
877
+ )
878
+ }
879
+
880
+ /**
881
+ * Create `eslint-comments/no-unused-disable` error.
882
+ * @param {string} ruleId The ruleId.
883
+ * @param {number} severity The severity of the rule.
884
+ * @param {Message} message The original message.
885
+ * @param {Comment|undefined} comment The directive comment.
886
+ * @returns {Message} The created error.
887
+ */
888
+ function createNoUnusedDisableError(ruleId, severity, message, comment) {
889
+ const clone = Object.assign({}, message);
890
+ const match = quotedName.exec(message.message);
891
+ const targetRuleId = match && match[1];
892
+
893
+ clone.ruleId = ruleId;
894
+ clone.severity = severity;
895
+ clone.message = targetRuleId
896
+ ? `'${targetRuleId}' rule is disabled but never reported.`
897
+ : "ESLint rules are disabled but never reported.";
898
+ clone.suggestions = [];
899
+
900
+ if (comment != null) {
901
+ if (targetRuleId) {
902
+ const loc = toRuleIdLocation(comment, targetRuleId);
903
+ clone.line = loc.start.line;
904
+ clone.column = loc.start.column + 1;
905
+ clone.endLine = loc.end.line;
906
+ clone.endColumn = loc.end.column + 1;
907
+ } else {
908
+ clone.endLine = comment.loc.end.line;
909
+ clone.endColumn = comment.loc.end.column + 1;
910
+ }
911
+ // Remove the whole node if it is the only rule, otherwise
912
+ // don't try to fix because it is quite complicated.
913
+ if (!comment.value.includes(",") && !comment.value.includes("--")) {
914
+ // We can't use the typical `fixer` helper because we are injecting
915
+ // this message after the fixes are resolved.
916
+ clone.suggestions = [
917
+ {
918
+ desc: "Remove `eslint-disable` comment.",
919
+ fix: {
920
+ range: comment.range,
921
+ text: comment.value.includes("\n") ? "\n" : "",
922
+ },
923
+ },
924
+ ];
925
+ }
926
+ }
927
+
928
+ return clone
929
+ }
930
+
931
+ /**
932
+ * Convert `reportUnusedDisableDirectives` errors to `eslint-comments/no-unused-disable` errors.
933
+ * @param {Message[]} messages The original messages.
934
+ * @param {SourceCode|undefined} sourceCode The source code object.
935
+ * @param {string} ruleId The rule ID to convert.
936
+ * @param {number} severity The severity of the rule.
937
+ * @param {boolean} keepAsIs The flag to keep original errors as is.
938
+ * @returns {Message[]} The converted messages.
939
+ */
940
+ function convert(messages, sourceCode, ruleId, severity, keepAsIs) {
941
+ for (let i = messages.length - 1; i >= 0; --i) {
942
+ const message = messages[i];
943
+ if (!isUnusedDisableDirectiveError(message)) {
944
+ continue
945
+ }
946
+
947
+ const newMessage = createNoUnusedDisableError(
948
+ ruleId,
949
+ severity,
950
+ message,
951
+ getCommentAt(message, sourceCode)
952
+ );
953
+
954
+ if (keepAsIs) {
955
+ messages.splice(i + 1, 0, newMessage);
956
+ } else {
957
+ messages.splice(i, 1, newMessage);
958
+ }
959
+ }
960
+
961
+ return messages
962
+ }
963
+
964
+ patch = (ruleId = "eslint-comments/no-unused-disable") => {
965
+ for (const Linter of getLinters()) {
966
+ const verify0 = Linter.prototype._verifyWithoutProcessors;
967
+ Object.defineProperty(Linter.prototype, "_verifyWithoutProcessors", {
968
+ value: function _verifyWithoutProcessors(
969
+ textOrSourceCode,
970
+ config,
971
+ filenameOrOptions
972
+ ) {
973
+ const severity = getSeverity(config, ruleId);
974
+ if (severity === 0) {
975
+ return verify0.call(
976
+ this,
977
+ textOrSourceCode,
978
+ config,
979
+ filenameOrOptions
980
+ )
981
+ }
982
+
983
+ const options =
984
+ typeof filenameOrOptions === "string"
985
+ ? { filename: filenameOrOptions }
986
+ : filenameOrOptions || {};
987
+ const reportUnusedDisableDirectives = Boolean(
988
+ options.reportUnusedDisableDirectives
989
+ );
990
+ const messages = verify0.call(
991
+ this,
992
+ textOrSourceCode,
993
+ config,
994
+ Object.assign({}, options, {
995
+ reportUnusedDisableDirectives: true,
996
+ })
997
+ );
998
+ return convert(
999
+ messages,
1000
+ this.getSourceCode(),
1001
+ ruleId,
1002
+ severity,
1003
+ reportUnusedDisableDirectives
1004
+ )
1005
+ },
1006
+ configurable: true,
1007
+ writable: true,
1008
+ });
1009
+ }
1010
+ };
1011
+ return patch;
1012
+ }
1013
+
1014
+ /**
1015
+ * @author Toru Nagashima <https://github.com/mysticatea>
1016
+ * See LICENSE file in root directory for full license.
1017
+ */
1018
+
1019
+ var noUnusedDisable;
1020
+ var hasRequiredNoUnusedDisable;
1021
+
1022
+ function requireNoUnusedDisable () {
1023
+ if (hasRequiredNoUnusedDisable) return noUnusedDisable;
1024
+ hasRequiredNoUnusedDisable = 1;
1025
+
1026
+ // Patch `Linter#verify` to work.
1027
+ requirePatch()();
1028
+
1029
+ noUnusedDisable = {
1030
+ meta: {
1031
+ docs: {
1032
+ description: "disallow unused `eslint-disable` comments",
1033
+ category: "Best Practices",
1034
+ recommended: false,
1035
+ url:
1036
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html",
1037
+ },
1038
+ fixable: null,
1039
+ schema: [],
1040
+ type: "problem",
1041
+ },
1042
+
1043
+ create() {
1044
+ // This rule patches `Linter#verify` method and:
1045
+ //
1046
+ // 1. enables `reportUnusedDisableDirectives` option.
1047
+ // 2. verifies the code.
1048
+ // 3. converts `reportUnusedDisableDirectives` errors to `no-unused-disable` errors.
1049
+ //
1050
+ // So this rule itself does nothing.
1051
+ return {}
1052
+ },
1053
+ };
1054
+ return noUnusedDisable;
1055
+ }
1056
+
1057
+ /**
1058
+ * @author Toru Nagashima <https://github.com/mysticatea>
1059
+ * See LICENSE file in root directory for full license.
1060
+ */
1061
+
1062
+ var noUnusedEnable;
1063
+ var hasRequiredNoUnusedEnable;
1064
+
1065
+ function requireNoUnusedEnable () {
1066
+ if (hasRequiredNoUnusedEnable) return noUnusedEnable;
1067
+ hasRequiredNoUnusedEnable = 1;
1068
+
1069
+ const DisabledArea = requireDisabledArea();
1070
+ const utils = requireUtils$1();
1071
+
1072
+ noUnusedEnable = {
1073
+ meta: {
1074
+ docs: {
1075
+ description: "disallow unused `eslint-enable` comments",
1076
+ category: "Best Practices",
1077
+ recommended: true,
1078
+ url:
1079
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-enable.html",
1080
+ },
1081
+ fixable: null,
1082
+ schema: [],
1083
+ type: "problem",
1084
+ },
1085
+
1086
+ create(context) {
1087
+ const sourceCode = context.getSourceCode();
1088
+ const disabledArea = DisabledArea.get(sourceCode);
1089
+
1090
+ return {
1091
+ Program() {
1092
+ for (const item of disabledArea.unusedEnableDirectives) {
1093
+ context.report({
1094
+ loc: utils.toRuleIdLocation(item.comment, item.ruleId),
1095
+ message: item.ruleId
1096
+ ? "'{{ruleId}}' rule is re-enabled but it has not been disabled."
1097
+ : "ESLint rules are re-enabled but those have not been disabled.",
1098
+ data: item,
1099
+ });
1100
+ }
1101
+ },
1102
+ }
1103
+ },
1104
+ };
1105
+ return noUnusedEnable;
1106
+ }
1107
+
1108
+ /**
1109
+ * @author Toru Nagashima <https://github.com/mysticatea>
1110
+ * See LICENSE file in root directory for full license.
1111
+ */
1112
+
1113
+ var noUse;
1114
+ var hasRequiredNoUse;
1115
+
1116
+ function requireNoUse () {
1117
+ if (hasRequiredNoUse) return noUse;
1118
+ hasRequiredNoUse = 1;
1119
+
1120
+ const utils = requireUtils$1();
1121
+
1122
+ noUse = {
1123
+ meta: {
1124
+ docs: {
1125
+ description: "disallow ESLint directive-comments",
1126
+ category: "Stylistic Issues",
1127
+ recommended: false,
1128
+ url:
1129
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html",
1130
+ },
1131
+ fixable: null,
1132
+ schema: [
1133
+ {
1134
+ type: "object",
1135
+ properties: {
1136
+ allow: {
1137
+ type: "array",
1138
+ items: {
1139
+ enum: [
1140
+ "eslint",
1141
+ "eslint-disable",
1142
+ "eslint-disable-line",
1143
+ "eslint-disable-next-line",
1144
+ "eslint-enable",
1145
+ "eslint-env",
1146
+ "exported",
1147
+ "global",
1148
+ "globals",
1149
+ ],
1150
+ },
1151
+ additionalItems: false,
1152
+ uniqueItems: true,
1153
+ },
1154
+ },
1155
+ additionalProperties: false,
1156
+ },
1157
+ ],
1158
+ type: "suggestion",
1159
+ },
1160
+
1161
+ create(context) {
1162
+ const sourceCode = context.getSourceCode();
1163
+ const allowed = new Set(
1164
+ (context.options[0] && context.options[0].allow) || []
1165
+ );
1166
+
1167
+ return {
1168
+ Program() {
1169
+ for (const comment of sourceCode.getAllComments()) {
1170
+ const directiveComment = utils.parseDirectiveComment(
1171
+ comment
1172
+ );
1173
+ if (directiveComment == null) {
1174
+ continue
1175
+ }
1176
+
1177
+ if (!allowed.has(directiveComment.kind)) {
1178
+ context.report({
1179
+ loc: utils.toForceLocation(comment.loc),
1180
+ message: "Unexpected ESLint directive comment.",
1181
+ });
1182
+ }
1183
+ }
1184
+ },
1185
+ }
1186
+ },
1187
+ };
1188
+ return noUse;
1189
+ }
1190
+
1191
+ /**
1192
+ * @author Yosuke Ota <https://github.com/ota-meshi>
1193
+ * See LICENSE file in root directory for full license.
1194
+ */
1195
+
1196
+ var requireDescription;
1197
+ var hasRequiredRequireDescription;
1198
+
1199
+ function requireRequireDescription () {
1200
+ if (hasRequiredRequireDescription) return requireDescription;
1201
+ hasRequiredRequireDescription = 1;
1202
+
1203
+ const utils = requireUtils$1();
1204
+
1205
+ requireDescription = {
1206
+ meta: {
1207
+ docs: {
1208
+ description:
1209
+ "require include descriptions in ESLint directive-comments",
1210
+ category: "Stylistic Issues",
1211
+ recommended: false,
1212
+ url:
1213
+ "https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html",
1214
+ },
1215
+ fixable: null,
1216
+ schema: [
1217
+ {
1218
+ type: "object",
1219
+ properties: {
1220
+ ignore: {
1221
+ type: "array",
1222
+ items: {
1223
+ enum: [
1224
+ "eslint",
1225
+ "eslint-disable",
1226
+ "eslint-disable-line",
1227
+ "eslint-disable-next-line",
1228
+ "eslint-enable",
1229
+ "eslint-env",
1230
+ "exported",
1231
+ "global",
1232
+ "globals",
1233
+ ],
1234
+ },
1235
+ additionalItems: false,
1236
+ uniqueItems: true,
1237
+ },
1238
+ },
1239
+ additionalProperties: false,
1240
+ },
1241
+ ],
1242
+ type: "suggestion",
1243
+ },
1244
+
1245
+ create(context) {
1246
+ const sourceCode = context.getSourceCode();
1247
+ const ignores = new Set(
1248
+ (context.options[0] && context.options[0].ignore) || []
1249
+ );
1250
+
1251
+ return {
1252
+ Program() {
1253
+ for (const comment of sourceCode.getAllComments()) {
1254
+ const directiveComment = utils.parseDirectiveComment(
1255
+ comment
1256
+ );
1257
+ if (directiveComment == null) {
1258
+ continue
1259
+ }
1260
+ if (ignores.has(directiveComment.kind)) {
1261
+ continue
1262
+ }
1263
+ if (!directiveComment.description) {
1264
+ context.report({
1265
+ loc: utils.toForceLocation(comment.loc),
1266
+ message:
1267
+ "Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary.",
1268
+ });
1269
+ }
1270
+ }
1271
+ },
1272
+ }
1273
+ },
1274
+ };
1275
+ return requireDescription;
1276
+ }
1277
+
1278
+ /** DON'T EDIT THIS FILE; was created by scripts. */
1279
+
1280
+ var rules;
1281
+ var hasRequiredRules;
1282
+
1283
+ function requireRules () {
1284
+ if (hasRequiredRules) return rules;
1285
+ hasRequiredRules = 1;
1286
+
1287
+ rules = {
1288
+ "disable-enable-pair": requireDisableEnablePair(),
1289
+ "no-aggregating-enable": requireNoAggregatingEnable(),
1290
+ "no-duplicate-disable": requireNoDuplicateDisable(),
1291
+ "no-restricted-disable": requireNoRestrictedDisable(),
1292
+ "no-unlimited-disable": requireNoUnlimitedDisable(),
1293
+ "no-unused-disable": requireNoUnusedDisable(),
1294
+ "no-unused-enable": requireNoUnusedEnable(),
1295
+ "no-use": requireNoUse(),
1296
+ "require-description": requireRequireDescription(),
1297
+ };
1298
+ return rules;
1299
+ }
1300
+
1301
+ /** DON'T EDIT THIS FILE; was created by scripts. */
1302
+
1303
+ var utils;
1304
+ var hasRequiredUtils;
1305
+
1306
+ function requireUtils () {
1307
+ if (hasRequiredUtils) return utils;
1308
+ hasRequiredUtils = 1;
1309
+
1310
+ utils = {
1311
+ patch: requirePatch(),
1312
+ };
1313
+ return utils;
1314
+ }
1315
+
1316
+ /** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */
1317
+
1318
+ var eslintPluginEslintComments;
1319
+ var hasRequiredEslintPluginEslintComments;
1320
+
1321
+ function requireEslintPluginEslintComments () {
1322
+ if (hasRequiredEslintPluginEslintComments) return eslintPluginEslintComments;
1323
+ hasRequiredEslintPluginEslintComments = 1;
1324
+
1325
+ eslintPluginEslintComments = {
1326
+ configs: requireConfigs(),
1327
+ rules: requireRules(),
1328
+ utils: requireUtils(),
1329
+ };
1330
+ return eslintPluginEslintComments;
1331
+ }
1332
+
1333
+ var eslintPluginEslintCommentsExports = requireEslintPluginEslintComments();
1334
+ const index = /*@__PURE__*/getDefaultExportFromCjs(eslintPluginEslintCommentsExports);
1335
+
1336
+ const index$1 = /*#__PURE__*/_mergeNamespaces({
1337
+ __proto__: null,
1338
+ default: index
1339
+ }, [eslintPluginEslintCommentsExports]);
1340
+
1341
+ export { index$1 as i };