1 | 'use strict';
|
2 | const getDocumentationUrl = require('./utils/get-documentation-url');
|
3 |
|
4 | const disableRegex = /^eslint-disable(?:-next-line|-line)?(?<ruleId>$|(?:\s+(?:@(?:[\w-]+\/){1,2})?[\w-]+)?)/;
|
5 |
|
6 | const create = context => ({
|
7 | Program: node => {
|
8 | for (const comment of node.comments) {
|
9 | const value = comment.value.trim();
|
10 | const result = disableRegex.exec(value);
|
11 |
|
12 | if (
|
13 | result &&
|
14 | !result.groups.ruleId
|
15 | ) {
|
16 | context.report({
|
17 | loc: {
|
18 | start: {
|
19 | ...comment.loc.start,
|
20 | column: -1
|
21 | },
|
22 | end: comment.loc.end
|
23 | },
|
24 | message: 'Specify the rules you want to disable.'
|
25 | });
|
26 | }
|
27 | }
|
28 | }
|
29 | });
|
30 |
|
31 | module.exports = {
|
32 | create,
|
33 | meta: {
|
34 | type: 'suggestion',
|
35 | docs: {
|
36 | url: getDocumentationUrl(__filename)
|
37 | }
|
38 | }
|
39 | };
|