@stylistic/eslint-plugin-ts
TypeScript stylistic rules for ESLint, migrated from typescript-eslint
.
Credits to all contributors who have committed to the original rules.
TIP
We recommend using @stylistic/eslint-plugin
as it includes the rules for both JavaScript and TypeScript
Install
sh
npm i -D @stylistic/eslint-plugin-ts
Add @stylistic/ts
to your plugins list, and change the prefix for stylistic rules from @typescript-eslint/
to @stylistic/ts/
:
js
// eslint.config.js
import stylisticTs from '@stylistic/eslint-plugin-ts'
import parserTs from '@typescript-eslint/parser'
export default [
{
plugins: {
'@stylistic/ts': stylisticTs
},
parser: parserTs,
rules: {
'@typescript-eslint/indent': ['error', 2],
'@stylistic/ts/indent': ['error', 2],
// ...
}
}
]
js
// .eslintrc.js
module.exports = {
plugins: [
'@typescript-eslint',
'@stylistic/ts',
],
parser: '@typescript-eslint/parser',
rules: {
'@typescript-eslint/indent': ['error', 2],
'@stylistic/ts/indent': ['error', 2],
// ...
}
};
Note that this package only contains stylistic rules. You still need to install @typescript-eslint/parser
and @typescript-eslint/eslint-plugin
to parse and lint your TypeScript code.
Check out the migration guide for more details.
Rules
Each rule has emojis denoting:
💼
The rule is part of the shared configuration
🔧
Some problems reported are fixable by the
--fix
command line option Rule | Description | ||
block-spacing | Disallow or enforce spaces inside of blocks after opening block and before closing block | 💼 | 🔧 |
brace-style | Enforce consistent brace style for blocks | 💼 | 🔧 |
comma-dangle | Require or disallow trailing commas | 💼 | 🔧 |
comma-spacing | Enforce consistent spacing before and after commas | 💼 | 🔧 |
func-call-spacing | Require or disallow spacing between function identifiers and their invocations | 🔧 | |
function-call-spacing | Require or disallow spacing between function identifiers and their invocations | 🔧 | |
indent | Enforce consistent indentation | 💼 | 🔧 |
key-spacing | Enforce consistent spacing between property names and type annotations in types and interfaces | 💼 | 🔧 |
keyword-spacing | Enforce consistent spacing before and after keywords | 💼 | 🔧 |
lines-around-comment | Require empty lines around comments | 🔧 | |
lines-between-class-members | Require or disallow an empty line between class members | 💼 | 🔧 |
member-delimiter-style | Require a specific member delimiter style for interfaces and type literals | 💼 | 🔧 |
no-extra-parens | Disallow unnecessary parentheses | 💼 | 🔧 |
no-extra-semi | Disallow unnecessary semicolons | 🔧 | |
object-curly-newline | Enforce consistent line breaks after opening and before closing braces | 🔧 | |
object-curly-spacing | Enforce consistent spacing inside braces | 💼 | 🔧 |
object-property-newline | Enforce placing object properties on separate lines | 🔧 | |
padding-line-between-statements | Require or disallow padding lines between statements | 🔧 | |
quote-props | Require quotes around object literal, type literal, interfaces and enums property names | 💼 | 🔧 |
quotes | Enforce the consistent use of either backticks, double, or single quotes | 💼 | 🔧 |
semi | Require or disallow semicolons instead of ASI | 💼 | 🔧 |
space-before-blocks | Enforce consistent spacing before blocks | 💼 | 🔧 |
space-before-function-paren | Enforce consistent spacing before function parenthesis | 💼 | 🔧 |
space-infix-ops | Require spacing around infix operators | 💼 | 🔧 |
type-annotation-spacing | Require consistent spacing around type annotations | 💼 | 🔧 |
25 rules in total.