Skip to content

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

Closed
@abacabadabacaba

Description

@abacabadabacaba

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.

Activity

added and removed
triageWaiting for team members to take a look
on Nov 30, 2020
bradzacher

bradzacher commented on Nov 30, 2020

@bradzacher
Member

seems reasonable

added a commit that references this issue on Nov 30, 2020
5268900
added a commit that references this issue on Nov 30, 2020
525d2ff
abacabadabacaba

abacabadabacaba commented on Nov 30, 2020

@abacabadabacaba
Author

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

bradzacher

bradzacher commented on Nov 30, 2020

@bradzacher
Member
abacabadabacaba

abacabadabacaba commented on Nov 30, 2020

@abacabadabacaba
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.

locked as resolved and limited conversation to collaborators on Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [naming-convention] Support destructured modifier for parameters · Issue #2828 · typescript-eslint/typescript-eslint