Replies: 6 comments 21 replies
-
Note that we already have an option for enum member case. I am open to relax some default and adding some options. Could you be more explicit about the need? |
Beta Was this translation helpful? Give feedback.
-
Proposal v1I have spent some time thinking about your needs and more generally the needs of the community. I propose to add a way to select a given set of names to apply a custom format and require a prefix/suffix. Unlike the ESLint rule, we provide a limited set of selectors. Some selectors override others. For example, type Case = "camelCase" | "PascalCase" | "CONSTANT_CASE" | "snake_case"
type NamingConventionOptions = {
strictCase?: boolean, // same option as now
selectors: {
[selector: Selector]?: {
format?: Case[],
prefix?: string[],
suffix?: string[],
exceptions?: string[],
},
},
requireAscii: boolean,
ignoreQuoted: boolean,
/** @Deprecated */ enumMemberCase: Case,
}
type Selector =
| "default"
| "typeLike" // class, interface, type alias, type parameter, enum
| "interface"
| "function" // function declaration, function expression
| "namespaceLike" // namespace, import namespace, export namespace
| "enumMember"
| "method"
| "property" // class prop, prop parameter, type prop, object prop
| "privateProperty" // property with `private` or `protected` accessibility modifier
| "objectProperty"
| "staticProperty"
| "staticReadonlyProperty"
| "parameter"
| "variable"
| "const"
| "topLevelConst" Some examples of selectors:
With these new options, we could forbid leading and trailing underscores by default. The only exceptions are unused variables, which can always start with a single underscore. We still accept a leading and trailing dollar sign. This can be overridden in the `default' selector. |
Beta Was this translation helpful? Give feedback.
-
Would it make sense to hard-code some exceptions for selected industry standards like S3? Or does it go against the Biome’s philosophy? For some reason the S3 SDK does this: S3.PutObject({
Bucket: S3_IMAGES_BUCKET,
Key,
Body,
ContentEncoding: 'base64',
ContentType: img.mime,
CacheControl: 'public, max-age=31536000', // year
}) |
Beta Was this translation helpful? Give feedback.
-
I've just published #2770 that adds options to |
Beta Was this translation helpful? Give feedback.
-
Hey guys, beforehand I apoligize if that's not the right place for this, but can you explain how can we enforce naming conventions on abstract classes? ...
"conventions": [
{
"selector": {
"kind": "class",
"modifiers": ["abstract"]
},
"formats": ["PascalCase"]
}
]
... My IDE is throwing |
Beta Was this translation helpful? Give feedback.
-
Is there a way to migrate that rule? There is no 'exported' selector '@typescript-eslint/naming-convention': [
'error',
{
selector: ['variable'],
suffix: ['Api'],
format: ['camelCase'],
modifiers: ['exported', 'const'],
},
{
selector: ['function'],
suffix: ['Api'],
format: ['camelCase'],
modifiers: ['exported'],
},
] |
Beta Was this translation helpful? Give feedback.
-
Description
It would be nice to support all cases of
@typescript-eslint/naming-convention
rule, such as the following usage:Beta Was this translation helpful? Give feedback.
All reactions