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

prefer-t-regex fails with t.is() with a single argument #347

Open
ehmicky opened this issue Aug 15, 2022 · 0 comments
Open

prefer-t-regex fails with t.is() with a single argument #347

ehmicky opened this issue Aug 15, 2022 · 0 comments

Comments

@ehmicky
Copy link

ehmicky commented Aug 15, 2022

When t.is() is passed 0 or 1 argument instead of 2, prefer-t-regex crashes.

This is related to #346, but that other issue seems to be more focused on graceful failures in general.

Steps to reproduce

test.js:

import test from 'ava'

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

.eslintrc.yml:

parserOptions:
  sourceType: module
  ecmaVersion: 2022
plugins: [ava]
rules:
  ava/prefer-t-regex: 2
$ eslint test.js 

Oops! Something went wrong! :(

ESLint: 8.22.0

TypeError: Cannot read properties of undefined (reading 'regex')
Occurred while linting /home/ehmicky/Desktop/test.js:4
Rule: "ava/prefer-t-regex"
    at isRegExp (/home/ehmicky/Desktop/node_modules/eslint-plugin-ava/rules/prefer-t-regex.js:83:14)
    at equalityHandler (/home/ehmicky/Desktop/node_modules/eslint-plugin-ava/rules/prefer-t-regex.js:138:32)
    at /home/ehmicky/Desktop/node_modules/eslint-plugin-ava/rules/prefer-t-regex.js:195:5
    at /home/ehmicky/Desktop/node_modules/enhance-visitors/index.js:25:12
    at /home/ehmicky/Desktop/node_modules/enhance-visitors/index.js:15:7
    at ruleErrorHandler (/home/ehmicky/Desktop/node_modules/eslint/lib/linter/linter.js:1114:28)
    at /home/ehmicky/Desktop/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/ehmicky/Desktop/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/ehmicky/Desktop/node_modules/eslint/lib/linter/node-event-generator.js:297:26)

ESLint: 8.22.0
eslint-plugin-ava: 13.2.0
Ava: 4.3.1

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

No branches or pull requests

1 participant