eslint-plugin icon indicating copy to clipboard operation
eslint-plugin copied to clipboard

Linting the following code throws TypeError

Open hakatashi opened this issue 3 years ago • 1 comments

const array = [0, 1, 2];
for (let i = 0; i < array.length; i++) {
  let variable;
  console.log(array[i]);
}

Reproduction Steps

$ mkdir eslint-config-repro
$ cd .\eslint-config-repro

$ npm install eslint @mysticatea/eslint-plugin

added 167 packages, and audited 168 packages in 15s

17 packages are looking for funding
  run `npm fund` for details

10 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

$ cp ../test.js test.js # put the code above

$ npx eslint --plugin "@mysticatea" --rule "@mysticatea/prefer-for-of: error" --parser-options=ecmaVersion:6 test.js
TypeError: Cannot read properties of null (reading 'type')
Occurred while linting C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\test.js:2
    at getElementVariableDeclaration (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\@mysticatea\eslint-plugin\lib\rules\prefer-for-of.js:366:25)
    at fixForStatement (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\@mysticatea\eslint-plugin\lib\rules\prefer-for-of.js:478:21)
    at normalizeFixes (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\report-translator.js:178:28)
    at C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\report-translator.js:343:49
    at Object.report (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\linter.js:905:41)
    at ForStatement:exit (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\@mysticatea\eslint-plugin\lib\rules\prefer-for-of.js:610:29)       
    at C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (C:\Users\hakatashi\Documents\GitHub\eslint-config-repro\node_modules\eslint\lib\linter\node-event-generator.js:254:26) 

Versions

     "@mysticatea/eslint-plugin": "13.0.0",
    "eslint": "6.8.0"

hakatashi avatar Mar 22 '22 18:03 hakatashi

Hi @hakatashi!

Since this repo is unmaintained, you might want to re-open this issue in the @eslint-community fork https://github.com/eslint-community/eslint-plugin-mysticatea

For more info about why we created this organization, you can read https://eslint.org/blog/2023/03/announcing-eslint-community-org

MichaelDeBoey avatar Oct 14 '23 15:10 MichaelDeBoey