ESLint Shareable Config For React App
Install peerDependencies.
# npm
npm install eslint eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react --save-dev
# yarn
yarn add eslint eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react --dev
Install This Config
# npm
npm install eslint-config-hyperchain --save-dev
# yarn
yarn add eslint-config-hyperchain --dev
Configure the following content in .eslintrc.js
"extends": [
"hyperchain"
]
rule | description |
---|---|
no-compare-neg-zero | disallow comparing against -0 |
no-cond-assign | disallow assignment operators in conditional expressions |
no-constant-condition | disallow constant expressions in conditions |
no-control-regex | disallow control characters in regular expressions |
no-debugger | disallow the use of debugger |
no-dupe-args | disallow duplicate arguments in function definitions |
no-dupe-keys | disallow duplicate keys in object literals |
no-duplicate-case | disallow duplicate case labels |
no-empty-character-class | disallow empty character classes in regular expressions |
no-ex-assign | disallow reassigning exceptions in catch clauses |
no-extra-boolean-cast | disallow unnecessary boolean casts |
no-extra-parens | disallow unnecessary parentheses |
no-func-assign | disallow reassigning function declarations |
no-inner-declarations | disallow variable or function declarations in nested blocks |
no-invalid-regexp | disallow invalid regular expression strings in RegExp constructors |
no-irregular-whitespace | disallow irregular whitespace outside of strings and comments |
no-obj-calls | disallow calling global object properties as functions |
no-regex-spaces | disallow multiple spaces in regular expressions |
no-sparse-arrays | disallow sparse arrays |
no-template-curly-in-string | disallow template literal placeholder syntax in regular strings |
no-unexpected-multiline | disallow confusing multiline expressions |
no-unreachable | disallow unreachable code after return, throw, continue, and break statements |
no-unsafe-finally | disallow control flow statements in finally blocks |
no-unsafe-negation | disallow negating the left operand of relational operators |
use-isnan | require calls to isNaN() when checking for NaN |
valid-typeof | enforce comparing typeof expressions against valid strings |
rule | description |
---|---|
accessor-pairs | enforce getter and setter pairs in objects |
curly | enforce consistent brace style for all control statements |
dot-location | enforce consistent newlines before and after dots |
eqeqeq | require the use of === and !== |
no-caller | disallow the use of arguments.caller or arguments.callee |
no-empty-pattern | disallow empty destructuring patterns |
no-eval | disallow the use of eval() |
no-extend-native | disallow extending native types |
no-extra-bind | disallow unnecessary calls to .bind() |
no-fallthrough | disallow fallthrough of case statements |
no-floating-decimal | disallow leading or trailing decimal points in numeric literals |
no-global-assign | disallow assignments to native objects or read-only global variables |
no-implied-eval | disallow the use of eval()-like methods |
no-iterator | disallow the use of the iterator property |
no-labels | disallow labeled statements |
no-lone-blocks | disallow unnecessary nested blocks |
no-multi-spaces | disallow multiple spaces |
no-multi-str | disallow multiline strings |
no-new | disallow new operators outside of assignments or comparisons |
no-new-func | disallow new operators with the Function object |
no-new-wrappers | disallow new operators with the String, Number, and Boolean objects |
no-octal | disallow octal literals |
no-octal-escape | disallow octal escape sequences in string literals |
no-proto | disallow the use of the proto property |
no-redeclare | disallow variable redeclaration |
no-return-assign | disallow assignment operators in return statements |
no-return-await | disallow unnecessary return await |
no-self-assign | disallow assignments where both sides are exactly the same |
no-self-compare | disallow comparisons where both sides are exactly the same |
no-sequences | disallow comma operators |
no-throw-literal | disallow throwing literals as exceptions |
no-unmodified-loop-condition | disallow unmodified loop conditions |
no-unused-expressions | disallow unused expressions |
no-useless-call | disallow unnecessary calls to .call() and .apply() |
no-useless-escape | disallow unnecessary escape characters |
no-useless-return | disallow redundant return statements |
no-with | disallow with statements |
prefer-promise-reject-errors | require using Error objects as Promise rejection reasons |
wrap-iife | require parentheses around immediate function invocations |
yoda | require or disallow “Yoda” conditions |
rule | description |
---|---|
no-delete-var | disallow deleting variables |
no-label-var | disallow labels that share a name with a variable |
no-shadow-restricted-names | disallow identifiers from shadowing restricted names |
no-undef | disallow the use of undeclared variables unless mentioned in /*global */ comments |
no-undef-init | disallow initializing variables to undefined |
no-unused-vars | disallow unused variables |
no-use-before-define | disallow the use of variables before they are defined |
rule | description |
---|---|
handle-callback-err | require error handling in callbacks |
no-new-require | disallow new operators with calls to require |
no-path-concat | disallow string concatenation with __dirname and __filename |
rule | description |
---|---|
block-spacing | disallow or enforce spaces inside of blocks after opening block and before closing block |
brace-style | enforce consistent brace style for blocks |
camelcase | enforce camelcase naming convention |
comma-dangle | require or disallow trailing commas |
comma-spacing | enforce consistent spacing before and after commas |
comma-style | enforce consistent comma style |
eol-last | require or disallow newline at the end of files |
func-call-spacing | require or disallow spacing between function identifiers and their invocations |
indent | enforce consistent indentation |
key-spacing | enforce consistent spacing between keys and values in object literal properties |
keyword-spacing | enforce consistent spacing before and after keywords |
new-cap | require constructor names to begin with a capital letter |
new-parens | require parentheses when invoking a constructor with no arguments |
no-array-constructor | disallow Array constructors |
no-mixed-operators | disallow mixed binary operators |
no-mixed-spaces-and-tabs | disallow mixed spaces and tabs for indentation |
no-multiple-empty-lines | disallow multiple empty lines |
no-new-object | disallow Object constructors |
no-tabs | disallow all tabs |
no-trailing-spaces | disallow trailing whitespace at the end of lines |
no-unneeded-ternary | disallow ternary operators when simpler alternatives exist |
no-whitespace-before-property | disallow whitespace before properties |
object-curly-spacing | enforce consistent spacing inside braces |
object-property-newline | enforce placing object properties on separate lines |
one-var | enforce variables to be declared either together or separately in functions |
operator-linebreak | enforce consistent linebreak style for operators |
padded-blocks | require or disallow padding within blocks |
quotes | enforce the consistent use of either backticks, double, or single quotes |
semi | require or disallow semicolons instead of ASI |
semi-spacing | enforce consistent spacing before and after 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 |
template-tag-spacing | require or disallow spacing between template tags and their literals |
unicode-bom | require or disallow Unicode byte order mark (BOM) |
rule | description |
---|---|
arrow-spacing | enforce consistent spacing before and after the arrow in arrow functions |
constructor-super | require super() calls in constructors |
generator-star-spacing | enforce consistent spacing around * operators in generator functions |
no-class-assign | disallow reassigning class members |
no-const-assign | disallow reassigning const variables |
no-dupe-class-members | disallow duplicate class members |
no-new-symbol | disallow new operators with the Symbol object |
no-this-before-super | disallow this/super before calling super() in constructors |
no-useless-computed-key | disallow unnecessary computed property keys in object literals |
no-useless-constructor | disallow unnecessary constructors |
no-useless-rename | disallow renaming import, export, and destructured assignments to the same name |
rest-spread-spacing | enforce spacing between rest and spread operators and their expressions |
symbol-description | require symbol descriptions |
template-curly-spacing | require or disallow spacing around embedded expressions of template strings |
yield-star-spacing | require or disallow spacing around the * in yield* expressions |
eslint-congfig-hyperchain is licensed under the MIT License.