@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
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
// .eslintrc.js
module.exports = {
plugins: [
'@typescript-eslint',
'@stylistic/ts',
],
parser: '@typescript-eslint/parser',
rules: {
'@typescript-eslint/indent': ['error', 2],
'@stylistic/ts/indent': ['error', 2],
// ...
}
};
// .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
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. Alias of `function-call-spacing`. |
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-spacing | Enforce consistent spacing inside braces |
padding-line-between-statements | Require or disallow padding lines between statements |
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 |