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

fix(eslint-plugin): [no-unused-vars-experimental] handle processable private accessors #2132

Closed

Conversation

brn
Copy link

@brn brn commented May 30, 2020

What is this PR?

If no-unused-vars-experimental rule found private get/set accessor in class, throw
Error: Unknown node with kind 162/163.
because of accessor is not treated correctly.

So this pr fix that problems.

Reproduce

package.json

{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "main": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.0.2",
    "@typescript-eslint/parser": "^3.0.2",
    "@typescript-eslint/typescript-estree": "^3.0.2",
    "eslint": "^7.1.0",
    "typescript": "^3.9.3"
  }
}

.eslintrc.js

module.exports = {
  root: true,
  plugins: ['@typescript-eslint'],
  rules: {
    '@typescript-eslint/no-unused-vars-experimental': [
      'error',
      {
        ignoreArgsIfArgsAfterAreUsed: true,
        ignoredNamesRegex: '^unused'
      }
    ]
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  }
}

Project structure

project +
        |
        + - package.json
        | 
        + - .eslintrc.js
        | 
        +- src
             |
             +- a.ts

a.ts

class Test {
  private get name() {
    return "test";
  }
}

Command

npx eslint --fix --max-warnings 0 'src/a.ts'

Error message

➜ npx eslint --fix --max-warnings 0 'src/a.ts'

Oops! Something went wrong! :(

ESLint: 7.1.0

Error: Unknown node with kind 163.
Occurred while linting /private/tmp/project/src/a.ts:1
    at handleIdentifier (/private/tmp/project/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars-experimental.js:163:27)
    at /private/tmp/project/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars-experimental.js:266:33
    at Array.forEach (<anonymous>)
    at Program:exit (/private/tmp/project/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-vars-experimental.js:260:29)
    at /private/tmp/project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/private/tmp/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/private/tmp/project/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/private/tmp/project/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.leaveNode (/private/tmp/project/node_modules/eslint/lib/linter/node-event-generator.js:306:14)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @brn!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@bradzacher bradzacher added the bug Something isn't working label May 30, 2020
@bradzacher bradzacher changed the title fix: Make no-unused-vars-experimental processable private accessors. fix(eslint-plugin): [no-unused-vars-experimental] handle processable private accessors May 30, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry - could you please add a test case for this to ensure we don't have a regression in future?

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label May 30, 2020
@brn
Copy link
Author

brn commented May 31, 2020

@bradzacher Oh, sorry I missed that. I wll add.

@bradzacher
Copy link
Member

#1856 is being released in 4.0, so no-unused-vars-experimental is being deprecated.

As such, we won't be accepting fixes for the rule, and suggest moving to the non-experimental version.
Thanks for the PR!

@bradzacher bradzacher closed this Aug 6, 2020
@bradzacher bradzacher added wontfix This will not be worked on and removed awaiting response Issues waiting for a reply from the OP or another party labels Aug 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants