"error 'Set' is not defined no-undef" in ecmaVersion 2017
See original GitHub issueTell us about your environment
-
ESLint Version: └─┬ gulp-eslint@3.0.1 └── eslint@3.12.2
-
Node Version: v4.2.6
-
npm Version: npm: ‘3.5.2’
What parser (default, Babel-ESLint, etc.) are you using?
gulp-eslint
Please show your full configuration:
env:
browser: true # Enable Browser global variables
parserOptions:
ecmaVersion: 2017 # Validate ECMAScript 2016 features
sourceType: module # Allow ECMAScript modules
globals:
PIXI: false
Phaser: false
extends: 'eslint:recommended'
rules:
indent: [2, 2] # Indent code with 2 spaces
quotes: [2, single] # Use single quotes for strings
linebreak-style: [2, unix] # Favor Unix-style line endings
semi: [2, always] # End lines with semicolons
What did you do? Please include the actual source code causing the issue.
static getLockedBirds(game){
var allBirdIds=new Set();
for(let i=0;i<=game.animationInfo.maxBirdFrame;i++){
allBirdIds.add(i);
}
var unlockedBirds = new Set(DataAccess.getConfig('unlockedBirdSprites'));
var lockedBirds = [...allBirdIds].filter(x => !unlockedBirds.has(x)); //find all bird ids that are not in the unlocked set but ARE in the allBird set
return lockedBirds;
}
What did you expect to happen?
Set is a ECMA 2015 object. By using ECMA 8/2017 I expected the parser to recognize this. If I add es6: true
to the environment configuration, no error is thrown
What actually happened? Please include the actual, raw output from ESLint.
/home/james/Documents/birdu/src/objects/Helpers/DataAccess.js
31:24 error 'Set' is not defined no-undef
36:29 error 'Set' is not defined no-undef
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
ESLint: Why is Symbol not defined (no-undef rule)?
For some reason, Typescript (or Babel) is unable to recognise Symbol and is giving me an error that Symbol is not defined ....
Read more >1, 2, 3, linted | Better world by better software - Gleb Bahmutov
JsHint is the oldest, with very stable API and large set of rules it ... /1-2-3-linted/index.js 1:1 error "foo" is not defined no-undef...
Read more >eslint/eslint - Gitter
Hey just a short question, is there any mechanism that helps me managing globals? I don't want to add them to a config...
Read more >Intro to ESLint Config Files - Mastering JS
ESLint config files let you define what rules ESLint enforces and what environment your project is targetting. Here's what you need to know....
Read more >JSHint Options Reference
This option sets a specific tab width for your code. latedef. This option prohibits the use of a variable before it was defined....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, thanks for the report.
The
parserOptions
config only handles options for the parser (e.g. if you’re using ES6 syntax). However, it doesn’t affect the list of availale globals, which is used by rules likeno-undef
. To set ES6 globals, you should addenv: {es6: true}
to your config (as you mentioned you did).Agreed, for some reason I thought we mentioned ecmaVersion but you are right, it links to the Configuring page.
I’d like to see a paragraph on the difference between ecmaVersion (syntax) and envs (globals), yeah.