Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.14 breaks my eslint: Cannot read property 'type' of undefined #9771

Closed
chapati23 opened this issue Dec 25, 2017 · 2 comments
Closed

4.14 breaks my eslint: Cannot read property 'type' of undefined #9771

chapati23 opened this issue Dec 25, 2017 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion triage An ESLint team member will look at this issue soon

Comments

@chapati23
Copy link

Tell us about your environment

  • ESLint Version:
    4.14

  • Node Version:
    8.9.1 (tried 9.3.0 as well, same result)

  • npm Version:
    5.6.0

What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint 8.1.0

Please show your full configuration:

Configuration
module.exports = {
  parser: 'babel-eslint',
  parserOptions: {
    ecmaFeatures: {
      generators: true,
      experimentalObjectRestSpread: true
    },
    sourceType: 'module',
    allowImportExportEverywhere: false
  },
  extends: [
    'eslint:recommended',
    'plugin:css-modules/recommended',
    'plugin:flowtype/recommended',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:jest/recommended',
    'plugin:promise/recommended',
    'plugin:react/recommended',
    'plugin:react-ssr/all',
    'plugin:redux-saga/recommended',
    'plugin:security/recommended'
  ],
  plugins: [
    'compat',
    'css-modules',
    'flowtype',
    'jest',
    'prettier',
    'promise',
    'react',
    'react-ssr',
    'redux-saga',
    'security'
  ],
  settings: {
    flowtype: {
      onlyFilesWithFlowAnnotation: true
    },
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.json', '.css'],
        paths: './src'
      }
    },
    polyfills: ['fetch', 'promises']
  },
  env: {
    browser: true,
    'jest/globals': true
  },
  globals: {
    __DEV__: true,
    __dirname: true,
    artifacts: true,
    afterEach: true,
    beforeEach: true,
    beforeAll: true,
    console: true,
    describe: true,
    xdescribe: true,
    document: true,
    expect: true,
    fetch: true,
    global: true,
    Intl: true,
    it: true,
    xit: true,
    jest: true,
    module: true,
    process: true,
    Promise: true,
    require: true,
    setTimeout: true,
    test: true,
    window: true
  },
  rules: Object.assign(
    {},
    cssModulesRules,
    compatRules,
    flowtypeRules,
    importRules,
    prettierRules,
    promiseRules,
    reactRules,
    securityRules,
    {
      /*
       * Deactivated because prettier takes care of this for us
       * https://eslint.org/docs/rules/arrow-body-style
       */
      'arrow-body-style': 'off',

      /*
       * require an empty line between class members
       * https://eslint.org/docs/rules/lines-between-class-members
       */
      'lines-between-class-members': ['error', 'always'],

      /*
       * enforce adding specific exceptions when using console.log()
       * so we don't forget any accidental console.logs in the code
       * https://eslint.org/docs/rules/no-console
       */
      'no-console': ['error', { allow: ['assert'] }],

      /*
       * don't allow the same variable name inside a given scope
       * https://eslint.org/docs/rules/no-shadow
       */
      'no-shadow': 'error',

      /*
       * require let or const instead of var
       * https://eslint.org/docs/rules/no-var
       */
      'no-var': 'error',

      'padding-line-between-statements': [
        'error',
        { blankLine: 'always', prev: 'class', next: '*' },
        { blankLine: 'always', prev: 'do', next: '*' },
        { blankLine: 'always', prev: '*', next: 'export' },
        { blankLine: 'always', prev: 'for', next: '*' },
        { blankLine: 'always', prev: 'if', next: '*' },
        { blankLine: 'always', prev: 'switch', next: '*' },
        { blankLine: 'always', prev: 'try', next: '*' },
        { blankLine: 'always', prev: 'while', next: '*' },
        { blankLine: 'always', prev: 'with', next: '*' }
      ],

      /*
       * if a let variable is never reassigned, use const instead of let
       * https://eslint.org/docs/rules/prefer-const
       */
      'prefer-const': 'error'
    }
  )
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

    if (format.second) {
      let seconds = moment.duration(remainingTime).get('seconds')
      seconds = seconds >= 0 ? seconds : 0
      if (leadingZero) {
        seconds = addLeadingZero(seconds)
      }
      html.push(
        <span className="react-cntdwn-second" key="second">
          {seconds}sec
        </span>
      )
    }
eslint --fix 'src/**/*.js'

What did you expect to happen?
Run eslint as usual

What actually happened? Please include the actual, raw output from ESLint.
eslint throws an error

Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at isForInRef (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:410:24)
    at variable.references.some.ref (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:447:21)
    at Array.some (<anonymous>)
    at isUsedVariable (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:446:40)
    at collectUnusedVariables (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:569:26)
    at collectUnusedVariables (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:576:17)
    at Program:exit (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/rules/no-unused-vars.js:621:36)
    at listeners.(anonymous function).forEach.listener (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
    at Traverser.leave [as _leave] (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/linter.js:1000:32)
    at Traverser._traverse (/Users/chapati/projects/brickblock/brickblock-ui/node_modules/eslint/lib/util/traverser.js:155:18)
error Command failed with exit code 1.

What could be the reason?
Reverting to 4.13 fixes the error for me so it must have been something introduced in 4.14
Maybe this one? 1c2aafd

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Dec 25, 2017
@chapati23 chapati23 changed the title 4.14 breaks my eslint: 4.14 breaks my eslint: Cannot read property 'type' of undefined Dec 25, 2017
@mysticatea
Copy link
Member

mysticatea commented Dec 25, 2017

Thank you for the report.

Would you confirm if it's duplicate of #9762 or #9767? (does it reproduce with babel-eslint@8.1.1?)

@chapati23
Copy link
Author

thanks @mysticatea, just saw the patch to babel-eslint@8.1.1 came out today and indeed fixed this problem.

merry christmas :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

2 participants