question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prefer-to-be-null TypeError with TSAsExpression

See original GitHub issue

ESLint: 6.1.0 @typescript-eslint/parser: 1.12.0 eslint-plugin-jest: 22.12.0

Code:

(expect('Model must be bound to an array if the multiple property is true') as any).toHaveBeenTipped()

Error in methodName:

TypeError: Cannot read property 'name' of undefined
Occurred while linting /home/kael/Documents/vuetifyjs/vuetify/packages/vuetify/src/components/VItemGroup/__tests__/VItemGroup.spec.ts:53
    at methodName (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint-plugin-jest/lib/rules/util.js:70:12)
    at expectNotCase (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint-plugin-jest/lib/rules/util.js:23:101)
    at expectToBeCase (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint-plugin-jest/lib/rules/util.js:43:41)
    at CallExpression (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint-plugin-jest/lib/rules/prefer-to-be-null.js:25:45)
    at /home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint/lib/linter/node-event-generator.js:253:26)
    at NodeEventGenerator.applySelectors (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint/lib/linter/node-event-generator.js:282:22)
    at NodeEventGenerator.enterNode (/home/kael/Documents/vuetifyjs/vuetify/node_modules/eslint/lib/linter/node-event-generator.js:296:14)

image node.parent.property is undefined

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Aug 4, 2019

Do we want to add a test case for this?

Yes 😃

We can have a separate RuleTester for these ones in the same test file. I’d like to keep most tests with the default parser

1reaction
G-Rathcommented, Aug 4, 2019

Bamn - TS conversion fixed this.

Do we want to add a test case for this?

It’s a generic problem, and in order to have a test for it we’ll have to set the parser for RuleTester to RuleTester parser to be set to @typescript-eslint/parser, b/c of the as:

const ruleTester = new TSESLint.RuleTester({
  parserOptions: { ecmaVersion: 2015 },
  parser: '@typescript-eslint/parser',
});

If we want a test case, I think ideally it should be added to the “standard tests” object I’m going to look to make, in which case all tests should be run using @typescript-eslint/parser.

I’ve got no problem w/ this, but don’t know what the impacts to performance & co might be 😂

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found