Skip to content

prefer-t-regex crashes ESLint #251

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

Closed
ehmicky opened this issue Jun 1, 2019 · 4 comments · Fixed by #254
Closed

prefer-t-regex crashes ESLint #251

ehmicky opened this issue Jun 1, 2019 · 4 comments · Fixed by #254
Labels

Comments

@ehmicky
Copy link

ehmicky commented Jun 1, 2019

example.js:

import test from 'ava'

const func = () => {}

test('example', t => {
  t.true(func())
})

.eslintrc.yml:

parserOptions:
  ecmaVersion: 2019
  sourceType: module
plugins: [eslint-plugin-ava]
rules:
  ava/prefer-t-regex: 2

package.json:

{
  "name": "eslint-plugin-ava-bug",
  "version": "0.0.1",
  "dependencies": {
    "eslint": "^5.16.0",
    "eslint-plugin-ava": "^7.0.0"
  }
}

Then:

$ eslint example.js 
TypeError: Cannot destructure property `name` of 'undefined' or 'null'.
Occurred while linting /home/ether/Desktop/eslint-plugin-ava-bug/example.js:6
    at /home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint-plugin-ava/rules/prefer-t-regex.js:44:10
    at /home/ether/Desktop/eslint-plugin-ava-bug/node_modules/enhance-visitors/index.js:25:12
    at /home/ether/Desktop/eslint-plugin-ava-bug/node_modules/enhance-visitors/index.js:15:7
    at /home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/util/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/home/ether/Desktop/eslint-plugin-ava-bug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)

Node 12.3.1
Ubuntu 19.04

@novemberborn
Copy link
Member

That looks like this line:

const {name} = firstArg.callee.property;

I guess the assumption there is wrong. @GMartigny what do you reckon?

@GMartigny
Copy link
Contributor

You're absolutely right @novemberborn.
I did not consider this case. I pushed a fix with regression test.

@ehmicky
Copy link
Author

ehmicky commented Jun 2, 2019

I just checked it and it works, thanks @GMartigny and @novemberborn!

@novemberborn
Copy link
Member

Thanks @ehmicky! I’m working on a fix for #252 as well. Will ping you once that’s ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants