Closed
Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existing open or closed documentation requests that match my proposal.
- I have read the FAQ and my problem is not listed.
Suggested Changes
In our FAQ we instruct people to use no-restricted-syntax
for cases of banning specific syntax rather than us creating bespoke rules.
As people report cases, we should add them to the docs so that they're discoverable.
Maybe a sub-page of the FAQ rather than directly on the FAQ itself?
Side note that this would be good to link into #5846
Examples:
Ban const
enums
{
selector: 'TSEnumDeclaration[const=true]',
message: 'My reason for not using const enums',
}
Ban non-const
enums
{
selector: 'TSEnumDeclaration:not([const=true])',
message: 'My reason for not using const enums',
}
Enforce tuple members have labels
{
selector: 'TSTupleType > :not(TSNamedTupleMember)',
message: 'All tuples should have labels',
}
Ban private
members
{
selector: ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
message: 'Use `#private` members instead',
}
Ban #private
members
{
selector: ':matches(PropertyDefinition, MethodDefinition) > PrivateIdentifier.key',
message: 'Use the `private` modifier instead',
}
Ban static this
{
selector: 'MethodDefinition[static = true] ThisExpression',
message: "Prefer using the class's name directly",
}
Ban accessors
{
selector: 'Property:matches([kind = "get"], [kind = "set"]), MethodDefinition:matches([kind = "get"], [kind = "set"])',
message: "Don't use accessors",
}