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

Cannot read property 'push' of undefined #11929

Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@bowernite
Copy link

Tell us about your environment

  • macOS 10.14.4

  • ESLint Version: 6.0.1

  • Node Version: 8.16.0

  • npm Version: 6.4.1

What parser (default, Babel-ESLint, etc.) are you using? Default

Please show your full configuration:

Configuration
module.exports = {
  env: {
    es6: true,
  },
  parserOptions: {
    ecmaVersion: 6,
  },

  rules: {
    /**
     * Possible Errors
     *
     * https://eslint.org/docs/rules/#possible-errors
     */
    'no-compare-neg-zero': 2,
    'no-cond-assign': 2,
    'no-console': 2,
    'no-constant-condition': 2,
    'no-debugger': 2,
    'no-dupe-args': 2,
    'no-dupe-keys': 2,
    'no-duplicate-case': 2,
    'no-empty': 2,
    'no-empty-character-class': 2,
    'no-ex-assign': 2,
    'no-extra-boolean-cast': 2,
    'no-extra-semi': 2,
    'no-func-assign': 2,
    'no-inner-declarations': 2,
    'no-invalid-regexp': 2,
    'no-irregular-whitespace': 2,
    'no-obj-calls': 2,
    'no-regex-spaces': 2,
    'no-sparse-arrays': 0,
    'no-template-curly-in-string': 2,
    'no-unexpected-multiline': 2,
    'no-unreachable': 2,
    'no-unsafe-finally': 2,
    'use-isnan': 2,
    'valid-typeof': 2,
    eqeqeq: ['error', 'always'],

    /**
     * Best Practices
     *
     * https://eslint.org/docs/rules/#best-practices
     */
    'no-caller': 2,
    'no-case-declarations': 2,
    'no-empty-pattern': 2,
    'no-extend-native': 2,
    'no-new-wrappers': 2,
    'no-octal': 2,
    'no-redeclare': 2,
    'no-self-assign': 2,
    'no-unused-labels': 2,
    'no-var': 2,

    /**
     * ESLint's "Variables" rules
     *
     * https://eslint.org/docs/rules/#variables
     */
    'no-delete-var': 2,
    'no-undef': 2,
    'no-unused-vars': [
      2,
      {
        args: 'none',
        ignoreRestSiblings: true,
      },
    ],
    'no-use-before-define': [
      2,
      {
        functions: false,
      },
    ],

    /**
     * ECMAScript 6
     *
     * https://eslint.org/docs/rules/#ecmascript-6
     */
    'constructor-super': 2,
  },
};

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

Can't tell which source code, if any, is triggering this.

./node_modules/.bin/eslint .

This does not happen if I run something like ./node_modules/.bin/eslint js where js is a directory.

What did you expect to happen?
ESLint runs as usual

What actually happened? Please include the actual, raw output from ESLint.

TypeError: Cannot read property 'push' of undefined
    at ast.comments.filter.forEach.comment (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:316:57)
    at Array.forEach (<anonymous>)
    at getDirectiveComments (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:270:60)
    at Linter._verifyWithoutProcessors (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:1065:15)
    at Linter._verifyWithConfigArray (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:1177:21)
    at Linter.verify (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:1132:25)
    at Linter.verifyAndFix (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/linter/linter.js:1322:29)
    at verifyText (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/cli-engine/cli-engine.js:231:48)
    at CLIEngine.executeOnFiles (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/cli-engine/cli-engine.js:781:28)
    at Object.execute (/Users/abr1402/nml/nm-innovation-hub-gen/node_modules/eslint/lib/cli.js:209:111)

Are you willing to submit a pull request to fix this bug?
Depends on how complex the fix is 🤷‍♀

@bowernite bowernite added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 1, 2019
@platinumazure
Copy link
Member

Hi @babramczyk, could you please run ESLint with the --debug flag? It should hopefully show the last file being linted before the error. Then, could you please post the contents of that file (if there are no confidentiality issues)? It will help us try to reproduce the issue. Thanks!

@platinumazure platinumazure added core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 1, 2019
@bowernite
Copy link
Author

So here is one (it seems of many) files that it chokes on. It's a build file from Vue, I believe (I've since ignored it in .eslintrc.js.

https://gist.github.com/babramczyk/ed2dcfa579fc83bc8294e3334d4e3319

@platinumazure platinumazure added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 3, 2019
@platinumazure
Copy link
Member

Marking as accepted based on the linked PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.