Skip to content

@stylistic/eslint-plugin

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

This plugin provides all rules from:

With this plugin, you no longer need to mainly disable JavaScript in favor of TypeScript. Rules work for both languages.

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
// .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
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💼🔧
dot-locationEnforce consistent newlines before and after dots💼🔧
eol-lastRequire or disallow newline at the end of files💼🔧
func-call-spacingRequire or disallow spacing between function identifiers and their invocations. Alias of `function-call-spacing`.🔧
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💼🔧
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🔧
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 keys and values in object literal properties💼🔧
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 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` definition opening 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.