Repository: eslint/eslint (js)

Issue:
`System` not detected as an undefined variable
**Tell us about your environment**

* **ESLint Version:** 4.11.0
* **Node Version:** 8.6.0

**What parser (default, Babel-ESLint, etc.) are you using?**
default

**Please show your full configuration:**

<details>
<summary>Configuration</summary>

<!-- Paste your configuration below: -->
```yaml
root: true
extends: eslint:recommended
parserOptions:
  ecmaVersion: 2017
  ecmaFeatures:
    impliedStrict: true
  sourceType: module
env:
  es6: true
  node: true
  mocha: true
  jasmine: true
rules:
  linebreak-style:
    - error
    - unix
  max-len:
    - warn
    - code: 80
      tabWidth: 2
      ignoreComments: true
      ignoreUrls: true
      ignoreTemplateLiterals: true
      ignoreRegExpLiterals: true
      ignorePattern: require\('
  indent:
    - error
    - 2
    - SwitchCase: 1
      VariableDeclarator:
        let: 2
        const: 3
      MemberExpression: off
  semi:
    - error
    - always
  consistent-this:
    - error
    - self
    - $ctrl
  quotes:
    - error
    - single
    - allowTemplateLiterals: true
  quote-props:
    - error
    - as-needed
  curly:
    - error
    - all
  comma-dangle:
    - error
    - always-multiline
  new-cap:
    - error
    - newIsCap: true
      capIsNew: true
      properties: false
  camelcase:
    - error
    - properties: never
  array-bracket-spacing:
    - error
    - never
  arrow-spacing:
    - error
    - before: true
      after: true
  block-spacing:
    - error
    - always
  comma-spacing:
    - error
    - before: false
      after: true
  computed-property-spacing:
    - error
    - never
  generator-star-spacing:
    - error
    - before: true
      after: false
  key-spacing:
    - error
    - beforeColon: false
      afterColon: true
      mode: minimum
  keyword-spacing:
    - error
    - before: true
  semi-spacing:
    - error
    - before: false
      after: true
  space-in-parens:
    - error
    - never
  space-unary-ops:
    - error
    - words: true
      nonwords: false
  space-before-function-paren:
    - error
    - anonymous: never
      named: never
      asyncArrow: always
  space-before-blocks:
    - error
    - always
  yoda:
    - error
    - never
  wrap-iife:
    - error
    - outside
  eqeqeq:
    - error
    - always
  newline-per-chained-call:
    - error
    - ignoreChainWithDepth: 3
  one-var-declaration-per-line:
    - error
    - initializations
  brace-style:
    - error
    - stroustrup
  no-implicit-coercion:
    - error
    - boolean: false
  no-global-assign:
    - error
    - exceptions:
        - Promise
  eol-last: error
  dot-notation: error
  space-infix-ops: error
  no-with: error
  no-unreachable: error
  no-redeclare: error
  no-unexpected-multiline: error
  no-multi-spaces: error
  no-multi-str: error
  no-trailing-spaces: error
  no-mixed-spaces-and-tabs: error
  no-spaced-func: error
  no-whitespace-before-property: error
  no-unsafe-negation: error
  no-lonely-if: error
  no-var: error
  no-console: off
```

</details>

**What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.**

<!-- Paste the source code below: -->
```js
console.log(System);
console.log(Blah);
```
(in test.js)

<!-- Paste the command you used to run ESLint: -->
```bash
eslint test.js
```

**What did you expect to happen?**
I expect to see two errors; 

1) 'System' is not defined
2) 'Blah' is not defined

**What actually happened? Please include the actual, raw output from ESLint.**
Only one error is shown:

```
  3:13  error  'Blah' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)
```

I've tried this across many files -- for some reason it doesn't flag `System` as an undefined variable, ever. I looked to see if I had it defined as a global, or if it was defined as a global in the [recommended preset](https://github.com/eslint/eslint/blob/master/conf/eslint-recommended.js), but it wasn't. It's also not a [global in Node](https://nodejs.org/api/globals.html), and the output of the console log is `undefined`.

Pull request description:
Update: upgrade `globals` to 11.0.1 (fixes #9614)
**What is the purpose of this pull request? (put an "X" next to item)**

[X] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))

