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

[naming-convention] Support destructured modifier for parameters #2828

Closed
abacabadabacaba opened this issue Nov 29, 2020 · 4 comments · Fixed by #2829
Closed

[naming-convention] Support destructured modifier for parameters #2828

abacabadabacaba opened this issue Nov 29, 2020 · 4 comments · Fixed by #2829
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@abacabadabacaba
Copy link

Currently, naming-convention rule supports destructured modifier only for variables. I propose to also support it for parameters.

Repro

{
  "rules": {
    "@typescript-eslint/naming-convention": ["error",
      {
        "selector": "parameter",
        "modifiers": ["destructured"],
        "format": ["camelCase"]
      }
    ]
  }
}
function foo({ aNameToBeChecked }: any) {
  // ...
}

Expected Result

The identifier aNameToBeChecked matches the rule.

Actual Result

The destructured modifier isn't supported with selector: "parameter", so it doesn't work.

Versions

This issue is currently present in the master branch.

@abacabadabacaba abacabadabacaba added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Nov 29, 2020
@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule and removed triage Waiting for maintainers to take a look labels Nov 30, 2020
@bradzacher
Copy link
Member

seems reasonable

@abacabadabacaba
Copy link
Author

@bradzacher I think that this modifier should be supported for selector: "variableLike" as well, as it includes both variable and parameter.

@bradzacher
Copy link
Member

@abacabadabacaba
Copy link
Author

You can use the array form of selector to specify multiple selectors.

Yes, but the whole point of group selectors is to be a concise replacement for all the selectors they are equivalent to, so they should support the same modifiers as the individual selectors.

Currently, it is possible to use modifiers: ["destructured"] with selector: "default" and selector: "variable" but not selector: "variableLike", and it doesn't seem right.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants