Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
class Test {
// these identifiers should not match formats with the "public" modifier
#privateField = 1;
#privateMethod() {}
}
ESLint Config
{
"rules": {
"@typescript-eslint/naming-convention": [
"error",
{
"format": ["StrictPascalCase"],
"selector": "classProperty",
"modifiers": ["public"]
},
{
"format": ["strictCamelCase"],
"selector": "classProperty"
},
{
"format": ["StrictPascalCase"],
"selector": "classMethod",
"modifiers": ["public"]
},
{
"format": ["strictCamelCase"],
"selector": "classMethod"
}
]
}
}
tsconfig
Expected Result
I expect class members with private identifiers (those starting with #
) to be considered private
, so there should be no errors in the example above.
Actual Result
There are errors in line 3 and 4:
Class Property name 'privateField' must match one of the following formats: StrictPascalCase
Class Method name 'privateMethod' must match one of the following formats: StrictPascalCase
These errors are due to the rule ignoring the #
sign and considering the fields as public because there are no typescript accessibility modifiers in front. Using "filter": { "regex": "^#", "match": false }
to work around the issue also does not work because the #
sign is ignored in the rule.
Additional Info
No response