Skip to content

[no-extraneous-class] Rule always throws an AssertionError #170

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
sebald opened this issue Jan 31, 2019 · 1 comment · Fixed by #174
Closed

[no-extraneous-class] Rule always throws an AssertionError #170

sebald opened this issue Jan 31, 2019 · 1 comment · Fixed by #174
Assignees
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@sebald
Copy link

sebald commented Jan 31, 2019

Repro

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "extends": ["plugin:@typescript-eslint/recommended"],
  "rules": {
    "@typescript-eslint/no-extraneous-class": "error"
  }
}

Note: the error occurs by just turning the rule on. So the below is not necessary

export default class Foo {
  hello() {
    return 'I am foo!';
  }

  waitFor(it: string) {
    return Promise.resolve(it);
  }
}

Expected Result
No exception.

Actual Result

Stack trace:

AssertionError [ERR_ASSERTION]: Node must be provided when reporting error if location is not provided
    at assertValidNodeInfo (<path>/node_modules/eslint/lib/util/report-translator.js:96:9)
    at args (<path>/node_modules/eslint/lib/util/report-translator.js:246:9)
    at Object.report (<path>/node_modules/eslint/lib/linter.js:720:41)
    at ClassBody (<path>/node_modules/@typescript-eslint/eslint-plugin/lib/rules/no-extraneous-class.js:71:19)
    at listeners.(anonymous function).forEach.listener (<path>/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (<path>/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (<path>/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (<path>/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (<path>/node_modules/eslint/lib/util/node-event-generator.js:294:14)

Additional Info

If I turn the rule everything works fine.

Versions

package version
@typescript-eslint/eslint-plugin 1.1.1
@typescript-eslint/parser 1.1.1
TypeScript 3.2.4
ESLint 5.12.1
node 10.15.1
npm 6.5.0
@sebald sebald added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 31, 2019
@bradzacher bradzacher added the bug Something isn't working label Jan 31, 2019
@armano2
Copy link
Collaborator

armano2 commented Jan 31, 2019

issue is not related to code provided in example, its for classes without name

export default class {}

@armano2 armano2 self-assigned this Jan 31, 2019
@bradzacher bradzacher removed the triage Waiting for team members to take a look label Jan 31, 2019
@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants