Linting

This documentation details the configuration of eslint.

Configuration

Recommended rules (if not ignored) appear as error.

Rule Fixable Level Parameters Comment
Custom rules
no-empty-module -
no-substr error
Possible Errors
for-direction error
getter-return error
no-async-promise-executor -
no-await-in-loop -
no-compare-neg-zero error
no-cond-assign error
no-console ignore The library offers a compatibility layer that includes console.log, console.warn and console.error.
no-constant-condition error
no-control-regex error
no-debugger error
no-dupe-args error
no-dupe-keys error
no-duplicate-case error
no-empty error
no-empty-character-class error
no-ex-assign error
no-extra-boolean-cast error
no-extra-parens error
no-extra-semi error
no-func-assign error
no-inner-declarations error
no-invalid-regexp error
no-irregular-whitespace error
no-misleading-character-class -
no-negated-in-lhs -
no-obj-calls error
no-prototype-builtins -
no-regex-spaces error
no-sparse-arrays error
no-template-curly-in-string -
no-unexpected-multiline error
no-unreachable error
no-unsafe-finally error
no-unsafe-negation error
require-atomic-updates -
use-isnan error
valid-jsdoc error .eslintrc Rule parameters are used to normalize the jsdoc tags. Also, The rule was also customized to match @gpf tags.
valid-typeof error
Best Practices
accessor-pairs error
array-callback-return -
block-scoped-var error This limits misuse of hoisting that leads to obscure code.
class-methods-use-this -
complexity error 6
consistent-return - The API extensively uses the undefined value to represent no value. Since a method with no return statement returns undefined, many functions are not consistent.
curly error "all"
default-case error
dot-location error "property"
dot-notation error .eslintrc
eqeqeq error
guard-for-in error
max-classes-per-file -
no-alert error
no-caller error
no-case-declarations error
no-div-regex error
no-else-return error
no-empty-function -
no-empty-pattern error
no-eq-null error
no-eval error
no-extend-native - Since the library implements polyfills to provide a compatibility layer, this rule is turned off. However, the general rule is to not extend native classes with non standard methods.
no-extra-bind error
no-extra-label -
no-fallthrough error
no-floating-decimal error
no-global-assign error
no-implicit-coercion error
no-implicit-globals -
no-implied-eval error
no-invalid-this error
no-iterator error
no-labels error Really?
no-lone-blocks error
no-loop-func error
no-magic-numbers error Disabled for test files.
no-multi-spaces error
no-multi-str error
no-native-reassign -
no-new error
no-new-func error
no-new-wrappers error
no-octal error
no-octal-escape error
no-param-reassign error
no-proto error
no-redeclare error
no-restricted-properties -
no-return-assign error
no-return-await -
no-script-url error
no-self-assign error
no-self-compare error
no-sequences error
no-throw-literal error
no-unmodified-loop-condition -
no-unused-expressions error
no-unused-labels error
no-useless-call error
no-useless-catch -
no-useless-concat error
no-useless-escape error
no-useless-return -
no-void error
no-warning-comments -
no-with error Extracted from the MDN description: Use of the with statement is not recommended, as it may be the source of confusing bugs and compatibility issues.
prefer-promise-reject-errors -
radix error
require-await -
require-unicode-regexp -
vars-on-top - Unless you don't understand hoisting, it is useless to put all vars on top.
wrap-iife error "outside"
yoda error Do or do not, there is no try.
Strict Mode
strict error "global" Required for all GPF-JS modules.
Variables
init-declarations - As GPF-JS uses undefined, variables are not necessarily initialized with a value.
no-catch-shadow -
no-delete-var error
no-label-var error
no-restricted-globals -
no-shadow error
no-shadow-restricted-names error
no-undef error
no-undef-init error
no-undefined - undefined is a value.
no-unused-vars error .eslintrc
no-use-before-define error .eslintrc
Node.js and CommonJS
callback-return -
global-require -
handle-callback-err error
no-buffer-constructor -
no-mixed-requires -
no-new-require error
no-path-concat - GPF-JS handles path separator the proper way
no-process-env error
no-process-exit -
no-restricted-modules -
no-sync error
Stylistic Issues
array-bracket-newline -
array-bracket-spacing error "never"
array-element-newline -
block-spacing error "never"
brace-style error "1tbs"
camelcase error
capitalized-comments -
comma-dangle error "never"
comma-spacing error .eslintrc
comma-style error "last"
computed-property-spacing -
consistent-this error "me"
eol-last error
func-call-spacing error "never"
func-name-matching -
func-names -
func-style error "declaration" Enforced on purpose.
function-paren-newline -
id-blacklist -
id-length -
id-match - A special rule will be developed to validate the IDs. From a general point of view, lowerCamelCase is preferred. Constants must be uppercase with _ to separate words. Finally, 'global' variables must start with _GPF or _gpf, they usually start with the module name (ex: _GpfStreamCsvParser)
implicit-arrow-linebreak -
indent error 4
indent-legacy -
jsx-quotes -
key-spacing error .eslintrc
keyword-spacing error .eslintrc
line-comment-position -
linebreak-style warning "unix"
lines-around-comment -
lines-around-directive -
lines-between-class-members -
max-depth error 4
max-len error 120
max-lines -
max-lines-per-function -
max-nested-callbacks error 2
max-params error 3
max-statements error 15
max-statements-per-line -
multiline-comment-style -
multiline-ternary -
new-cap error
new-parens error
newline-after-var -
newline-before-return -
newline-per-chained-call -
no-array-constructor error
no-bitwise -
no-continue -
no-inline-comments -
no-lonely-if error
no-mixed-operators -
no-mixed-spaces-and-tabs error
no-multi-assign -
no-multiple-empty-lines error
no-negated-condition error
no-nested-ternary error
no-new-object error
no-plusplus -
no-restricted-syntax error .eslintrc Forbids the use of switch and with
no-spaced-func -
no-tabs -
no-ternary error
no-trailing-spaces error
no-underscore-dangle -
no-unneeded-ternary error
no-whitespace-before-property -
nonblock-statement-body-position -
object-curly-newline -
object-curly-spacing error "never"
object-property-newline -
one-var - Following clean code principles, variables are declared close to their related functions.
one-var-declaration-per-line -
operator-assignment error "always"
operator-linebreak error "before"
padded-blocks -
padding-line-between-statements -
prefer-object-spread -
quote-props warning .eslintrc
quotes error "double"
require-jsdoc -
semi error "always"
semi-spacing error .eslintrc
semi-style -
sort-keys -
sort-vars -
space-before-blocks error .eslintrc
space-before-function-paren error "always"
space-in-parens error "never"
space-infix-ops error .eslintrc
space-unary-ops error
spaced-comment -
switch-colon-spacing -
template-tag-spacing -
unicode-bom -
wrap-regex error
ECMAScript 6
arrow-body-style -
arrow-parens -
arrow-spacing -
constructor-super error
generator-star-spacing -
no-class-assign error
no-confusing-arrow -
no-const-assign error
no-dupe-class-members error
no-duplicate-imports -
no-new-symbol error
no-restricted-imports -
no-this-before-super error
no-useless-computed-key -
no-useless-constructor -
no-useless-rename -
no-var -
object-shorthand -
prefer-arrow-callback -
prefer-const -
prefer-destructuring -
prefer-numeric-literals -
prefer-reflect -
prefer-rest-params -
prefer-spread -
prefer-template -
require-yield error
rest-spread-spacing -
sort-imports -
symbol-description -
template-curly-spacing -
yield-star-spacing -

Use grunt eslint to apply linter.