Skip to content

@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
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💼🔧
jsx-quotesEnforce the consistent use of either double or single quotes in JSX attributes💼🔧
key-spacingEnforce consistent spacing between keys and values in object literal properties💼🔧
keyword-spacingEnforce consistent spacing before and after keywords💼🔧
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💼
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💼🔧
wrap-iifeRequire parentheses around immediate `function` invocations💼🔧
wrap-regexRequire parenthesis around regex literals🔧
yield-star-spacingRequire or disallow spacing around the `*` in `yield*` expressions💼🔧
68 rules in total.

Released under the MIT License.