diff --git a/lib/linter/linter.js b/lib/linter/linter.js index 44e88f845fa..e94b507b5dd 100644 --- a/lib/linter/linter.js +++ b/lib/linter/linter.js @@ -444,7 +444,7 @@ function normalizeEcmaVersion(ecmaVersion) { return ecmaVersion >= 2015 ? ecmaVersion - 2009 : ecmaVersion; } -const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//gu; +const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)\*\//gsu; /** * Checks whether or not there is a comment which has "eslint-env *" in a given text. diff --git a/tests/lib/linter/linter.js b/tests/lib/linter/linter.js index bcf3edfb90c..e61804d3ae7 100644 --- a/tests/lib/linter/linter.js +++ b/tests/lib/linter/linter.js @@ -2973,6 +2973,23 @@ var a = "test2"; assert.strictEqual(messages.length, 0); }); + // https://github.com/eslint/eslint/issues/14652 + it("should not report a violation", () => { + const codes = [ + "/*eslint-env es6\n */ new Promise();", + "/*eslint-env browser,\nes6 */ window;Promise;", + "/*eslint-env\nbrowser,es6 */ window;Promise;" + ]; + const config = { rules: { "no-undef": 1 } }; + + for (const code of codes) { + const messages = linter.verify(code, config, filename); + + assert.strictEqual(messages.length, 0); + } + + }); + it("should not report a violation", () => { const code = `/*${ESLINT_ENV} mocha,node */ require();describe();`;