Description
Tell us about your environment
- ESLint Version: v7.27.0
- Node Version: v12.18.4
- npm Version: v6.14.6
- Operating System: windows
What parser (default, @babel/eslint-parser
, @typescript-eslint/parser
, etc.) are you using?
default
Please show your full configuration:
Configuration
module.exports = {
rules: {
"no-undef": "error"
}
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
/* eslint-env browser
*/
window;
npx eslint index.js
What did you expect to happen?
no no-undef
errors, because browser
environment enables window
global
What actually happened? Please copy-paste the actual, raw output from ESLint.
4:1 error 'window' is not defined no-undef
Steps to reproduce this issue:
Are you willing to submit a pull request to fix this bug?
Yes, if it is a bug.
The issue is: linter ignores multiline /* eslint-env ... */
comments. A single-line comment works well, as in this demo.
I couldn't find a test case or a discussion that would confirm that this was intentional. It looks like a common bug with .
in a regular expression that doesn't have the s
flag.
Also, noInlineConfig: true
option does report multiline eslint-env
as a directive:
module.exports = {
rules: {
"no-undef": "error"
},
noInlineConfig: true
};
/* eslint-env browser
*/
window;
1:1 warning '/*eslint-env*/' has no effect because you have 'noInlineConfig' setting in your config (.eslintrc.js)
4:1 error 'window' is not defined
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Milestone
Relationships
Development
- Update: support multiline /*eslint-env*/ directives (fixes #14652)eslint/eslint
- [Snyk] Upgrade eslint from 7.26.0 to 7.32.0ManuelDevWeb/platziVideoReactRouterYRedux
- [Snyk] Upgrade eslint from 7.26.0 to 7.32.0ManuelDevWeb/platziVideoReact
- [Snyk] Upgrade eslint from 7.16.0 to 7.32.0Tanver-Hasan/nextjs-boilerplate
- [Snyk] Upgrade eslint from 7.16.0 to 7.32.0Tanver-Hasan/nextjs-boilerplate
- [Snyk] Upgrade eslint from 7.16.0 to 7.32.0Tanver-Hasan/nextjs-boilerplate
- [Snyk] Upgrade eslint from 7.16.0 to 7.32.0Tanver-Hasan/nextjs-boilerplate
- [Snyk] Upgrade eslint from 7.16.0 to 7.32.0Tanver-Hasan/nextjs-boilerplate
- [Snyk] Upgrade eslint from 7.26.0 to 7.32.0ManuelDevWeb/platziVideoReactRouterYRedux
- [Snyk] Upgrade eslint from 7.26.0 to 7.32.0ManuelDevWeb/platziVideoReact
Activity
Fix: linter ignores multiline /*eslint-env*/ directives (fixes eslint…
mdjermanovic commentedon Jun 3, 2021
@eslint/eslint-tsc Thoughts about this? I think this is a bug, but would like another confirmation. We have PR #14660 prepared.
nzakas commentedon Jun 4, 2021
Most likely a bug. I’m not sure how much it matters since this feature will be going away, but no objections to fixing it.
Update: support multiline /*eslint-env*/ directives (fixes #14652) (#…