question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"error 'Set' is not defined no-undef" in ecmaVersion 2017

See original GitHub issue

Tell 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:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
not-an-aardvarkcommented, Jan 26, 2017

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 like no-undef. To set ES6 globals, you should add env: {es6: true} to your config (as you mentioned you did).

3reactions
platinumazurecommented, Jan 26, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found