Fixes #9614.
Closes #9555.

**What changes did you make? (Give an overview)**

This PR upgrades the dependency to `globals` package to `11.x` from `9.x` ([diff](https://github.com/sindresorhus/globals/compare/v9.17.0...v11.0.0#diff-1c916b21daa3b4eab4ea8661b409056c)).

Estimated effects:

- `no-undef` rule reports `System` variables (#9614).
- `no-shadow` and `no-redeclare` with `{builtinGlobals: true}` option no longer report `System` variables.
- `no-extend-native` rule reports about `Atomics` and `SharedBufferArray`.<br><br>
- ~~`node` environment no longer has the deprecated globals: `root`, `GLOBAL`, and `arguments`.~~
- `browser` environment is updated massively. The new globals are based on the global variables of current Chrome Canary. **EDIT:** there are not deleted variables
- `jasmine` gets `spyOnProperty` variable.
- `jest` gets `wait` variable ~~and no longer has `check` and `gen`.~~
- `greasemonkey` gets `GM` variable.

**Is there anything you'd like reviewers to focus on?**

I think we can release the changes in the next minor version because those are bug fixes.
But the diff is large a bit. What do you think?


Patch:
diff --git a/README.md b/README.md
index 3b7d6aca4..5a23d6295 100644
--- a/README.md
+++ b/README.md
@@ -225,7 +225,7 @@ In all cases, make sure your plugins' peerDependencies have been installed as we
 
 ### Does ESLint support JSX?
 
-Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring).). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
+Yes, ESLint natively supports parsing JSX syntax (this must be enabled in [configuration](https://eslint.org/docs/user-guide/configuring)). Please note that supporting JSX syntax *is not* the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) if you are using React and want React semantics.
 
 ### What about ECMAScript 6 support?
 
diff --git a/conf/environments.js b/conf/environments.js
index a11f2963d..44f2e0dee 100644
--- a/conf/environments.js
+++ b/conf/environments.js
@@ -17,10 +17,126 @@ const globals = require("globals");
 module.exports = {
     builtin: globals.es5,
     browser: {
-        globals: globals.browser
+
+        /*
+         * For backward compatibility.
+         * Remove those on the next major release.
+         */
+        globals: Object.assign(
+            {
+                AutocompleteErrorEvent: false,
+                CDATASection: false,
+                ClientRect: false,
+                ClientRectList: false,
+                CSSAnimation: false,
+                CSSTransition: false,
+                CSSUnknownRule: false,
+                CSSViewportRule: false,
+                Debug: false,
+                DocumentTimeline: false,
+                DOMSettableTokenList: false,
+                ElementTimeControl: false,
+                FederatedCredential: false,
+                FileError: false,
+                HTMLAppletElement: false,
+                HTMLBlockquoteElement: false,
+                HTMLIsIndexElement: false,
+                HTMLKeygenElement: false,
+                HTMLLayerElement: false,
+                IDBEnvironment: false,
+                InputMethodContext: false,
+                MediaKeyError: false,
+                MediaKeyEvent: false,
+                MediaKeys: false,
+                opera: false,
+                PasswordCredential: false,
+                ReadableByteStream: false,
+                SharedKeyframeList: false,
+                showModalDialog: false,
+                SiteBoundCredential: false,
+                SVGAltGlyphDefElement: false,
+                SVGAltGlyphElement: false,
+                SVGAltGlyphItemElement: false,
+                SVGAnimateColorElement: false,
+                SVGAnimatedPathData: false,
+                SVGAnimatedPoints: false,
+                SVGColor: false,
+                SVGColorProfileElement: false,
+                SVGColorProfileRule: false,
+                SVGCSSRule: false,
+                SVGCursorElement: false,
+                SVGDocument: false,
+                SVGElementInstance: false,
+                SVGElementInstanceList: false,
+                SVGEvent: false,
+                SVGExternalResourcesRequired: false,
+                SVGFilterPrimitiveStandardAttributes: false,
+                SVGFitToViewBox: false,
+                SVGFontElement: false,
+                SVGFontFaceElement: false,
+                SVGFontFaceFormatElement: false,
+                SVGFontFaceNameElement: false,
+                SVGFontFaceSrcElement: false,
+                SVGFontFaceUriElement: false,
+                SVGGlyphElement: false,
+                SVGGlyphRefElement: false,
+                SVGHKernElement: false,
+                SVGICCColor: false,
+                SVGLangSpace: false,
+                SVGLocatable: false,
+                SVGMissingGlyphElement: false,
+                SVGPaint: false,
+                SVGPathSeg: false,
+                SVGPathSegArcAbs: false,
+                SVGPathSegArcRel: false,
+                SVGPathSegClosePath: false,
+                SVGPathSegCurvetoCubicAbs: false,
+                SVGPathSegCurvetoCubicRel: false,
+                SVGPathSegCurvetoCubicSmoothAbs: false,
+                SVGPathSegCurvetoCubicSmoothRel: false,
+                SVGPathSegCurvetoQuadraticAbs: false,
+                SVGPathSegCurvetoQuadraticRel: false,
+                SVGPathSegCurvetoQuadraticSmoothAbs: false,
+                SVGPathSegCurvetoQuadraticSmoothRel: false,
+                SVGPathSegLinetoAbs: false,
+                SVGPathSegLinetoHorizontalAbs: false,
+                SVGPathSegLinetoHorizontalRel: false,
+                SVGPathSegLinetoRel: false,
+                SVGPathSegLinetoVerticalAbs: false,
+                SVGPathSegLinetoVerticalRel: false,
+                SVGPathSegList: false,
+                SVGPathSegMovetoAbs: false,
+                SVGPathSegMovetoRel: false,
+                SVGRenderingIntent: false,
+                SVGStylable: false,
+                SVGTests: false,
+                SVGTransformable: false,
+                SVGTRefElement: false,
+                SVGURIReference: false,
+                SVGViewSpec: false,
+                SVGVKernElement: false,
+                SVGZoomAndPan: false,
+                SVGZoomEvent: false,
+                TimeEvent: false,
+                XDomainRequest: false,
+                XMLHttpRequestProgressEvent: false,
+                XPathException: false,
+                XPathNamespace: false,
+                XPathNSResolver: false
+            },
+            globals.browser
+        )
     },
     node: {
-        globals: globals.node,
+
+        /*
+         * For backward compatibility.
+         * Remove those on the next major release.
+         */
+        globals: Object.assign(
+            { arguments: false, GLOBAL: false, root: false },
+            globals.node
+        ),
         parserOptions: {
             ecmaFeatures: {
                 globalReturn: true
@@ -51,7 +167,15 @@ module.exports = {
         globals: globals.jasmine
     },
     jest: {
-        globals: globals.jest
+
+        /*
+         * For backward compatibility.
+         * Remove those on the next major release.
+         */
+        globals: Object.assign(
+            { check: false, gen: false },
+            globals.jest
+        )
     },
     phantomjs: {
         globals: globals.phantomjs
@@ -96,7 +220,7 @@ module.exports = {
         globals: globals.webextensions
     },
     es6: {
-        globals: globals.es6,
+        globals: globals.es2015,
         parserOptions: {
             ecmaVersion: 6
         }
diff --git a/docs/user-guide/migrating-from-jscs.md b/docs/user-guide/migrating-from-jscs.md
index 41d55aec0..c5ac5f235 100644
--- a/docs/user-guide/migrating-from-jscs.md
+++ b/docs/user-guide/migrating-from-jscs.md
@@ -100,7 +100,7 @@ Both JSCS and ESLint use comments inside of files to disable rules around certai
 | Enable one rule | `// jscs:enable ruleName` or `/* jscs:enable ruleName */` | `/* eslint-enable rule-name */` |
 | Disable multiple rules | `// jscs:disable ruleName1, ruleName2` or `/* jscs:disable ruleName1, ruleName2 */` | `/* eslint-disable rule-name1, rule-name2 */` |
 | Enable multiple rules | `// jscs:enable ruleName1, ruleName2` or `/* jscs:enable ruleName1, ruleName2 */` | `/* eslint-enable rule-name1, rule-name2 */` |
-| Disable one rule on single line | `// jscs:ignore ruleName` | `/* eslint-disable-line rule-name */` |
+| Disable one rule on single line | `// jscs:ignore ruleName` | `// eslint-disable-line rule-name` |
 
 ## Command Line Options
 
diff --git a/lib/rules/prefer-destructuring.js b/lib/rules/prefer-destructuring.js
index eeb5e060c..56c348a47 100644
--- a/lib/rules/prefer-destructuring.js
+++ b/lib/rules/prefer-destructuring.js
@@ -145,7 +145,7 @@ module.exports = {
          * @returns {void}
          */
         function performCheck(leftNode, rightNode, reportNode) {
-            if (rightNode.type !== "MemberExpression") {
+            if (rightNode.type !== "MemberExpression" || rightNode.object.type === "Super") {
                 return;
             }
 
diff --git a/lib/rules/space-in-parens.js b/lib/rules/space-in-parens.js
index 95b03c3db..67ec5847c 100644
--- a/lib/rules/space-in-parens.js
+++ b/lib/rules/space-in-parens.js
@@ -45,8 +45,7 @@ module.exports = {
         const MISSING_SPACE_MESSAGE = "There must be a space inside this paren.",
             REJECTED_SPACE_MESSAGE = "There should be no spaces inside this paren.",
             ALWAYS = context.options[0] === "always",
-
-            exceptionsArrayOptions = (context.options.length === 2) ? context.options[1].exceptions : [],
+            exceptionsArrayOptions = (context.options[1] && context.options[1].exceptions) || [],
             options = {};
         let exceptions;
 
diff --git a/package.json b/package.json
index 69f896149..363b80772 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,7 @@
     "file-entry-cache": "^2.0.0",
     "functional-red-black-tree": "^1.0.1",
     "glob": "^7.1.2",
-    "globals": "^9.17.0",
+    "globals": "^11.0.1",
     "ignore": "^3.3.3",
     "imurmurhash": "^0.1.4",
     "inquirer": "^3.0.6",


Test patch:
diff --git a/tests/lib/rules/prefer-destructuring.js b/tests/lib/rules/prefer-destructuring.js
index 93cf62a3e..e60535e7e 100644
--- a/tests/lib/rules/prefer-destructuring.js
+++ b/tests/lib/rules/prefer-destructuring.js
@@ -130,7 +130,8 @@ ruleTester.run("prefer-destructuring", rule, {
         {
             code: "var foo = object.foo;",
             options: [{ VariableDeclarator: { object: false }, AssignmentExpression: { object: true } }]
-        }
+        },
+        "class Foo extends Bar { static foo() {var foo = super.foo} }"
     ],
 
     invalid: [
@@ -276,6 +277,13 @@ ruleTester.run("prefer-destructuring", rule, {
                 message: "Use object destructuring.",
                 type: "AssignmentExpression"
             }]
+        },
+        {
+            code: "class Foo extends Bar { static foo() {var bar = super.foo.bar} }",
+            errors: [{
+                message: "Use object destructuring.",
+                type: "VariableDeclarator"
+            }]
         }
     ]
 });
diff --git a/tests/lib/rules/space-in-parens.js b/tests/lib/rules/space-in-parens.js
index c9249e730..6e66a8fbd 100644
--- a/tests/lib/rules/space-in-parens.js
+++ b/tests/lib/rules/space-in-parens.js
@@ -110,7 +110,8 @@ ruleTester.run("space-in-parens", rule, {
         { code: "foo( ); bar( {bar:'baz'} ); baz( [1,2] )", options: ["never", { exceptions: ["{}", "[]", "empty"] }] },
 
         // faulty exceptions option
-        { code: "foo( { bar: 'baz' } )", options: ["always", { exceptions: [] }] }
+        { code: "foo( { bar: 'baz' } )", options: ["always", { exceptions: [] }] },
+        { code: "foo( { bar: 'baz' } )", options: ["always", {}] }
     ],
 
     invalid: [