Configuration globals "off" is not respected for TypeScript files
See original GitHub issueTell us about your environment
$ eslint --env-info Environment Info:
Node version: v10.11.0 npm version: v6.4.1 Local ESLint version: v6.8.0 Global ESLint version: v6.8.0 (Currently used)
What parser (default, Babel-ESLint, etc.) are you using?
"parser": "@typescript-eslint/parser"
Please show your full configuration:
Configuration
module.exports = {
"root": true,
"parserOptions": {
"ecmaVersion": 6
},
"extends": [
"eslint:recommended"
],
"plugins": [
"@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"overrides": [{
"files": ["**/*.ts"],
"parserOptions": {
"sourceType": "module"
},
"globals": {
"console": "off",
"document": "off",
"window": "off"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
]
}]
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
I want to turn off the globals such as console
, document
and window
, and want eslint to show errors when people try to access them.
// test1.js
// eslint works well in javascript file. All three globals are found and errors are thrown.
console.log(document, window);
// test2.ts
// eslint just silently let these globals pass in typescript file.
console.log(document, window);
$ eslint --ext .ts,.js test1.js
...\test1.js
1:1 error 'console' is not defined no-undef
1:13 error 'document' is not defined no-undef
1:23 error 'window' is not defined no-undef
✖ 3 problems (3 errors, 0 warnings)
$ eslint --ext .ts,.js test2.ts
What did you expect to happen?
I expect that eslint
can catch the turned-off globals console
, document
and window
in the TypeScript file.
What actually happened? Please include the actual, raw output from ESLint.
eslint
just let these globals pass without showing any errors for TypeScript files. =(
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I believe this is happening because
@typescript-eslint/eslint-recommended
from your configuration disables the coreno-undef
rule, as described here:From eslint-recommended.ts:
It looks like the conversation is stalled here. As this is a question rather than an action item, I’m closing the issue. If you still need help, please send a message to our mailing list or chatroom. Thanks! [//]: # (auto-close)