@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. Rule | Description | |||
array-bracket-newline | Enforce linebreaks after opening and before closing array brackets | ๐ง | ||
array-bracket-spacing | Enforce consistent spacing inside array brackets | ๐ผ | ๐ง | |
array-element-newline | Enforce line breaks after each array element | ๐ง | ||
arrow-parens | Require parentheses around arrow function arguments | ๐ผ | ๐ง | |
arrow-spacing | Enforce consistent spacing before and after the arrow in arrow functions | ๐ผ | ๐ง | |
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 | ๐ผ | ๐ง | |
comma-style | Enforce consistent comma style | ๐ผ | ๐ง | |
computed-property-spacing | Enforce consistent spacing inside computed property brackets | ๐ผ | ๐ง | |
curly-newline | Enforce consistent line breaks after opening and before closing braces | ๐ง | ||
dot-location | Enforce consistent newlines before and after dots | ๐ผ | ๐ง | |
eol-last | Require or disallow newline at the end of files | ๐ผ | ๐ง | |
function-call-argument-newline | Enforce line breaks between arguments of a function call | ๐ง | ||
function-call-spacing | Require or disallow spacing between function identifiers and their invocations | ๐ง | ||
function-paren-newline | Enforce consistent line breaks inside function parentheses | ๐ง | ||
generator-star-spacing | Enforce consistent spacing around `*` operators in generator functions | ๐ผ | ๐ง | |
implicit-arrow-linebreak | Enforce the location of arrow function bodies | ๐ง | ||
indent | Enforce consistent indentation | ๐ผ | ๐ง | |
indent-binary-ops | Indentation for binary operators | ๐ผ | ๐ง | |
jsx-child-element-spacing | Enforce or disallow spaces inside of curly braces in JSX attributes and expressions | |||
jsx-closing-bracket-location | Enforce closing bracket location in JSX | ๐ผ | ๐ง | |
jsx-closing-tag-location | Enforce closing tag location for multiline JSX | ๐ผ | ๐ง | |
jsx-curly-brace-presence | Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes | ๐ผ | ๐ง | |
jsx-curly-newline | Enforce consistent linebreaks in curly braces in JSX attributes and expressions | ๐ผ | ๐ง | |
jsx-curly-spacing | Enforce or disallow spaces inside of curly braces in JSX attributes and expressions | ๐ผ | ๐ง | |
jsx-equals-spacing | Enforce or disallow spaces around equal signs in JSX attributes | ๐ผ | ๐ง | |
jsx-first-prop-new-line | Enforce proper position of the first property in JSX | ๐ผ | ๐ง | |
jsx-function-call-newline | Enforce line breaks before and after JSX elements when they are used as arguments to a function. | ๐ผ | ๐ง | |
jsx-indent | Enforce JSX indentation. Deprecated, use `indent` rule instead. | ๐ง | ||
jsx-indent-props | Enforce props indentation in JSX | ๐ผ | ๐ง | |
jsx-max-props-per-line | Enforce maximum of props on a single line in JSX | ๐ผ | ๐ง | |
jsx-newline | Require or prevent a new line after jsx elements and expressions. | ๐ง | ||
jsx-one-expression-per-line | Require one JSX element per line | ๐ผ | ๐ง | |
jsx-pascal-case | Enforce PascalCase for user-defined JSX components | |||
jsx-props-no-multi-spaces | Disallow multiple spaces between inline JSX props. Deprecated, use `no-multi-spaces` rule instead. | ๐ง | ||
jsx-quotes | Enforce the consistent use of either double or single quotes in JSX attributes | ๐ผ | ๐ง | |
jsx-self-closing-comp | Disallow extra closing tags for components without children | ๐ง | ||
jsx-sort-props | Enforce props alphabetical sorting | ๐ง | ||
jsx-tag-spacing | Enforce whitespace in and around the JSX opening and closing brackets | ๐ผ | ๐ง | |
jsx-wrap-multilines | Disallow missing parentheses around multiline JSX | ๐ผ | ๐ง | |
key-spacing | Enforce consistent spacing between property names and type annotations in types and interfaces | ๐ผ | ๐ง | |
keyword-spacing | Enforce consistent spacing before and after keywords | ๐ผ | ๐ง | |
line-comment-position | Enforce position of line comments | |||
linebreak-style | Enforce consistent linebreak style | ๐ง | ||
lines-around-comment | Require empty lines around comments | ๐ง | ||
lines-between-class-members | Require or disallow an empty line between class members | ๐ผ | ๐ง | |
max-len | Enforce a maximum line length | |||
max-statements-per-line | Enforce a maximum number of statements allowed per line | ๐ผ | ||
member-delimiter-style | Require a specific member delimiter style for interfaces and type literals | ๐ผ | ๐ง | |
multiline-comment-style | Enforce a particular style for multiline comments | ๐ง | ||
multiline-ternary | Enforce newlines between operands of ternary expressions | ๐ผ | ๐ง | |
new-parens | Enforce or disallow parentheses when invoking a constructor with no arguments | ๐ผ | ๐ง | |
newline-per-chained-call | Require a newline after each call in a method chain | ๐ง | ||
no-confusing-arrow | Disallow arrow functions where they could be confused with comparisons | ๐ง | ||
no-extra-parens | Disallow unnecessary parentheses | ๐ผ | ๐ง | |
no-extra-semi | Disallow unnecessary semicolons | ๐ง | ||
no-floating-decimal | Disallow leading or trailing decimal points in numeric literals | ๐ผ | ๐ง | |
no-mixed-operators | Disallow mixed binary operators | ๐ผ | ||
no-mixed-spaces-and-tabs | Disallow mixed spaces and tabs for indentation | ๐ผ | ||
no-multi-spaces | Disallow multiple spaces | ๐ผ | ๐ง | |
no-multiple-empty-lines | Disallow multiple empty lines | ๐ผ | ๐ง | |
no-tabs | Disallow all tabs | ๐ผ | ||
no-trailing-spaces | Disallow trailing whitespace at the end of lines | ๐ผ | ๐ง | |
no-whitespace-before-property | Disallow whitespace before properties | ๐ผ | ๐ง | |
nonblock-statement-body-position | Enforce the location of single-line statements | ๐ง | ||
object-curly-newline | Enforce consistent line breaks after opening and before closing braces | ๐ง | ||
object-curly-spacing | Enforce consistent spacing inside braces | ๐ผ | ๐ง | |
object-property-newline | Enforce placing object properties on separate lines | ๐ง | ||
one-var-declaration-per-line | Require or disallow newlines around variable declarations | ๐ง | ||
operator-linebreak | Enforce consistent linebreak style for operators | ๐ผ | ๐ง | |
padded-blocks | Require or disallow padding within blocks | ๐ผ | ๐ง | |
padding-line-between-statements | Require or disallow padding lines between statements | ๐ง | ||
quote-props | Require quotes around object literal, type literal, interfaces and enums property names | ๐ผ | ๐ง | |
quotes | Enforce the consistent use of either backticks, double, or single quotes | ๐ผ | ๐ง | |
rest-spread-spacing | Enforce spacing between rest and spread operators and their expressions | ๐ผ | ๐ง | |
semi | Require or disallow semicolons instead of ASI | ๐ผ | ๐ง | |
semi-spacing | Enforce consistent spacing before and after semicolons | ๐ผ | ๐ง | |
semi-style | Enforce location of semicolons | ๐ง | ||
space-before-blocks | Enforce consistent spacing before blocks | ๐ผ | ๐ง | |
space-before-function-paren | Enforce consistent spacing before function parenthesis | ๐ผ | ๐ง | |
space-in-parens | Enforce consistent spacing inside parentheses | ๐ผ | ๐ง | |
space-infix-ops | Require spacing around infix operators | ๐ผ | ๐ง | |
space-unary-ops | Enforce consistent spacing before or after unary operators | ๐ผ | ๐ง | |
spaced-comment | Enforce consistent spacing after the `//` or `/*` in a comment | ๐ผ | ๐ง | |
switch-colon-spacing | Enforce spacing around colons of switch statements | ๐ง | ||
template-curly-spacing | Require or disallow spacing around embedded expressions of template strings | ๐ผ | ๐ง | |
template-tag-spacing | Require or disallow spacing between template tags and their literals | ๐ผ | ๐ง | |
type-annotation-spacing | Require consistent spacing around type annotations | ๐ผ | ๐ง | |
type-generic-spacing | Enforces consistent spacing inside TypeScript type generics | ๐ผ | ๐ง | |
type-named-tuple-spacing | Expect space before the type declaration in the named tuple | ๐ผ | ๐ง | |
wrap-iife | Require parentheses around immediate `function` invocations | ๐ผ | ๐ง | |
wrap-regex | Require parenthesis around regex literals | ๐ง | ||
yield-star-spacing | Require or disallow spacing around the `*` in `yield*` expressions | ๐ผ | ๐ง |
95 rules in total.