Skip to content

@stylistic/eslint-plugin โ€‹

Stylistic rules for ESLint, works for both JavaScript, TypeScript and JSX.

Shared Configurations โ€‹

This plugin provides some built-in configurations that you can use out of the box. Learn more about shared configurations.

Install โ€‹

sh
npm i -D @stylistic/eslint-plugin

Add @stylistic to your plugins list, and prefix stylistic rules with @stylistic:

js
// eslint.config.js
import stylistic from '@stylistic/eslint-plugin'

export default [
  {
    plugins: {
      '@stylistic': stylistic
    },
    rules: {
      'indent': ['error', 2],
      '@stylistic/indent': ['error', 2],
      // ...
    }
  }
]
js
// Legacy config is no longer supported in v4+
// Please use v3.x if you need to use legacy config
// We encourage you to migrate to flat config soon

// .eslintrc.js
module.exports = {
  plugins: [
    '@stylistic'
  ],
  rules: {
    'indent': ['error', 2],
    '@stylistic/indent': ['error', 2],
    // ...
  }
}

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
๐Ÿงช
This is an experimental rule, should have exp- prefix when using.
RuleDescription
array-bracket-newlineEnforce linebreaks after opening and before closing array brackets๐Ÿ”ง
array-bracket-spacingEnforce consistent spacing inside array brackets๐Ÿ’ผ๐Ÿ”ง
array-element-newlineEnforce line breaks after each array element๐Ÿ”ง
arrow-parensRequire parentheses around arrow function arguments๐Ÿ’ผ๐Ÿ”ง
arrow-spacingEnforce consistent spacing before and after the arrow in arrow functions๐Ÿ’ผ๐Ÿ”ง
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๐Ÿ’ผ๐Ÿ”ง
comma-styleEnforce consistent comma style๐Ÿ’ผ๐Ÿ”ง
computed-property-spacingEnforce consistent spacing inside computed property brackets๐Ÿ’ผ๐Ÿ”ง
curly-newlineEnforce consistent line breaks after opening and before closing braces๐Ÿ”ง
dot-locationEnforce consistent newlines before and after dots๐Ÿ’ผ๐Ÿ”ง
eol-lastRequire or disallow newline at the end of files๐Ÿ’ผ๐Ÿ”ง
function-call-argument-newlineEnforce line breaks between arguments of a function call๐Ÿ”ง
function-call-spacingRequire or disallow spacing between function identifiers and their invocations๐Ÿ”ง
function-paren-newlineEnforce consistent line breaks inside function parentheses๐Ÿ”ง
generator-star-spacingEnforce consistent spacing around `*` operators in generator functions๐Ÿ’ผ๐Ÿ”ง
implicit-arrow-linebreakEnforce the location of arrow function bodies๐Ÿ”ง
indentEnforce consistent indentation๐Ÿ’ผ๐Ÿ”ง
indent-binary-opsIndentation for binary operators๐Ÿ’ผ๐Ÿ”ง
jsx-child-element-spacingEnforce or disallow spaces inside of curly braces in JSX attributes and expressions
jsx-closing-bracket-locationEnforce closing bracket location in JSX๐Ÿ’ผ๐Ÿ”ง
jsx-closing-tag-locationEnforce closing tag location for multiline JSX๐Ÿ’ผ๐Ÿ”ง
jsx-curly-brace-presenceDisallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes๐Ÿ’ผ๐Ÿ”ง
jsx-curly-newlineEnforce consistent linebreaks in curly braces in JSX attributes and expressions๐Ÿ’ผ๐Ÿ”ง
jsx-curly-spacingEnforce or disallow spaces inside of curly braces in JSX attributes and expressions๐Ÿ’ผ๐Ÿ”ง
jsx-equals-spacingEnforce or disallow spaces around equal signs in JSX attributes๐Ÿ’ผ๐Ÿ”ง
jsx-first-prop-new-lineEnforce proper position of the first property in JSX๐Ÿ’ผ๐Ÿ”ง
jsx-function-call-newlineEnforce line breaks before and after JSX elements when they are used as arguments to a function.๐Ÿ’ผ๐Ÿ”ง
jsx-indentEnforce JSX indentation. Deprecated, use `indent` rule instead.๐Ÿ”ง
jsx-indent-propsEnforce props indentation in JSX๐Ÿ’ผ๐Ÿ”ง
jsx-max-props-per-lineEnforce maximum of props on a single line in JSX๐Ÿ’ผ๐Ÿ”ง
jsx-newlineRequire or prevent a new line after jsx elements and expressions.๐Ÿ”ง
jsx-one-expression-per-lineRequire one JSX element per line๐Ÿ’ผ๐Ÿ”ง
jsx-pascal-caseEnforce PascalCase for user-defined JSX components
jsx-props-no-multi-spacesDisallow multiple spaces between inline JSX props. Deprecated, use `no-multi-spaces` rule instead.๐Ÿ”ง
jsx-quotesEnforce the consistent use of either double or single quotes in JSX attributes๐Ÿ’ผ๐Ÿ”ง
jsx-self-closing-compDisallow extra closing tags for components without children๐Ÿ”ง
jsx-sort-propsEnforce props alphabetical sorting๐Ÿ”ง
jsx-tag-spacingEnforce whitespace in and around the JSX opening and closing brackets๐Ÿ’ผ๐Ÿ”ง
jsx-wrap-multilinesDisallow missing parentheses around multiline JSX๐Ÿ’ผ๐Ÿ”ง
key-spacingEnforce consistent spacing between property names and type annotations in types and interfaces๐Ÿ’ผ๐Ÿ”ง
keyword-spacingEnforce consistent spacing before and after keywords๐Ÿ’ผ๐Ÿ”ง
line-comment-positionEnforce position of line comments
linebreak-styleEnforce consistent linebreak style๐Ÿ”ง
lines-around-commentRequire empty lines around comments๐Ÿ”ง
lines-between-class-membersRequire or disallow an empty line between class members๐Ÿ’ผ๐Ÿ”ง
max-lenEnforce a maximum line length
max-statements-per-lineEnforce a maximum number of statements allowed per line๐Ÿ’ผ
member-delimiter-styleRequire a specific member delimiter style for interfaces and type literals๐Ÿ’ผ๐Ÿ”ง
multiline-comment-styleEnforce a particular style for multiline comments๐Ÿ”ง
multiline-ternaryEnforce newlines between operands of ternary expressions๐Ÿ’ผ๐Ÿ”ง
new-parensEnforce or disallow parentheses when invoking a constructor with no arguments๐Ÿ’ผ๐Ÿ”ง
newline-per-chained-callRequire a newline after each call in a method chain๐Ÿ”ง
no-confusing-arrowDisallow arrow functions where they could be confused with comparisons๐Ÿ”ง
no-extra-parensDisallow unnecessary parentheses๐Ÿ’ผ๐Ÿ”ง
no-extra-semiDisallow unnecessary semicolons๐Ÿ”ง
no-floating-decimalDisallow leading or trailing decimal points in numeric literals๐Ÿ’ผ๐Ÿ”ง
no-mixed-operatorsDisallow mixed binary operators๐Ÿ’ผ
no-mixed-spaces-and-tabsDisallow mixed spaces and tabs for indentation๐Ÿ’ผ
no-multi-spacesDisallow multiple spaces๐Ÿ’ผ๐Ÿ”ง
no-multiple-empty-linesDisallow multiple empty lines๐Ÿ’ผ๐Ÿ”ง
no-tabsDisallow all tabs๐Ÿ’ผ
no-trailing-spacesDisallow trailing whitespace at the end of lines๐Ÿ’ผ๐Ÿ”ง
no-whitespace-before-propertyDisallow whitespace before properties๐Ÿ’ผ๐Ÿ”ง
nonblock-statement-body-positionEnforce the location of single-line statements๐Ÿ”ง
object-curly-newlineEnforce consistent line breaks after opening and before closing braces๐Ÿ”ง
object-curly-spacingEnforce consistent spacing inside braces๐Ÿ’ผ๐Ÿ”ง
object-property-newlineEnforce placing object properties on separate lines๐Ÿ”ง
one-var-declaration-per-lineRequire or disallow newlines around variable declarations๐Ÿ”ง
operator-linebreakEnforce consistent linebreak style for operators๐Ÿ’ผ๐Ÿ”ง
padded-blocksRequire or disallow padding within blocks๐Ÿ’ผ๐Ÿ”ง
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๐Ÿ’ผ๐Ÿ”ง
rest-spread-spacingEnforce spacing between rest and spread operators and their expressions๐Ÿ’ผ๐Ÿ”ง
semiRequire or disallow semicolons instead of ASI๐Ÿ’ผ๐Ÿ”ง
semi-spacingEnforce consistent spacing before and after semicolons๐Ÿ’ผ๐Ÿ”ง
semi-styleEnforce location of semicolons๐Ÿ”ง
space-before-blocksEnforce consistent spacing before blocks๐Ÿ’ผ๐Ÿ”ง
space-before-function-parenEnforce consistent spacing before function parenthesis๐Ÿ’ผ๐Ÿ”ง
space-in-parensEnforce consistent spacing inside parentheses๐Ÿ’ผ๐Ÿ”ง
space-infix-opsRequire spacing around infix operators๐Ÿ’ผ๐Ÿ”ง
space-unary-opsEnforce consistent spacing before or after unary operators๐Ÿ’ผ๐Ÿ”ง
spaced-commentEnforce consistent spacing after the `//` or `/*` in a comment๐Ÿ’ผ๐Ÿ”ง
switch-colon-spacingEnforce spacing around colons of switch statements๐Ÿ”ง
template-curly-spacingRequire or disallow spacing around embedded expressions of template strings๐Ÿ’ผ๐Ÿ”ง
template-tag-spacingRequire or disallow spacing between template tags and their literals๐Ÿ’ผ๐Ÿ”ง
type-annotation-spacingRequire consistent spacing around type annotations๐Ÿ’ผ๐Ÿ”ง
type-generic-spacingEnforces consistent spacing inside TypeScript type generics๐Ÿ’ผ๐Ÿ”ง
type-named-tuple-spacingExpect space before the type declaration in the named tuple๐Ÿ’ผ๐Ÿ”ง
wrap-iifeRequire parentheses around immediate `function` invocations๐Ÿ’ผ๐Ÿ”ง
wrap-regexRequire parenthesis around regex literals๐Ÿ”ง
yield-star-spacingRequire or disallow spacing around the `*` in `yield*` expressions๐Ÿ’ผ๐Ÿ”ง
95 rules in total.

Released under the MIT License.