@stylistic/eslint-plugin-js
JavaScript stylistic rules for ESLint, migrated from eslint core.
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-js
Add @stylistic/js
to your plugins list, and prefix stylistic rules with @stylistic/js
:
js
// eslint.config.js
import stylisticJs from '@stylistic/eslint-plugin-js'
export default [
{
plugins: {
'@stylistic/js': stylisticJs
},
rules: {
'indent': ['error', 2],
'@stylistic/js/indent': ['error', 2],
// ...
}
}
]
js
// .eslintrc.js
module.exports = {
plugins: [
'@stylistic/js'
],
rules: {
'indent': ['error', 2],
'@stylistic/js/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 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 | 💼 | 🔧 |
dot-location | Enforce consistent newlines before and after dots | 💼 | 🔧 |
eol-last | Require or disallow newline at the end of files | 💼 | 🔧 |
func-call-spacing | Require or disallow spacing between function identifiers and their invocations | 🔧 | |
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 | 💼 | 🔧 |
jsx-quotes | Enforce the consistent use of either double or single quotes in JSX attributes | 💼 | 🔧 |
key-spacing | Enforce consistent spacing between keys and values in object literal properties | 💼 | 🔧 |
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 | 💼 | |
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 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` definition opening 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 | 💼 | 🔧 |
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 | 💼 | 🔧 |
70 rules in total.