adjacent-overload-signatures
array-type
T[]
or Array<T>
for arraysArray<T>
and T[]
styles in the code, which could potentially lead to confusion or errors, especially for developers new to TypeScript or those working across multiple projects with different style preferences.T[]
is generally shorter and more to the point compared to Array<T>
, making the code less cluttered and quicker to read and understand.await-thenable
await
only with actual Promise objects (Thenables), thus preventing runtime errors from awaiting non-Promise values.await
keyword with values that do not represent asynchronous operations, thereby guiding developers towards correct usage patterns and promoting best practices in asynchronous programming.ban-ts-comment
@ts-<directive>
comments or require descriptions after directives@ts-<directive>
comments like @ts-ignore
without an accompanying explanation, promoting better code documentation and clarity on why type checking is being bypassed.ban-tslint-comment
// tslint:<rule-flag>
comments@typescript-eslint
plugin, by redirecting developers to use the appropriate ESLint rules instead of the now-deprecated TSLint comments.ban-types
{}
type in TypeScript, which represents an empty object but actually allows any non-nullish value, leading to potential misuse where stricter type checking is expected. It encourages developers to explicitly state their intent, enhancing code readability and maintainability.
unknown
instead of {}
, it helps to catch type-related errors at compile time rather than runtime. This can lead to more robust and predictable code behavior, as developers are forced to narrow down the type before usage.
{}
type in favor of more specific types like unknown
, the rule helps in maintaining a high level of type safety.
block-spacing
brace-style
if-else
statements, loops, and function blocks.class-literal-property-style
class-methods-use-this
this
this
are statically defined, which can lead to better organization of the code by clearly distinguishing between methods that operate on instance variables and those that don’t.comma-dangle
comma-spacing
consistent-generic-constructors
consistent-indexed-object-style
Record
typeRecord
type which can lead to easier refactoring and stronger type checks, especially in larger codebases where explicit types are beneficial for understandability.consistent-type-assertions
as Type
or <Type>
syntax consistently, based on the configuration.as Type
vs. <Type>
), particularly for developers who might not be aware of the nuances or have a preference for one over the other. A consistent syntax ensures that type assertions are made explicitly and correctly throughout the application.consistent-type-definitions
interface
or type
interface
or always using type
. Consistency in coding style makes the code more readable and maintainable, especially for teams.
interface
vs type
. In TypeScript, while both have their specific use cases, they are often interchangeable. Standardizing on one reduces cognitive load for the developers.
type
to interface
to leverage interface merging), having a consistent starting point makes the process more straightforward and less error-prone.
interface
or type
), the rule indirectly encourages best practices associated with that method. For example, if interface
is chosen, it promotes the use of interface merging. Conversely, if type
is chosen, it might encourage leveraging union types more effectively.
consistent-type-exports
consistent-type-imports
import type
for TypeScript types and interfaces, which makes the intention of importing such entities solely for type-checking purposes clear. This enhances code readability and understanding, especially for new developers or when revisiting the code after some time.
import type
prevents the JavaScript engine from trying to load modules that are only needed for type checking, optimizing performance.
default-param-last
function greet(message = "Hi", name) {...}
to function greet(name, message = "Hi") {...}
.function greet(name, message = "Hi") {...}
), it is easy to omit the second argument without affecting the function’s behavior, whereas in the problematic example, omitting the second argument (name
) would lead to errors or unexpected behavior.dot-notation
explicit-function-return-type