UNPKG

833 BJavaScriptView Raw
1'use strict';
2const getDocumentationUrl = require('./utils/get-documentation-url');
3
4const disableRegex = /^eslint-disable(?:-next-line|-line)?(?<ruleId>$|(?:\s+(?:@(?:[\w-]+\/){1,2})?[\w-]+)?)/;
5
6const 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 && // It's a eslint-disable comment
14 !result.groups.ruleId // But it did not specify any rules
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
31module.exports = {
32 create,
33 meta: {
34 type: 'suggestion',
35 docs: {
36 url: getDocumentationUrl(__filename)
37 }
38 }
39};