Skip to content

Commit

Permalink
Revert "fix: update astUtils.isDirectiveComment with globals and …
Browse files Browse the repository at this point in the history
…`exported` (eslint#15775)"

This reverts commit bd8cad3.
  • Loading branch information
srijan-deepsource committed May 30, 2022
1 parent a41378e commit b0984ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
9 changes: 6 additions & 3 deletions lib/rules/utils/ast-utils.js
Expand Up @@ -32,7 +32,6 @@ const thisTagPattern = /^[\s*]*@this/mu;


const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
const ESLINT_DIRECTIVE_PATTERN = /^(?:eslint[- ]|(?:globals?|exported) )/u;
const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);

// A set of node types that can contain a list of statements
Expand Down Expand Up @@ -909,8 +908,12 @@ module.exports = {
const comment = node.value.trim();

return (
node.type === "Line" && comment.startsWith("eslint-") ||
node.type === "Block" && ESLINT_DIRECTIVE_PATTERN.test(comment)
node.type === "Line" && comment.indexOf("eslint-") === 0 ||
node.type === "Block" && (
comment.indexOf("global ") === 0 ||
comment.indexOf("eslint ") === 0 ||
comment.indexOf("eslint-") === 0
)
);
},

Expand Down
3 changes: 0 additions & 3 deletions tests/lib/rules/no-inline-comments.js
Expand Up @@ -39,9 +39,6 @@ ruleTester.run("no-inline-comments", rule, {
"// A solitary comment",
"var a = 1; // eslint-disable-line no-debugger",
"var a = 1; /* eslint-disable-line no-debugger */",
"foo(); /* global foo */",
"foo(); /* globals foo */",
"var foo; /* exported foo */",

// JSX exception
`var a = (
Expand Down
10 changes: 2 additions & 8 deletions tests/lib/rules/utils/ast-utils.js
Expand Up @@ -204,10 +204,7 @@ describe("ast-utils", () => {
"// lalala I'm a normal comment",
"// trying to confuse eslint ",
"//trying to confuse eslint-directive-detection",
"//eslint is awesome",
"//global line comment is not a directive",
"//globals line comment is not a directive",
"//exported line comment is not a directive"
"//eslint is awesome"
].join("\n");
const ast = espree.parse(code, ESPREE_CONFIG);
const sourceCode = new SourceCode(code, ast);
Expand Down Expand Up @@ -250,10 +247,7 @@ describe("ast-utils", () => {
"/*eslint-enable no-undef*/",
"/* eslint-env {\"es6\": true} */",
"/* eslint foo */",
"/*eslint bar*/",
"/*global foo*/",
"/*globals foo*/",
"/*exported foo*/"
"/*eslint bar*/"
].join("\n");
const ast = espree.parse(code, ESPREE_CONFIG);
const sourceCode = new SourceCode(code, ast);
Expand Down

0 comments on commit b0984ef

Please sign in to comment.