eslint-config-jhh
Version:
JHH ESLint config
221 lines (159 loc) • 7.13 kB
JavaScript
/**
* These rules relate to better ways of doing things to help you avoid problems
*
* @see http://eslint.org/docs/rules/#best-practices
*/
module.exports = {
rules: {
// enforce getter and setter pairs in objects
'accessor-pairs': 'off',
// enforce return statements in callbacks of array methods
'array-callback-return': 'error',
// enforce the use of variables within the scope they are defined
'block-scoped-var': 'error',
// enforce that class methods utilize this
// Setting to warning to be have similar to IDEs such as Pycharm. This
// way the user will be alerted that they can make the method static
// and ignore the warning if they wish.
'class-methods-use-this': ['warn', {
exceptMethods: []
}],
// require return statements to either always or never specify values
'consistent-return': 'error',
// enforce consistent brace style for all control statements
curly: ['error', 'multi-line'],
// require default cases in switch statements
// If you are skipping the default case intentionally you can avoid an
// error by adding `// no default` at the end of the statement.
'default-case': ['error', { commentPattern: '^no default$' }],
// enforce consistent newlines before and after dots
// Requires dot in a member expression should be on the same line as the
// property portion.
'dot-location': ['error', 'property'],
// enforce dot notation whenever possible
'dot-notation': ['error', { allowKeywords: true }],
// require the use of === and !==
eqeqeq: ['error', 'always', { null: 'ignore' }],
// require for-in loops to include an if statement
'guard-for-in': 'error',
// disallow the use of alert, confirm, and prompt
'no-alert': 'warn',
// disallow use of arguments.caller or arguments.callee
'no-caller': 'error',
// disallow lexical declarations in case clauses
'no-case-declarations': 'error',
// disallow else blocks after return statements in if statements
'no-else-return': 'error',
// disallow empty functions
'no-empty-function': ['error'],
// disallow empty destructuring patterns
'no-empty-pattern': 'error',
// disallow use of eval()
// Die in a raging fire.
'no-eval': 'error',
// disallow extending native types
// Hands off the natives pervert.
'no-extend-native': 'error',
// disallow unnecessary calls to .bind()
'no-extra-bind': 'error',
// disallow unnecessary labels
'no-extra-label': 'error',
// disallow fallthrough of case statements
'no-fallthrough': 'error',
// disallow leading or trailing decimal points in numeric literals
'no-floating-decimal': 'error',
// disallow assignments to native objects or read-only global variables
'no-global-assign': 'error',
// disallow shorthand type conversions
'no-implicit-coercion': ['off', {
boolean: false, // !!foo is ok
number: true, // +foo is not ok
string: true // '' + foo is not ok
}],
// disallow variable and function declarations in the global scope
'no-implicit-globals': 'error',
// disallow the use of eval()-like methods
'no-implied-eval': 'error',
// disallow the use of the __iterator__ propert
'no-iterator': 'error',
// disallow labeled statements
// I've never seen anyone here use a labeled statement so let's just
// avoid that whole can of worms and forbid them.
'no-labels': 'error',
// disallow unnecessary nested blocks
'no-lone-blocks': 'error',
// disallow function declarations and expressions inside loop statements
'no-loop-func': 'error',
// disallow multiple spaces
'no-multi-spaces': 'error',
// disallow multiline strings
'no-multi-str': 'error',
// disallow new operators with the Function object
'no-new-func': 'error',
// disallow new operators with the String, Number, and Boolean objects
'no-new-wrappers': 'error',
// disallow octal escape sequences in string literals
'no-octal-escape': 'error',
// disallow octal literals
'no-octal': 'error',
// disallow octal escape sequences in string literals
'no-octal-escape': 'error',
// disallow reassigning function parameters
'no-param-reassign': ['error', {
props: true // making allowance for React component props
}],
// disallow the use of the __proto__ property
// WHAT YEAR IS THIS?!
'no-proto': 'error',
// disallow variable redeclaration
'no-redeclare': 'error',
// disallow assignment operators in return statements
'no-return-assign': 'error',
// disallow unnecessary return await
'no-return-await': 'error',
// disallow javascript: urls
'no-script-url': 'error',
// disallow assignments where both sides are exactly the same
'no-self-assign': 'error',
// disallow comparisons where both sides are exactly the same
'no-self-compare': 'error',
// disallow comma operators
'no-sequences': 'error',
// disallow throwing literals as exceptions
'no-throw-literal': 'error',
// disallow unused expressions
'no-unused-expressions': ['error', {
allowShortCircuit: true, // a && b()
allowTernary: true // a ? b() : c()
}],
// disallow unused labels
'no-unused-labels': 'error',
// disallow unnecessary calls to .call() and .apply()
'no-useless-call': 'error',
// disallow unnecessary concatenation of literals or template literals
'no-useless-concat': 'error',
// disallow unnecessary escape characters
'no-useless-escape': 'error',
'no-useless-return': 'error',
// disallow void operators
'no-void': 'error',
// disallow specified warning terms in comments
// Warn if it spots a `todo` or `fixme` to remind you to actually do it
'no-warning-comments': ['warn', {
terms: ['todo', '@todo', 'fixme', '@fixme'],
location: 'start'
}],
// disallow with statements
'no-with': 'error',
// enforce the consistent use of the radix argument when using
// parseInt()
radix: 'error',
// require var declarations be placed at the top of their containing
// scope
'vars-on-top': 'error',
// require parentheses around immediate function invocations
'wrap-iife': ['error', 'outside'],
// require or disallow “Yoda” conditions
yoda: 'error'
}
}