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:
πŸ’Ό
The rule is part of the shared configuration
πŸ”§
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.