.eslintrc
{
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
//Stylistic Issues
"brace-style": [2, "1tbs", {
"allowSingleLine": true
}],
"camelcase": 2,
"consistent-this": [2, "self"],
"eol-last": 2, //- enforce newline at the end of file, with no multiple empty lines
//"func-style": [2, "declaration", { "allowArrowFunctions": true }], //- use var to declare functions to prevent errors related hoisting (functions used before declared
"func-names": 1, //- require function expressions to have a name (warning only to allow developer choice)
"new-cap": 2, //- require a capital letter for constructors
"new-parens": 2, //- disallow the omission of parentheses when invoking a constructor with no arguments
"no-array-constructor": 2, //- disallow use of the Array constructor
"no-lonely-if": 2, //- disallow if as the only statement in an else block (off by default)
"no-new-object": 2, //- clearer to use {} rather than new Object()
"no-spaced-func": 2, //- disallow space between function identifier and application
"semi-spacing": [2, {"before": false, "after": true}], //-disallow space before semicolon
"no-nested-ternary": 2, //- disallow nested ternary expressions (off by default)
"no-ternary": 0, //- disallow the use of ternary operators (off by default)
"no-trailing-spaces": 1, //- disallow trailing whitespace at the end of lines
"no-underscore-dangle": 0, //- disallow dangling underscores in identifiers
"no-extra-parens": [2, "all"], //- disallow wrapping of non-IIFE statements in parens
"no-mixed-spaces-and-tabs": [2, true], //- disallow mixed spaces and tabs for indentation but allow smart tabs
"quotes": [0, "single"],
"quote-props": 2, //- 1e2 and 100 are coerced into strings before getting used as the property name. Both String(1e2) and String(100) happen to be equal to "100", which causes the “Duplicate data property in object literal not allowed in strict mode” error. Issues like that can be tricky to debug. Yet, they can easily be avoided, by simply always quoting property names in object literals.
"semi": [2, "always"], //-require or disallow use of semicolons instead of ASI
"sort-vars": 0, //- sort variables within the same declaration block (off by default)
"keyword-spacing": ["error", { "after": true }], //-require a space after certain keywords (off by default)
"object-curly-spacing": [2, "never"], //-require or disallow spaces inside brackets (off by default)
"array-bracket-spacing": [2, "never"],
"computed-property-spacing": [2, "never"],
"space-in-parens": [2, "never"], //-require or disallow spaces inside parentheses (off by default)
"space-infix-ops": 2, //-require spaces around operators
"space-unary-ops": 2, //-require a space around word operators such as typeof (off by default)
"max-nested-callbacks": [2, 4], //-specify the maximum depth callbacks can be nested (off by default)
"one-var": 0, //-allow just one var statement per function (off by default)
"wrap-regex": 0, //-When a regular expression is used in certain situation, it can end up looking like a division operator
//Strict
"strict": [2, "global"], //- require that all functions are run in strict mode
//Node.js
"no-restricted-modules": [2, "os"], //-restrict usage of specified node modules (off by default)
//Legacy
"max-depth": [2, 10], //-This rule aims to reduce the complexity of your code by allowing you to configure the maximum depth blocks can be nested in a function.
"max-len": [2, 120, 2], //-specify the maximum length of a line in your program (off by default)
"max-params": [2, 8], //-limits the number of parameters that can be used in the function declaration. (off by default)
"max-statements": [2, 50], //- specify the maximum number of statement allowed in a function (off by default)
"no-bitwise": 2, //-disallow use of bitwise operators (off by default)
"no-plusplus": 2, //-disallow use of unary operators, ++ and -- (off by default)
//Variables
"no-delete-var": 2, //-The delete operator will only delete the properties of objects. It cannot "delete" variables or anything else. Using them on variables might lead to unexpected behavior.
"no-label-var": 2, //-disallow labels that share a name with a variable
"no-shadow": 2, //-disallow declaration of variables already declared in the outer scope
"no-shadow-restricted-names": 2, //-disallow shadowing of names such as arguments
"no-undef": 2, //-disallow use of undeclared variables unless mentioned in a /*global */ block
"no-undefined": 2, //-disallow use of undefined variable (off by default) Checking if a value is undefined should be done with typeof <v> === "undefined"
"no-undef-init": 2, //-disallow use of undefined when initializing variables - unnecessary
"no-unused-vars": 2, //-disallow declaration of variables that are not used in the code
"no-use-before-define": 0, //-disallow use of variables before they are defined
//Best Practices
"block-scoped-var": 2, //-treat var statements as if they were block scoped (off by default). E.g. block scope includes If or switch case blocks. This is to help avoid difficult bugs with variable hoisting.
"complexity": [1, 12], //-specify the maximum cyclomatic complexity allowed in a program (off by default)
"consistent-return": ["warn", { "treatUndefinedAsUnspecified": true }], //-require return statements to either always or never specify values
"curly": 2, //-specify curly brace conventions for all control statements
"default-case": 2, //-require default case in switch statements (off by default)
"dot-notation": 2, //-encourages use of dot notation whenever possible
"eqeqeq": [2, "smart"], //-require the use of === and !== except for specific cases a) Comparing two literal values b) Evaluating the value of typeof c) Comparing against null
"guard-for-in": 2, //-make sure for-in loops have an if statement (off by default)
"no-alert": 2, //-disallow the use of alert, confirm, and prompt
"no-caller": 2, //-The use of arguments.caller and arguments.callee make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 while in strict mode.
"no-div-regex": 2, //-disallow division operators explicitly at beginning of regular expression (off by default)
"no-else-return": 2, //-disallow else after a return in an if (off by default)
"no-labels": ["error", {"allowLoop": true, "allowSwitch": true}], //-disallow use of labels for anything other then loops and switches
"no-eq-null": 2, //-disallow comparisons to null without a type-checking operator (off by default)
"no-eval": 2, //-disallow use of eval()
"no-extend-native": 2, //-disallow adding to native types
"no-extra-bind": 2, //-disallow unnecessary function binding - Function binding makes no difference in function expressions, when the function does not use this.
"no-fallthrough": 2, //-This rule is aimed at eliminating unintentional fallthrough of one case to the other. As such, it flags and fallthrough scenarios that are not marked by a comment.
"no-floating-decimal": 2, //-disallow the use of leading or trailing decimal points in numeric literals (off by default)
"no-implied-eval": 2, //-This rule aims to eliminate implied eval() through the use of setTimeout() and setInterval(). As such, it will warn when either function is used with a string as the first argument.
"no-iterator": 2, //-This rule is aimed at preventing errors that may arise from using the __iterator__ property, which is not implemented in several browsers. As such, it will warn whenever it encounters the __iterator__ property.
"no-lone-blocks": 2, //-disallow unnecessary nested blocks
"no-loop-func": 2, //-disallow creation of functions within loops
"no-multi-str": 2, //-It's possible to create multiline strings in JavaScript by using a slash before a newline - This rule is aimed at preventing the use of multiline strings.
"no-native-reassign": 2, //-disallow reassignments of native objects
"no-new": 2, //-Calling constructors with the new keyword, without assigning the resulting object to a variable does is equivalent to simply calling the constructor without the new keyword. Thus, the constructor can be avoided and the function can be called directly.
"no-new-func": 2, //-This error is raised to highlight the use of a bad practice. By passing a string to the Function constructor, you are requiring the engine to parse that string much in the way it has to when you call the eval function.
"no-new-wrappers": 2, //-This rule aims to eliminate the use of String, Number, and Boolean with the new operator. The first problem is that primitive wrapper objects are, in fact, objects. That means typeof will return "object" instead of "string", "number", or "boolean". The second problem comes with boolean objects. Every object is truthy, that means an instance of Boolean always resolves to true even when its actual value is false.
"no-octal": 2, //-disallow use of octal literals - As of version 5 of the ECMAScript specification, octal sequences are a deprecated feature
"no-octal-escape": 2, //-As of version 5 of the ECMAScript specification, octal escape sequences are a deprecated feature and should not be used. It is recommended that Unicode escapes be used instead.
"no-proto": 2, //-__proto__ property has been deprecated as of ECMAScript 3.1 and shouldn't be used in the code.
"no-redeclare": 2, //-disallow declaring the same variable more then once
"no-return-assign": 2, //-One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison.
"no-script-url": 2, //-Using javascript: urls is considered by some as a form of eval. Script passed after javascript: has to be parsed and evaluated by the browser the same way that it does eval.
"no-self-compare": 2, //-Comparing a variable against itself is usually an error, either an typo or refactoring error. It is confusing to the reader and may potentially introduce a runtime error.
"no-sequences": 2, //-The comma operator includes multiple expressions where only one is expected. It evaluates each operand from left to right and returns the value of the last operand. However, this frequently obscures side effects, and its use is often an accident. This rule forbids the use of the comma operator, with the following exceptions: In the initialization or update portions of a for statement. If the expression sequence is explicitly wrapped in parentheses.
"no-unused-expressions": 2, //-Unused expressions are those expressions that evaluate to a value but are never used.
"no-void": 2, //-Some code styles prohibit void operator marking it as non-obvious and hard to read.
"no-warning-comments": [1, {
"terms": ["@TODO", "TODO", "fixme", "xxx"],
"location": "start"
}], //-disallow usage of configurable warning terms in comments
"no-with": 2, //-The with statement is potentially problematic because it adds members of an object to the current scope, making it impossible to tell what a variable inside the block actually refers to. Additionally, the with statement cannot be used in strict mode.
"radix": 2, //-require use of the second argument for parseInt() (off by default)
"vars-on-top": 2, //-requires to declare all vars on top of their containing scope (off by default) Allows use of mulitple var keywords as long as they are at the top in sequence
"wrap-iife": [2, "any"], //-Require immediate function invocation to be wrapped in parentheses. wrapping the call expression
"yoda": [2, "never"], //-if ("red" === color) is called a Yoda condition because it reads as, "red is the color", if (color === "red") which is arguably a more natural way to describe the comparison. Opponents of Yoda conditions point out that tooling has made us better programmers because tools will catch the mistaken use of = instead of == (ESLint will catch this for you). Therefore, they argue, the utility of the pattern doesn't outweigh the readability hit the code takes while using Yoda conditions.
//Possible Errors
"no-cond-assign": 2, // - disallow assignment in conditional expressions
"no-console": 2, // - disallow use of console (off by default in the node environment)
"no-constant-condition": 2, // - disallow use of constant expressions in conditions
"comma-dangle": [2, "never"], // - disallow trailing commas in object literals
"no-control-regex": 2, // - disallow control characters in regular expressions
"no-debugger": 2, // - disallow use of debugger
"no-dupe-keys": 2, // - disallow duplicate keys when creating object literals
"no-empty": 2, // - disallow empty statements
"no-empty-character-class": 2, // - disallow the use of empty character classes in regular expressions
"no-ex-assign": 2, // - disallow assigning to the exception in a catch block
"no-extra-boolean-cast": 2, // - disallow double-negation boolean casts in a boolean context
"no-extra-semi": 2, // - disallow unnecessary semicolons
"no-func-assign": 2, // - disallow overwriting functions written as function declarations
"no-inner-declarations": 2, // - disallow function or variable declarations in nested blocks
"no-invalid-regexp": 2, // - disallow invalid regular expression strings in the RegExp constructor
"no-negated-in-lhs": 2, // - disallow negation of the left operand of an in expression
"no-obj-calls": 2, // - disallow the use of object properties of the global object (Math and JSON) as functions
"no-regex-spaces": 2, // - disallow multiple spaces in a regular expression literal
"no-sparse-arrays": 2, // - disallow sparse arrays
"no-unreachable": 2, // - disallow unreachable statements after a return, throw, continue, or break statement
"use-isnan": 2, // - disallow comparisons with the value NaN
"valid-jsdoc": [2, {
"requireReturn": false
}], // - Ensure JSDoc comments are valid (off by default)
"valid-typeof": 2 // - Ensure that the results of typeof are compared against a valid string
}
}