Skip to content

@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:
🔧
Some problems reported are fixable by the --fix command line option
RuleDescription
block-spacingDisallow or enforce spaces inside of blocks after opening block and before closing block🔧
brace-styleEnforce consistent brace style for blocks🔧
comma-dangleRequire or disallow trailing commas🔧
comma-spacingEnforce consistent spacing before and after commas🔧
func-call-spacingRequire or disallow spacing between function identifiers and their invocations. Alias of `function-call-spacing`.🔧
function-call-spacingRequire or disallow spacing between function identifiers and their invocations🔧
indentEnforce consistent indentation🔧
key-spacingEnforce consistent spacing between property names and type annotations in types and interfaces🔧
keyword-spacingEnforce consistent spacing before and after keywords🔧
lines-around-commentRequire empty lines around comments🔧
lines-between-class-membersRequire or disallow an empty line between class members🔧
member-delimiter-styleRequire a specific member delimiter style for interfaces and type literals🔧
no-extra-parensDisallow unnecessary parentheses🔧
no-extra-semiDisallow unnecessary semicolons🔧
object-curly-spacingEnforce consistent spacing inside braces🔧
padding-line-between-statementsRequire or disallow padding lines between statements🔧
quote-propsRequire quotes around object literal, type literal, interfaces and enums property names🔧
quotesEnforce the consistent use of either backticks, double, or single quotes🔧
semiRequire or disallow semicolons instead of ASI🔧
space-before-blocksEnforce consistent spacing before blocks🔧
space-before-function-parenEnforce consistent spacing before function parenthesis🔧
space-infix-opsRequire spacing around infix operators🔧
type-annotation-spacingRequire consistent spacing around type annotations🔧
23 rules in total.

Released under the MIT License.