Closed
Description
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
bradzacher commentedon Nov 30, 2020
seems reasonable
feat(eslint-plugin): [naming-convention] allow `destructured` modifie…
destructured
modifier forparameter
selector #2829feat(eslint-plugin): [naming-convention] allow `destructured` modifie…
abacabadabacaba commentedon Nov 30, 2020
@bradzacher I think that this modifier should be supported for
selector: "variableLike"
as well, as it includes bothvariable
andparameter
.bradzacher commentedon Nov 30, 2020
You can use the array form of selector to specify multiple selectors.
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md#selector-options
abacabadabacaba commentedon Nov 30, 2020
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"]
withselector: "default"
andselector: "variable"
but notselector: "variableLike"
, and it doesn't seem right.