Skip to main content
Version: 2.0

REGARDS ESLint rules

Presentation

The module @regardsoss/eslint-config-es6-rules (webapp/eslint-config-es6-rules/) provides REGARDS' ESLint configuration. It is referenced by root webapp/.eslintrc file, which is the root ESLint configuration file for REGARDS front-end project.

Usage

We export here under ESLint configurations for your usage.

rules packageimport modecomment
eslintrecommendedStandard Javascript rules provided by eslint
eslint-config-airbnballAdditional standard and ES6 Javascript rules
eslint-plugin-importallPrevent issues with misspelling of file paths and import names
eslint-plugin-jsx-allyallStatic AST checker for accessibility rules on JSX elements
eslint-plugin-lodashrecommendedSpecific rules for lodash library
eslint-plugin-mochaallESLint rules for mocha
eslint-plugin-promiserecommendedEnforce best practices for JavaScript promises
eslint-plugin-reactrecommendedSpecific rules for react library
eslint-plugin-react-perfrecommendedSpecific good practices rules for react library

To use our configuration package add the code here under to your .eslintrc configuration file

{
"parser": "babel-eslint",
"extends": [
"@regardsoss/eslint-config-es6-rules"
]
}

You need to add the following dependencies to your package.json :

{
"eslint": "~8.57.0",
"eslint-config-airbnb": "~19.0.4",
"eslint-plugin-import": "~2.29.1",
"eslint-plugin-jsx-a11y": "~6.8.0",
"eslint-plugin-lodash": "~7.4.0",
"eslint-plugin-mocha": "~10.3.0",
"eslint-plugin-promise": "~6.1.1",
"eslint-plugin-react": "~7.34.0",
"eslint-plugin-react-perf": "~3.3.2",
}

Imported rules

In the next sections you can find for each rules package the custom configuration made for REGARDS project. By default, all rules are imported without modification from each package the references rules here are disabled or modified.

eslint rules

To see all javascript rules set by eslint : http://eslint.org/docs/rules/

Special configuration for eslint rules :

ruleConfigurationcomment
func-namesDisabledAllow anonymous functions
global-requireDisabled
camelcaseActivated
max-lenDisabled
no-consoleDisabled
spaced-commentDisabled
no-unused-varsActivatedDo not check arguments. Ignore unused variable on functions arguments
no-confusing-arrowDisabled
no-warning-commentsActivatedRaise a warning if a TODO or FIXME is find in comments
no-mixed-operatorsActivated
prefer-destructuringActivated
function-paren-newlineDisabled
jsx-a11y/control-has-associated-labelDisabledAllow that a control (an unteractive element) has no text label
function-call-argument-newline'DisabledAllow to line break whenever we want
operator-linebreakDisabledAllow to place operator (like ternary operator) wherever we want
default-param-lastDisabledAllow to set default param at any place we want in method parameter list
no-promise-executor-returnDisabledAllow returning values from promise executor functions
react/no-unstable-nested-componentsDisabledAllow to create components during render
react/function-component-definitionDisableddon't enforce consistent function types for function components
prefer-regex-literalsDisabledAllow the use of RegExp constructor
no-use-before-defineDisabledAllow usage of static attributes inside the class
react/no-unused-class-component-methodsActivated
semiActivatedDisallows semicolons as the end of statements (except to disambiguate statements beginning with [, (, /, +, or -)
import/namedDisabled
import/no-commonjsActivated
import/no-self-importActivated
import/no-cycleActivated
react/state-in-constructorActivated
react/static-property-placementActivated
react/jsx-props-no-spreadingDisabled
react/jsx-indentDisabled
react/jsx-no-target-blank'Disabled
react-perf/jsx-no-new-function-as-propDisabled
react-perf/jsx-no-new-object-as-propDisabled
react-perf/jsx-no-new-array-as-propDisabled
jsx-a11y/anchor-is-validDisabled
jsx-a11y/no-noninteractive-element-interactionsDisabled
jsx-a11y/mouse-events-have-key-eventsDisabled
jsx-a11y/click-events-have-key-eventsDisabled
jsx-a11y/no-static-element-interactionsDisabled
jsx-a11y/label-has-forDisabled

eslint-config-airbnb

To see all javascript rules set by eslint-config-airbnb : https://github.com/airbnb/javascript

Special configuration for eslint-config-airbnb rules :

ruleConfigurationcomment
import/no-extraneous-dependenciesDisabled
import/no-named-as-defaultDisabled
import/no-named-as-default-memberDisabled
import/prefer-default-exportDisabled

plugin:react

To see all javascript rules set by plugin:react : https://github.com/yannickcr/eslint-plugin-react

Special configuration for plugin:react rules :

ruleConfigurationcomment
prefer-es6-classDisabled
require-extensionDisabled
require-default-propsDisabled
prefer-stateless-functionDisabled
react/display-nameDisabledOnly detect sipaly names of components during debug
jsx-uses-reactActivated
jsx-uses-varsActivated
react-in-jsx-scopeActivated
jsx-no-undefActivated
destructuring-assignmentDisabled
jsx-wrap-multilinesDisabled
no-access-state-in-setstateDisabled
jsx-closing-tag-locationDisabled

plugin:react-perf

To see all javascript rules set by plugin:react-perf : https://github.com/cvazac/eslint-plugin-react-perf

Special configuration for plugin:react-perf rules : None

plugin:lodash

To see all javascript rules set by plugin:lodash : https://github.com/wix/eslint-plugin-lodash

Special configuration for plugin:lodash rules :

ruleConfigurationcomment
import-scopeActivatedFor single method imports
prefer-noopDisabledDisable useless rule (_.noop instead of empty annonnymous function)
prefer-lodash-methodDisabledThis rule is not satisfying
prefer-constantDisabledWe do not use lodash constants factory
prop-shorthandDisabledNot so readable
matches-prop-shorthandDisabledWe prefer the explicit declaration
no-exclusive-testsActivated
max-top-level-suitesActivated
handle-done-callbackActivated
no-top-level-hooksActivated
no-return-and-callbackActivated
no-sibling-hooksActivated
no-global-testsActivated
no-hooks-for-single-caseDisabledAll React tests contains before and after whether having 1 or more tests
no-mocha-arrowsDisabled
mocha/no-skipped-testsActivated
mocha/no-identical-titleActivated
mocha/no-synchronous-testsDisabledWe wrote sync tests

plugin:promise

To see all javascript rules set by plugin:promise : https://github.com/xjamundx/eslint-plugin-promise

Special configuration for plugin:promise rules :

ruleConfigurationcomment
no-callback-in-promiseDisabledWe call done from Mocha inside async tests
no-nestingDisabledRule is not adequate without async / await
avoid-newDisabledThis is handy to create custom promises!
catch-or-returnDisabledWe do not always return a promise on react component since most of the time nobody consumes them
always-returnDisabled