Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Incompatibility with eslint 4.14.0 #558

Closed
ndelangen opened this issue Dec 24, 2017 · 38 comments · Fixed by #559
Closed

Incompatibility with eslint 4.14.0 #558

ndelangen opened this issue Dec 24, 2017 · 38 comments · Fixed by #559

Comments

@ndelangen
Copy link

See: eslint/eslint#9767

Something changed in esline 4.14.0 that is causing an incompatibility. With the result of:

> $ yarn lint                                                                          [±master ●]
yarn run v1.3.2
$ yarn lint:js . && yarn lint:md .
$ cross-env NODE_ENV=production eslint --cache --cache-location=.cache/eslint --ext .js,.jsx,.json .
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at isForInRef (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:410:24)
    at variable.references.some.ref (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:447:21)
    at Array.some (<anonymous>)
    at isUsedVariable (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:446:40)
    at collectUnusedVariables (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:569:26)
    at collectUnusedVariables (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:576:17)
    at Program:exit (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:621:36)
    at listeners.(anonymous function).forEach.listener (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
    at Traverser.leave [as _leave] (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/linter.js:1000:32)
    at Traverser._traverse (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/traverser.js:155:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I've detailed more here

I've run eslint with debug enabled, and copied the final few lines:

  eslint:cli-engine Processing /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/components/FlowTypeButton.js +16ms
  eslint:cli-engine Linting /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/components/FlowTypeButton.js +0ms
  eslint:config Constructing config file hierarchy for /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/components +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/package.json +0ms
  eslint:config-file Loading package.json config file: /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/package.json +0ms
  eslint:config-file Loading JSON config file: /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/package.json +0ms
  eslint:config Using config from cache +0ms
  eslint:linter Linting code for /Users/dev/Projects/GitHub/storybook/core/examples/official-storybook/components/FlowTypeButton.js (pass 1) +0ms
  eslint:traverser Unknown node type "TypeAlias": Estimated visitor keys ["type","start","end","loc","range","id","typeParameters","right"] +328ms
  eslint:traverser Unknown node type "ObjectTypeAnnotation": Estimated visitor keys ["type","start","end","loc","range","callProperties","properties","indexers","exact"] +0ms
  eslint:traverser Unknown node type "ObjectTypeProperty": Estimated visitor keys ["type","start","end","loc","range","static","kind","value","variance","optional"] +0ms
  eslint:traverser Unknown node type "StringTypeAnnotation": Estimated visitor keys ["type","start","end","loc","range"] +0ms
  eslint:traverser Unknown node type "ObjectTypeProperty": Estimated visitor keys ["type","start","end","loc","range","static","kind","value","variance","optional"] +0ms
  eslint:traverser Unknown node type "GenericTypeAnnotation": Estimated visitor keys ["type","start","end","loc","range","typeParameters","id"] +0ms
  eslint:traverser Unknown node type "ObjectTypeProperty": Estimated visitor keys ["type","start","end","loc","range","static","kind","value","variance","optional"] +0ms
  eslint:traverser Unknown node type "BooleanTypeAnnotation": Estimated visitor keys ["type","start","end","loc","range"] +0ms
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at isForInRef (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:410:24)
    at variable.references.some.ref (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:447:21)
    at Array.some (<anonymous>)
    at isUsedVariable (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:446:40)
    at collectUnusedVariables (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:569:26)
    at collectUnusedVariables (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:576:17)
    at Program:exit (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/rules/no-unused-vars.js:621:36)
    at listeners.(anonymous function).forEach.listener (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
    at Traverser.leave [as _leave] (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/linter.js:1000:32)
    at Traverser._traverse (/Users/dev/Projects/GitHub/storybook/core/node_modules/eslint/lib/util/traverser.js:155:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@not-an-aardvark
Copy link
Member

Could you provide an example of a file that you're linting when this crash occurs? (To check which file causes the crash, you can run eslint with the --debug flag and see the last file that gets printed before the crash happens.)

@ndelangen
Copy link
Author

// @flow
import React from 'react';

type PropsType = {
  /** The text to be rendered in the button */
  label: string,
  /** Function to be called when the button is clicked */
  onClick?: Function,
  /** Boolean representing wether the button is disabled */
  disabled?: boolean,
};

/** FlowTypeButton component description imported from comments inside the component file */
const FlowTypeButton = ({ label, onClick, disabled }: PropsType) => (
  <button onClick={onClick} disabled={disabled}>
    {label}
  </button>
);

FlowTypeButton.defaultProps = {
  disabled: false,
  onClick: () => {},
};

export default FlowTypeButton;

@not-an-aardvark
Copy link
Member

Thanks for providing the file. Could you also provide your config?

I can't reproduce this crash at the moment. I'm using your file as foo.js:

foo.js
// @flow
import React from 'react';

type PropsType = {
  /** The text to be rendered in the button */
  label: string,
  /** Function to be called when the button is clicked */
  onClick?: Function,
  /** Boolean representing wether the button is disabled */
  disabled?: boolean,
};

/** FlowTypeButton component description imported from comments inside the component file */
const FlowTypeButton = ({ label, onClick, disabled }: PropsType) => (
  <button onClick={onClick} disabled={disabled}>
    {label}
  </button>
);

FlowTypeButton.defaultProps = {
  disabled: false,
  onClick: () => {},
};

export default FlowTypeButton;

And I'm using the following config file:

.eslintrc.yml
parser: babel-eslint
rules:
  no-unused-vars: error

And I'm running the following commands to lint the file:

$ rm -rf node_modules/
$ npm i eslint@4.14.0 babel-eslint@8.1.0
$ node_modules/.bin/eslint foo.js

I get the following reported error as expected, but no crash:

  2:8  error  'React' is defined but never used  no-unused-vars

Creating a reproducible test case for this issue would make it much easier to determine whether this is a bug.

@ndelangen
Copy link
Author

Here's my eslint config:

const error = 2;
const warn = 1;
const ignore = 0;

module.exports = {
  root: true,
  extends: ['eslint-config-airbnb', 'plugin:jest/recommended', 'prettier'],
  plugins: ['prettier', 'jest', 'react', 'json'],
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module',
  },
  env: {
    es6: true,
    node: true,
    'jest/globals': true,
  },
  settings: {
    'import/core-modules': ['enzyme'],
  },
  rules: {
    strict: [error, 'never'],
    'prettier/prettier': [
      warn,
      {
        printWidth: 100,
        tabWidth: 2,
        bracketSpacing: true,
        trailingComma: 'es5',
        singleQuote: true,
      },
    ],
    'no-debugger': process.env.NODE_ENV === 'production' ? error : ignore,
    quotes: [warn, 'single', { avoidEscape: true }],
    'class-methods-use-this': ignore,
    'arrow-parens': [warn, 'as-needed'],
    'space-before-function-paren': ignore,
    'import/no-unresolved': error,
    'import/extensions': [
      error,
      {
        js: 'never',
        json: 'always',
      },
    ],
    'import/no-extraneous-dependencies': [
      error,
      {
        devDependencies: [
          'examples/**',
          '**/example/**',
          '*.js',
          '**/*.test.js',
          '**/*.stories.js',
          '**/scripts/*.js',
          '**/stories/**/*.js',
          '**/__tests__/**/*.js',
        ],
        peerDependencies: true,
      },
    ],
    'import/prefer-default-export': ignore,
    'react/jsx-wrap-multilines': ignore,
    'react/jsx-indent': ignore,
    'react/jsx-indent-props': ignore,
    'react/jsx-closing-bracket-location': ignore,
    'react/jsx-uses-react': error,
    'react/jsx-uses-vars': error,
    'react/react-in-jsx-scope': error,
    'react/jsx-filename-extension': [
      warn,
      {
        extensions: ['.js', '.jsx'],
      },
    ],
    'jsx-a11y/accessible-emoji': ignore,
    'jsx-a11y/href-no-hash': ignore,
    'jsx-a11y/label-has-for': ignore,
    'jsx-a11y/click-events-have-key-events': error,
    'jsx-a11y/anchor-is-valid': [warn, { aspects: ['invalidHref'] }],
    'react/no-unescaped-entities': ignore,
  },
};

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Dec 25, 2017

Oops, I had forgotten that you showed your config before in eslint/eslint#9767 (comment). Thanks for pasting it again.

However, I'm still unable to reproduce the issue. When I install all of the latest versions of eslint, babel-eslint, and your plugins and configs, I still get no errors when linting your file using the config that you provided:

$ npm install eslint@4.14.0 babel-eslint@8.1.0 eslint-plugin-prettier@2.4.0 eslint-plugin-jest@21.5.0 eslint-plugin-react@7.5.1 eslint-plugin-json@1.2.0 eslint-plugin-import@2.8.0 eslint-config-prettier@2.9.0 eslint-config-airbnb@16.1.0 eslint-plugin-jsx-a11y@6.0.3 prettier@1.9.2 react@16.2.0
$ node_modules/.bin/eslint foo.js

Could you double-check the following?

  • You have babel-eslint@8.1.0 installed (run npm ls babel-eslint and check the version)
  • The file that you provided is the same file that is causing the crash (you can run node_modules/.bin/eslint theFile.js and ensure it crashes)

@ndelangen
Copy link
Author

ndelangen commented Dec 25, 2017

Thank you for all the amazing help @not-an-aardvark really really appreciate every second! 🙇

I will do another attempt, possibly tomorrow, it's late over here 💤

I can give you the repo I had the problem on:
https://github.com/storybooks/storybook

If you interested in debugging it further, I have no expectations, thanks 👏

@not-an-aardvark
Copy link
Member

Thanks, I was able to reproduce the issue after cloning https://github.com/storybooks/storybook. I'll investigate it now.

@mysticatea
Copy link
Member

I apology for this and thank you very much for the repro steps.
I'll investigate this as well!

@not-an-aardvark
Copy link
Member

@mysticatea On the storybooks/storybook repo, the issue can be reproduced by running:

$ node_modules/.bin/eslint examples/cra-kitchen-sink/src/stories/index.stories.js examples/official-storybook/components/FlowTypeButton.js

For some reason, everything works when FlowTypeButton.js is linted on its own, but it crashes when index.stories.js is linted first. I suspect babelEslint.parse is getting called somehow instead of babelEslint.parseForESLint, so it's reverting to the old monkeypatching behavior on all future runs.

@mysticatea
Copy link
Member

mysticatea commented Dec 25, 2017

I realized that it may be came from eslint-plugin-import

@not-an-aardvark
Copy link
Member

I agree, it looks like eslint-plugin-import is calling parser.parse here, which causes babel-eslint to revert to the monkeypatching behavior.

I think the best solution would be to avoid monkeypatching when babelEslint.parse is called, and just return an AST. (Alternatively, maybe it could patch eslint-scope when parse is called, but still use a custom scopeManager/visitorKeys if parseForESLint is called afterwards.)

@not-an-aardvark
Copy link
Member

Making this change in babel-eslint seems to fix the crash in storybook, at least:

diff --git a/lib/index.js b/lib/index.js
index 130b10b..d950300 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1,18 +1,14 @@
 "use strict";
 
-let patched = false;
-
 exports.parse = function(code, options) {
-  patched = true;
   return require("./parse-with-patch")(code, options);
 };
 
 exports.parseForESLint = function(code, options) {
-  if (!patched && options.eslintVisitorKeys && options.eslintScopeManager) {
+  if (options.eslintVisitorKeys && options.eslintScopeManager) {
     return require("./parse-with-scope")(code, options);
   }
 
-  patched = true;
   return { ast: require("./parse-with-patch")(code, options) };
 };
 

Does it make sense to run parse-with-scope when eslint-scope has already been patched?

@mysticatea
Copy link
Member

If options.eslintScopeManager in parse exists, we can use it. (I'm still on the linking phase of yarn command...)

@mysticatea
Copy link
Member

Does it make sense to run parse-with-scope when eslint-scope has already been patched?

If npm did dedup, I'm not sure that parse-with-scope works correctly.

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Dec 25, 2017

Here's a minimal reproduction case:

a.js:

export default function foo() {}

b.js:

import foo from './a.js';

c.js:

type Foo = {};

const x: Foo = 0;

.eslintrc.yml:

parser: babel-eslint

plugins:
  - import

rules:
  import/no-named-as-default: error
  no-unused-vars: error
$ npm install eslint@4.14.0 babel-eslint@8.1.0 eslint-plugin-import@2.8.0
$ node_modules/.bin/eslint b.js c.js

@mysticatea
Copy link
Member

If options.eslintScopeManager in parse exists, we can use it.

Unfortunately, it does not exist.

@not-an-aardvark
Copy link
Member

One possibility would be for parse-with-scope to create a copy of the eslint-scope classes before it extends them. Then if eslint-scope gets monkeypatched after a call to parse, it will still be possible to have parse-with-scope working correctly if parseForESLint is called later.

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Dec 25, 2017

Alternatively, we could do something like this:

diff --git a/lib/analyze-scope.js b/lib/analyze-scope.js
index b538dea..28d7eb2 100644
--- a/lib/analyze-scope.js
+++ b/lib/analyze-scope.js
@@ -322,7 +322,10 @@ module.exports = function(ast, parserOptions) {
     fallback,
   };
   const scopeManager = new escope.ScopeManager(options);
-  const referencer = new Referencer(options, scopeManager);
+  const ReferencerConstructor = hasPatchedEslintScope
+    ? OriginalReferencer
+    : Referencer;
+  const referencer = new ReferencerConstructor(options, scopeManager);
 
   referencer.visit(ast);
 

After eslint-scope has already been monkeypatched, I think we could just use a regular eslint-scope referencer to get the scope.

EDIT: Actually, we would need to make sure that the resolved version of eslint-scope is the same as the version that was monkeypatched.

@mysticatea
Copy link
Member

Sounds good idea

@mysticatea
Copy link
Member

I was thinking to determine implementation at the first call:

"use strict";

let patched = undefined;

exports.parse = function(code, options) {
  return exports.parseForESLint(code, options).ast
};

exports.parseForESLint = function (code, options) {
  if (patched === undefined) {
    patched = !(options.eslintVisitorKeys && options.eslintScopeManager)
  }
  if (patched) {
    return { ast: require("./parse-with-patch")(code, options) };
  }
  return require("./parse-with-scope")(code, options);
};

exports.parseNoPatch = function(code, options) {
  return require("./parse")(code, options);
};

@not-an-aardvark
Copy link
Member

I think we should try to avoid global mutable state, aside from the places where we have to monkeypatch for legacy reasons. So I think it would be better to not depend on what calls parse first, assuming there are other available options.

@not-an-aardvark
Copy link
Member

Actually, it seems like the monkeypatched escope.analyze will never be called by parse-with-scope, because parse-with-scope creates a Referencer manually. The changes to estraverse shouldn't affect eslint-scope because eslint-scope only uses estraverse.Syntax (based on this search), not estraverse.VisitorKeys. So I think the change from #558 (comment) should work fine.

@mysticatea
Copy link
Member

Hmm, but parse-with-patch modifies Referencer.prototype.

@not-an-aardvark
Copy link
Member

Oh, you're right. I hadn't realized that.

I'll try the approach in #558 (comment).

mysticatea added a commit that referenced this issue Dec 25, 2017
@mysticatea
Copy link
Member

I added a test based on #558 (comment): f92b364

not-an-aardvark pushed a commit that referenced this issue Dec 25, 2017
@not-an-aardvark
Copy link
Member

I added a fix based on #558 (comment) and reopened #559. However, I'm trying to figure out why this test is failing.

@mysticatea
Copy link
Member

I guess related to parserOptions.ecmaFeatures.globalReturn... (escope's option's nodejsScope)

mysticatea pushed a commit that referenced this issue Dec 25, 2017
… called (fixes #558)(#559)

* Prevent parseForESLint() behavior from changing after parse() is called

(fixes #558, fixes eslint/eslint#9767)

* Avoid using the enhanced referencer after monkeypatching

* Chore: add test for #558

* Pass correct scope analyzer options

* fix escope patch and improve tests

* remove process.exit(1)
@ndelangen
Copy link
Author

I've upgraded storybook to both latest versions, but I'm seeing some really unexpected results.

The process exits with a expected failure, saying there are errors in my code.
The errors weren't there before the upgrade, and when I have a look at the errors it's returning, they seem incorrect to me.

When I run with debug enabled, I'm seeing a whole lot of
eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind"] +0ms

Here's a section of the log:

  eslint:config-file Loading JSON config file: /Users/dev/Projects/GitHub/storybook/core/lib/ui/package.json +0ms
  eslint:config Using config from cache +0ms
  eslint:cli-engine Processing /Users/dev/Projects/GitHub/storybook/core/lib/ui/src/modules/ui/containers/stories_panel.js +8ms
  eslint:cli-engine Linting /Users/dev/Projects/GitHub/storybook/core/lib/ui/src/modules/ui/containers/stories_panel.js +0ms
  eslint:config Constructing config file hierarchy for /Users/dev/Projects/GitHub/storybook/core/lib/ui/src/modules/ui/containers +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /Users/dev/Projects/GitHub/storybook/core/lib/ui/package.json +0ms
  eslint:config-file Loading package.json config file: /Users/dev/Projects/GitHub/storybook/core/lib/ui/package.json +0ms
  eslint:config-file Loading JSON config file: /Users/dev/Projects/GitHub/storybook/core/lib/ui/package.json +0ms
  eslint:config Using config from cache +0ms
  eslint:linter Linting code for /Users/dev/Projects/GitHub/storybook/core/lib/ui/src/modules/ui/containers/stories_panel.js (pass 1) +0ms
  eslint:traverser Unknown node type "Literal": Estimated visitor keys ["type","start","end","loc","range","value","raw"] +9ms
  eslint:traverser Unknown node type "Literal": Estimated visitor keys ["type","start","end","loc","range","value","raw"] +1ms
  eslint:traverser Unknown node type "Literal": Estimated visitor keys ["type","start","end","loc","range","value","raw"] +0ms
  eslint:traverser Unknown node type "Literal": Estimated visitor keys ["type","start","end","loc","range","value","raw"] +0ms
  eslint:traverser Unknown node type "Literal": Estimated visitor keys ["type","start","end","loc","range","value","raw"] +1ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +1ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind"] +1ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:traverser Unknown node type "Property": Estimated visitor keys ["type","start","end","loc","range","method","key","computed","shorthand","value","kind","extra"] +0ms
  eslint:linter Generating fixed text for /Users/dev/Projects/GitHub/storybook/core/lib/ui/src/modules/ui/containers/stories_panel.js (pass 1) +12ms
  eslint:text-fixer Applying fixes +12ms
  eslint:text-fixer shouldFix parameter was false, not attempting fixes +0ms

I can post the entire log if desired.

In the end, I get this list of errors:

/Users/dev/Projects/GitHub/storybook/core/addons/actions/src/lib/retrocycle.js
   1:8   error  'reviver' is defined but never used       no-unused-vars
   2:10  error  'muteProperty' is defined but never used  no-unused-vars
   3:10  error  'CYCLIC_KEY' is defined but never used    no-unused-vars
   5:7   error  'pathReg' is defined but never used       no-unused-vars
   5:7   error  'pathReg' is not defined                  no-undef
   7:36  error  'json' is defined but never used          no-unused-vars
   8:9   error  '$' is defined but never used             no-unused-vars
   8:9   error  '$' is not defined                        no-undef
   8:24  error  'json' is not defined                     no-undef
   8:30  error  'reviver' is not defined                  no-undef
  10:32  error  '$' is not defined                        no-undef
  11:12  error  '$' is not defined                        no-undef
  14:17  error  'value' is defined but never used         no-unused-vars
  15:9   error  'value' is not defined                    no-undef
  16:25  error  'value' is not defined                    no-undef
  17:29  error  'value' is not defined                    no-undef
  18:24  error  'value' is not defined                    no-undef
  21:45  error  'pathReg' is not defined                  no-undef
  22:15  error  'value' is not defined                    no-undef
  24:15  error  'rez' is not defined                      no-undef
  30:28  error  'value' is not defined                    no-undef
  31:24  error  'value' is not defined                    no-undef
  36:45  error  'pathReg' is not defined                  no-undef
  37:15  error  'value' is not defined                    no-undef
  39:15  error  'rez' is not defined                      no-undef
  45:6   error  '$' is not defined                        no-undef
  47:3   error  'muteProperty' is not defined             no-undef
  47:16  error  'CYCLIC_KEY' is not defined               no-undef
  47:28  error  '$' is not defined                        no-undef
  49:10  error  '$' is not defined                        no-undef

on this file:

import reviver from './reviver';
import { muteProperty } from './util';
import { CYCLIC_KEY } from './';

const pathReg = /^\$(?:\[(?:\d+|"(?:[^\\"\u0000-\u001f]|\\([\\"/bfnrt]|u[0-9a-zA-Z]{4}))*")])*$/;

export default function retrocycle(json) {
  const $ = JSON.parse(json, reviver);

  if (typeof $ !== 'object' || $ === null) {
    return $;
  }

  (function rez(value) {
    if (value && typeof value === 'object') {
      if (Array.isArray(value)) {
        for (let i = 0; i < value.length; i += 1) {
          const item = value[i];
          if (item && typeof item === 'object') {
            const path = item.$ref;
            if (typeof path === 'string' && pathReg.test(path)) {
              value[i] = eval(path); // eslint-disable-line no-eval, no-param-reassign
            } else {
              rez(item);
            }
          }
        }
      } else {
        // eslint-disable-next-line no-restricted-syntax, guard-for-in
        for (const name in value) {
          const item = value[name];

          if (typeof item === 'object' && item !== null) {
            const path = item.$ref;

            if (typeof path === 'string' && pathReg.test(path)) {
              value[name] = eval(path); // eslint-disable-line no-eval, no-param-reassign
            } else {
              rez(item);
            }
          }
        }
      }
    }
  })($);

  muteProperty(CYCLIC_KEY, $);

  return $;
}

@mysticatea
Copy link
Member

Thank you for the report.
Probably #560 (#561) fixes it. Please wait for review of the team.

@ndelangen
Copy link
Author

Sure, thanks @mysticatea just wanted to report any info that might be of use. Happy Holidays, really appreciate your efforts!

@mysticatea
Copy link
Member

mysticatea commented Dec 25, 2017

Thank you so much, I found a performance issue from your debug log. #562 should fix it.

@eljoaquin
Copy link

Hi,

after upgrade to eslint@4.14.0 I got an error:

6:30 error Parse errors in imported module '*********': Cannot find module 'estraverse' (undefined:undefined) import/no-named-as-default

it looks like the babel-eslint in file patch-eslint-scope.js is looking for estraverse module, and because it was removed from eslint in version 4.14 it returns an error.
After I installed estraverse into my local devDependencies it started working, but what do you think, how it should be handled?

Thanks

@ndelangen
Copy link
Author

Everything is working on my end.

@eljoaquin try removing all node_modules and your lockfiles and install again.

Upgrading all related dependencies might also resolve the issue.

@adamgruber
Copy link

adamgruber commented Dec 28, 2017

Seeing the same issue as @eljoaquin. Running on node 4.8.7 and npm 2.15.11. It works fine on node >= 6. Downgrading eslint to 4.13.1 works so maybe more of an issue with eslint than with babel-eslint.

adamgruber pushed a commit to adamgruber/mochawesome-report-generator that referenced this issue Dec 28, 2017
Mayank1791989 added a commit to Mayank1791989/eslint-plugin-playlyfe that referenced this issue Jan 2, 2018
izaakschroeder added a commit to metalabdesign/eslint-config-metalab that referenced this issue Jan 14, 2018
@dickeylth
Copy link

dickeylth commented Mar 20, 2018

Seeing the same issue as @eljoaquin on npm 2.15.12, so the only solution is to install estraverse as devDependency?

@barrymichaeldoyle
Copy link

@dickeylth what does estraverse do?

I'm having the same issues now where I get the Cannot read property range of undefined :(

wcjohnson added a commit to wcjohnson/lightscript-eslint that referenced this issue Sep 20, 2018
commit 6aa8b6f
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Aug 27 18:09:21 2018 -0400

    9.0.0

commit c7ee9ae
Author: Brian Ng <bng412@gmail.com>
Date:   Mon Aug 27 17:04:26 2018 -0500

    Bump to babel@7.0.0 🎉 (babel#676)

commit 3ece549
Author: Ed Morley <501702+edmorley@users.noreply.github.com>
Date:   Thu Aug 23 06:23:06 2018 +0100

    Docs: Make the default parserOptions more explicit (babel#673)

    In particular, previously the `.eslintrc` example implied that the default value for `codeFrame` was `false`, when in fact it is `true`:
    https://github.com/babel/babel-eslint/blob/v9.0.0-beta.3/lib/parse.js#L14

commit 0b36951
Author: Alexandre Borela <alexandre.borela@gmail.com>
Date:   Thu Aug 23 02:21:45 2018 -0300

    Add logical assignment plugin (babel#674)

    Fix babel#672

commit 5856ff5
Author: Brian Ng <bng412@gmail.com>
Date:   Tue Aug 21 15:18:02 2018 -0500

    Bump some devDeps

commit 45938d9
Author: Leo Yin <viztor@users.noreply.github.com>
Date:   Wed Aug 22 04:00:17 2018 +0800

    build(deps): upgrade @babel/* to 7.0.0-rc.2 (babel#668)

commit bc97875
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Jul 12 09:50:58 2018 -0400

    9.0.0-beta.3

commit 74c5d62
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Jul 12 09:50:30 2018 -0400

    update lock

commit 6a45632
Author: Mark Tse <neverendingqs@users.noreply.github.com>
Date:   Thu Jul 12 09:49:43 2018 -0400

    chore - fixing eslint-scope to a safe version; resolves babel#656. (babel#657)

commit e0119e0
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jul 6 11:24:45 2018 -0500

    9.0.0-beta.2

commit 198964b
Merge: 8948d83 9b06e1f
Author: Rubén Norte <rubennorte@gmail.com>
Date:   Fri Jul 6 17:20:52 2018 +0100

    Merge pull request babel#645 from rubennorte/support-new-flow-syntax-in-scope-analysis

    Support new flow syntax in scope analysis

commit 9b06e1f
Author: Rubén Norte <rubennorte@fb.com>
Date:   Fri Jul 6 11:33:37 2018 +0100

    Added failing test for variables used in type parameters

commit 8948d83
Author: Rubén Norte <rubennorte@gmail.com>
Date:   Fri Jul 6 14:50:59 2018 +0100

    Upgrade Babel to v7.0.0-beta.52 (babel#650)

    * Upgrade Babel to v7.0.0-beta.52

    * Fixed failing test

commit 4882b29
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jun 29 08:37:18 2018 -0500

    9.0.0-beta.1

commit 15e8d6f
Author: Rubén Norte <rubennorte@gmail.com>
Date:   Fri Jun 29 14:26:43 2018 +0100

    Breaking: Upgraded Babel to 7.0.0-beta.51 (babel#642)

    * Upgraded Babel to 7.0.0-beta.51, with changes to decorators

    * Removed support for Node 4 and added it for Node 10

    * nit: fix typo [skip ci]

commit e865104
Author: Brian Ng <bng412@gmail.com>
Date:   Sat Jun 23 08:20:40 2018 -0500

    8.2.5

commit 10a402c
Author: Brian Ng <bng412@gmail.com>
Date:   Sat Jun 23 08:20:08 2018 -0500

    Revert bump to babel 51 (babel#640)

commit 2bd8508
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jun 22 13:39:23 2018 -0500

    8.2.4

commit 5881648
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jun 22 11:12:54 2018 -0500

    Add test for template string with object with template string inside (babel#639)

    Closes babel#538.
    Fixes babel#537.

    Now that babel#610 has landed, I wanted to make sure this case was covered.

commit 476426a
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jun 22 11:03:15 2018 -0500

    Support OptionalMemberExpression with scope too (babel#634)

commit 92874d4
Author: Brian Ng <bng412@gmail.com>
Date:   Fri Jun 15 16:39:58 2018 -0500

    Drop node4 in travis

commit d2ac299
Author: Brian Ng <bng412@gmail.com>
Date:   Mon Jun 11 08:47:15 2018 -0500

    Bump Babel deps

commit e63962d
Author: Cristian Pallarés <cristian@pallares.io>
Date:   Wed Jun 6 00:18:13 2018 +0200

    refactor: rename babylon to @babel/parser

commit 873f02f
Author: Brian Ng <bng412@gmail.com>
Date:   Mon Jun 18 16:46:31 2018 -0500

    Fix converting template types to handle nested templates (babel#610)

    Fixes babel#603 (and the fixture from babel#609 works).

    Reworks our code that converts the format of Babylon template tokens to be a bit more robust, especially with things like nested templates with arrows.

    (Adapted the logic from https://github.com/eslint/espree/blob/master/lib/token-translator.js)

commit 74a3207
Author: Rubén Norte <rubennorte@gmail.com>
Date:   Fri Jun 15 15:42:05 2018 +0100

    Fix token types for experimental operators (babel#632)

    * Added failing tests

    * Recognized nullish coalescing, optional chaining and pipeline operators as Punctuator tokens

commit e802577
Author: Rubén Norte <rubennorte@gmail.com>
Date:   Fri Jun 15 15:31:43 2018 +0100

    Add support for the optional chaining operator (babel#630)

commit ebc46e1
Author: jmurretxactly <35241735+jmurretxactly@users.noreply.github.com>
Date:   Tue May 8 05:52:59 2018 -0600

    don't require unpad per test fixture, fixes babel#572 (babel#618)

commit 9641e4b
Author: Ankur Oberoi <aoberoi@gmail.com>
Date:   Fri Apr 13 09:26:41 2018 -0700

    updates readme for latest eslint & babel-eslint (babel#607) [skip ci]

commit aaeb46b
Author: Henry Zhu <hi@henryzoo.com>
Date:   Fri Apr 13 11:25:03 2018 -0400

    8.2.3

commit afc3c87
Author: Henry Zhu <hi@henryzoo.com>
Date:   Fri Apr 13 11:23:59 2018 -0400

    lock to beta.44

commit 92202be
Author: Bary Levi <barylevi@gmail.com>
Date:   Fri Apr 13 18:23:03 2018 +0300

    Save babel beta packages as exact versions (babel#606) [skip ci]

commit 9a6d663
Author: Daniel Tschinder <daniel.tschinder@researchgate.net>
Date:   Tue Feb 20 11:57:07 2018 +0100

    8.2.2

commit 51afa9e
Author: Daniel Tschinder <daniel.tschinder@researchgate.net>
Date:   Tue Feb 20 11:56:40 2018 +0100

    Allow newer versions of babel

commit 7928722
Author: Daniel Tschinder <daniel.tschinder@researchgate.net>
Date:   Tue Feb 20 11:54:09 2018 +0100

    Update dependencies

commit f958995
Author: Daniel Tschinder <daniel@tschinder.de>
Date:   Tue Feb 20 11:49:19 2018 +0100

    chore(package): update lint-staged to version 6.1.1 (babel#592)

    Closes babel#539

commit 29b12ab
Author: Brian Ng <bng412@gmail.com>
Date:   Thu Feb 15 21:39:42 2018 -0600

    Bump deps (babel#591)

commit 236adb8
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Wed Jan 17 15:10:55 2018 +0900

    Fix: wrong token type of ! and ~ (fixes babel#576) (babel#577)

commit bf27f60
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Jan 8 19:15:40 2018 -0500

    8.2.1

commit d96ce55
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Jan 8 19:15:22 2018 -0500

    fix export change (babel#571)

commit ef27670
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Mon Jan 8 18:06:57 2018 -0500

    8.2.0

commit eba5920
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Jan 8 17:46:57 2018 -0500

    Add other parser plugins, update yarn.lock (babel#569)

commit e201fb4
Author: Kai Cataldo <kaicataldo@users.noreply.github.com>
Date:   Mon Jan 8 17:45:24 2018 -0500

    Make 2018 the default ecmaVersion for rules relying on parserOptions (babel#556)

commit 1dedd1b
Author: jony89 <ariel@emath.co.il>
Date:   Tue Jan 9 00:40:11 2018 +0200

    update babel packages (babel#565)

    * update babel packages

    There is some critical bug fixes in version babylon#7.0.0-beta.33 regard `async` - `await` syntax which is needed pretty immediately :)

    * remove test 42 (test for import type *)

    `import type *` is invalid, since the namespace can't be a type

commit 36bf8b4
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Tue Dec 26 10:59:19 2017 +0900

    8.1.2

commit 5aaf0e1
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Tue Dec 26 10:50:13 2017 +0900

    Fix: add Literal type to visitorKeys (babel#562)

    * Fix: add Literal type to visitorKeys
    * Fix: use ./visitor-keys

commit bf9092a
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Tue Dec 26 10:49:36 2017 +0900

    Fix: ignore eval (fixes babel#560) (babel#561)

commit d84b236
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Mon Dec 25 15:57:19 2017 +0900

    8.1.1

commit e4bed5a
Author: Teddy Katz <teddy.katz@gmail.com>
Date:   Mon Dec 25 01:52:36 2017 -0500

    Fix: Prevent parseForESLint() behavior from changing after parse() is called (fixes babel#558)(babel#559)

    * Prevent parseForESLint() behavior from changing after parse() is called

    (fixes babel#558, fixes eslint/eslint#9767)

    * Avoid using the enhanced referencer after monkeypatching

    * Chore: add test for babel#558

    * Pass correct scope analyzer options

    * fix escope patch and improve tests

    * remove process.exit(1)

commit 893a5e3
Author: Teddy Katz <teddy.katz@gmail.com>
Date:   Sun Dec 24 02:02:44 2017 -0500

    8.1.0

commit bba9d00
Author: Teddy Katz <teddy.katz@gmail.com>
Date:   Sun Dec 24 02:00:29 2017 -0500

    Re-add parseNoPatch function (accidentally removed) (babel#557)

commit dbc6546
Author: Toru Nagashima <star.ctor@gmail.com>
Date:   Sun Dec 24 15:42:17 2017 +0900

    Use new scopeManager/visitorKeys APIs (babel#542)

    (fixes eslint/eslint#9762)

commit 1f220c2
Author: Logan Smyth <loganfsmyth@gmail.com>
Date:   Fri Dec 1 10:06:40 2017 -0800

    8.0.3

commit cf5ab03
Author: Logan Smyth <loganfsmyth@gmail.com>
Date:   Fri Dec 1 10:06:24 2017 -0800

    Fix mocha command path.

commit 0609da8
Author: Logan Smyth <loganfsmyth@gmail.com>
Date:   Fri Dec 1 10:05:34 2017 -0800

    Lock down dependency versions.

commit a0fbd50
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Nov 6 15:00:41 2017 -0500

    8.0.2

commit 2004b91
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Nov 6 14:57:56 2017 -0500

    require correct deps

commit fa56d21
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Nov 6 12:51:19 2017 -0500

    Always use unpad (babel#535)

commit 295091d
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Nov 6 12:47:47 2017 -0500

    Allow ^ version for babel dependencies (babel#534)

commit d3b8519
Author: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
Date:   Mon Nov 6 12:25:35 2017 -0500

    fix(package): update babylon to version 7.0.0-beta.31 (babel#533)

commit 54ab4ac
Author: Henry Zhu <hi@henryzoo.com>
Date:   Tue Sep 26 16:18:43 2017 -0400

    8.0.1

commit c1a7882
Author: Clement Hoang <clement.hoang24@gmail.com>
Date:   Tue Oct 31 11:50:35 2017 -0700

    Update README.md support (babel#531) [skip ci]

    #linting channel is now archived in babel slack.

commit 51100c9
Author: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
Date:   Wed Oct 11 14:14:29 2017 +0200

    chore(package): update mocha to version 4.0.0 (babel#524)

commit 5742b71
Author: Jordan Gensler <jordangens@gmail.com>
Date:   Tue Sep 26 13:17:44 2017 -0700

    Adding optionalCatchBinding to plugins. (babel#521)

commit 905887c
Author: Henry Zhu <hi@henryzoo.com>
Date:   Tue Sep 12 09:44:23 2017 -0400

    8.0.0

commit 49493e4
Author: Henry Zhu <hi@henryzoo.com>
Date:   Tue Sep 12 09:42:30 2017 -0400

    update to beta.0

commit 42d0c5b
Author: Daniel Tschinder <daniel@tschinder.de>
Date:   Wed Aug 2 14:37:01 2017 +0200

    Remove already fixed workaround (babel#508)

commit 25bd208
Author: Henry Zhu <hi@henryzoo.com>
Date:   Wed Jul 26 16:19:29 2017 -0400

    8.0.0-alpha.17

commit 1468905
Author: Henry Zhu <hi@henryzoo.com>
Date:   Wed Jul 26 16:18:45 2017 -0400

    alpha.17

commit 57c133e
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Jul 13 13:01:31 2017 -0400

    8.0.0-alpha.15

commit 1e41162
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Jul 13 12:58:45 2017 -0400

    update (babel#504)

commit c31b577
Author: Evan Brodie <ecbrodie@users.noreply.github.com>
Date:   Sun Jul 9 21:03:59 2017 -0400

    Readme update usage section (babel#501) [skip ci]

    * Updates README: Consolidates versioning table

    Basically a revert of 52b4a13. It is easier to read a single table instead of two locations in the README for the version compatabilities between ESLint and babel-eslint

    * Updates README: Add yarn command for installation

    * [skip ci]

commit c2626f9
Author: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
Date:   Sun Jun 25 08:30:29 2017 -0700

    Update eslint to the latest version 🚀 (babel#500)

    * chore(package): update eslint to version 4.1.0

    * escope -> eslint-scope

    * Fix linting

commit 3c6b2de
Author: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
Date:   Thu Jun 22 13:18:47 2017 -0700

    chore(package): update husky to version 0.14.0 (babel#498)

commit e052d5a
Author: Kevin Mårtensson <kevinmartensson@gmail.com>
Date:   Tue Jun 20 23:49:46 2017 +0200

    Update install instructions to use latest stable release (babel#497) [skip ci]

commit 8e3e088
Author: Henry Zhu <hi@henryzoo.com>
Date:   Sun Jun 18 18:33:40 2017 -0400

    8.0.0-alpha.13

commit f757e22
Merge: 37f9242 5736be6
Author: Henry Zhu <hi@henryzoo.com>
Date:   Sun Jun 18 18:30:59 2017 -0400

    Merge pull request babel#493 from danez/regression-test

    Test for babylon regression

commit 5736be6
Author: Daniel Tschinder <daniel.tschinder@researchgate.net>
Date:   Sun Jun 18 23:12:08 2017 +0200

    Update babylon

commit 37f9242
Author: Brian Ng <bng412@gmail.com>
Date:   Sat Jun 17 14:14:42 2017 -0500

    Add Prettier (babel#491)

commit d0c3223
Author: Daniel Tschinder <daniel.tschinder@researchgate.net>
Date:   Sat Jun 17 21:12:07 2017 +0200

    Test for babylon regression

commit 945f00a
Author: Henry Zhu <hi@henryzoo.com>
Date:   Fri Jun 16 16:56:32 2017 -0400

    8.0.0-alpha.12

commit 39b4a6a
Author: Daniel Tschinder <daniel@tschinder.de>
Date:   Thu Jun 15 23:03:02 2017 +0200

    Use babylon estree and ranges (babel#489)

commit 1aedb95
Author: Mark Banner <standard8@mozilla.com>
Date:   Thu Jun 8 17:23:08 2017 +0100

    Fix: allow options to be optional when monkey patching escope.analyze (fixes babel#470). (babel#484)

commit a8003c0
Author: Reyad Attiyat <reyad.attiyat@gmail.com>
Date:   Tue Jun 6 20:38:49 2017 -0500

    Use Node 8 and drop Node 5 from travis (babel#483)

    * Use Node 8 and drop Node 5 from travis

    * switch the order [skip ci]

commit c66ec51
Author: Reyad Attiyat <reyad.attiyat@gmail.com>
Date:   Tue Jun 6 20:37:57 2017 -0500

    Update to Babylon 7 (fixes babel#481) (babel#482)

    * Update to Babylon 7 (fixes babel#481)

    * Pin dependencies to alpha version

    * fix deprecation, add other plugins

    * oops

    * Update index.js

    * Add tests for private class properties with rules no-undef no-unused-vars

commit 54ed517
Author: Reyad Attiyat <reyad.attiyat@gmail.com>
Date:   Mon May 29 20:41:14 2017 -0500

    Fix: Convert RegExpLieteral value to RegExp object (fixes babel#477) (babel#478)

commit 94bb5a1
Author: Sebastian McKenzie <sebmck@fb.com>
Date:   Fri Apr 21 22:14:19 2017 +0100

    7.2.3

commit dfaff04
Author: Andres Suarez <zertosh@gmail.com>
Date:   Fri Apr 21 11:48:52 2017 -0400

    Fix flow type spread handling (babel#465)

commit f59d200
Author: Henry Zhu <hi@henryzoo.com>
Date:   Wed Apr 12 12:07:05 2017 -0400

    7.2.2

commit 8622009
Author: Vitor Balocco <vitorbal@gmail.com>
Date:   Wed Apr 12 17:59:23 2017 +0200

    Fix: use eslint-scope instead of escope if present (babel#461)

commit 0f611b8
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 30 13:49:51 2017 -0400

    Separate finding peer deps from monkeypatching (babel#460)

commit 1201e12
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 19:36:10 2017 -0400

    Remove unused .gitmodules (babel#457)

commit a750684
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 19:32:05 2017 -0400

    Use dedent for unpadding (babel#456)

commit cdb92fe
Merge: 21dac73 ec14787
Author: Henry Zhu <hi@henryzoo.com>
Date:   Sat Mar 25 19:15:23 2017 -0400

    Merge pull request babel#455 from babel/babylon-to-espree-tidy

    Tidy up babylon-to-espree

commit ec14787
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 18:03:17 2017 -0400

    Enable strict mode in all of babylon-to-espree

commit 6c5beec
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 18:01:13 2017 -0400

    Move ast convert steps to babylon-to-espree

commit d2ce789
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:42:51 2017 -0400

    Use for-loop for template literal conversion

commit 539af05
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:36:20 2017 -0400

    Only iterate over tokens once

commit 06c3a31
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:28:01 2017 -0400

    Inline fixDirectives and use for-loop

commit 5d32ad0
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:07:41 2017 -0400

    Consolidate versions of "convertComments"

commit 2541fc9
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 00:18:57 2017 -0400

    toAst pass "source" in state instead of keeping in scope

commit 21dac73
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 15:46:48 2017 -0400

    Add type parameter scope tests (babel#454)

commit 3cda62e
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Mar 23 14:03:23 2017 -0400

    7.2.1

commit 5626de1
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 14:02:24 2017 -0400

    Remove left over eslint 2 estraverse code (babel#452)

    This was missed in babel#361

commit b5fb53b
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 12:49:19 2017 -0400

    Fix type param and interface declaration scoping (babel#449)

commit f1cee0f
Author: Andres Suarez <zertosh@gmail.com>
Date:   Wed Mar 22 22:35:31 2017 -0400

    Remove lodash dependency (babel#450)

commit eb05812
Author: Andres Suarez <zertosh@gmail.com>
Date:   Wed Mar 22 22:34:13 2017 -0400

    Format non-regression errors for legibility (babel#451)

commit 7972a05
Author: Luís Couto <hello@luiscouto.pt>
Date:   Tue Mar 21 00:11:30 2017 +0000

    Update README.md with codeFrame option (babel#448)

commit 4db4db5
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Mar 20 17:53:26 2017 -0400

    7.2.0

commit 4499412
Author: wtgtybhertgeghgtwtg <wtgtybhertgeghgtwtg@gmail.com>
Date:   Mon Mar 20 14:50:09 2017 -0700

    Use `lodash` instead of `lodash.pickby`. (babel#435)

commit a2c3b30
Author: Alex Rattray <rattray.alex@gmail.com>
Date:   Mon Mar 20 14:46:07 2017 -0700

    [flow] Process polymorphic type bounds on functions (babel#444)

commit 515adef
Author: Luís Couto <hello@luiscouto.pt>
Date:   Mon Mar 20 21:45:11 2017 +0000

    Add option to disable code frame. (babel#446)

    * Add option to disable code hightlight.

    * Rename codeHighlight with codeFrame

    * Add codeFrame tests

    * Remove colors from test assertions

commit ce66e73
Merge: bdeb86f b49ab20
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Mar 20 11:44:33 2017 -0400

    Merge pull request babel#447 from kaicataldo/clean-up-eslint

    Chore: Clean up and upgrades

commit b49ab20
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Mon Mar 20 10:33:14 2017 -0400

    Updates ESLint version/remove unnecessary config

commit 702d6b8
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Mon Mar 20 10:27:28 2017 -0400

    Remove broken ESLint tests

commit 6b4c4ca
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Sat Mar 11 22:15:47 2017 -0500

    Upgrade outdated dependencies
@bradennapier
Copy link

I am now having this issue with the latest everything?

"babel-eslint": "^10.0.1",

[Error - 12:17:26 PM] TypeError: Cannot read property 'type' of undefined
    at isForInRef (/Users/Shared/Development/projects/pubchan/node_modules/eslint/lib/rules/no-unused-vars.js:430:24)
    at variable.references.some.ref (/Users/Shared/Development/projects/pubchan/node_modules/eslint/lib/rules/no-unused-vars.js:467:21)
    at Array.some (<anonymous>)
    at isUsedVariable (/Users/Shared/Development/projects/pubchan/node_modules/eslint/lib/rules/no-unused-vars.js:466:40)
    at collectUnusedVariables (/Users/Shared/Development/projects/pubchan/node_modules/eslint/lib/rules/no-unused-vars.js:578:26)
    at collectUnusedVariables (/Users/Shared/Development/projects/pubchan/node_modules/eslint/lib/rules/no-unused-vars.js:585:17)
    at Program:exit 
...

@ThomasGHenry
Copy link

@bradennapier did you solve this? thx!

kaicataldo pushed a commit to babel/babel that referenced this issue Nov 14, 2019
… called (fixes #558)(#559)

* Prevent parseForESLint() behavior from changing after parse() is called

(fixes babel/babel-eslint#558, fixes eslint/eslint#9767)

* Avoid using the enhanced referencer after monkeypatching

* Chore: add test for #558

* Pass correct scope analyzer options

* fix escope patch and improve tests

* remove process.exit(1)
nicolo-ribaudo pushed a commit to babel/babel that referenced this issue Nov 14, 2019
… called (fixes babel/babel-eslint#558)(babel/babel-eslint#559)

* Prevent parseForESLint() behavior from changing after parse() is called

(fixes babel/babel-eslint#558, fixes eslint/eslint#9767)

* Avoid using the enhanced referencer after monkeypatching

* Chore: add test for babel/babel-eslint#558

* Pass correct scope analyzer options

* fix escope patch and improve tests

* remove process.exit(1)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants