|
| 1 | +/* eslint-disable quote-props */ |
| 2 | + |
| 3 | +/** |
| 4 | + * Fullstack Education Group |
| 5 | + * ESLint config for teaching full-stack ES5/6 JS |
| 6 | + * See http://eslint.org/docs/developer-guide/shareable-configs |
| 7 | + * Authored by Gabriel Lebec, 2016 |
| 8 | + */ |
| 9 | + |
| 10 | +module.exports = { |
| 11 | + extends: 'eslint:recommended', // overridden below unless new recommended rules are added before this doc is updated |
| 12 | + |
| 13 | + env: { |
| 14 | + es6: true, |
| 15 | + browser: true, |
| 16 | + node: true, |
| 17 | + mocha: true, |
| 18 | + jasmine: true, |
| 19 | + jquery: true, |
| 20 | + }, |
| 21 | + parserOptions: { |
| 22 | + ecmaVersion: 6 |
| 23 | + }, |
| 24 | + globals: { |
| 25 | + angular: true |
| 26 | + }, |
| 27 | + |
| 28 | + rules: { // http://eslint.org/docs/rules/ |
| 29 | + |
| 30 | + // Possible Errors |
| 31 | + 'comma-dangle': [2, 'only-multiline'], // require or disallow trailing commas |
| 32 | + 'no-cond-assign': 2, // disallow assignment operators in conditional expressions |
| 33 | + 'no-console': 0, // disallow the use of `console` |
| 34 | + 'no-constant-condition': 2, // disallow constant expressions in conditions |
| 35 | + 'no-control-regex': 2, // disallow control characters in regular expressions |
| 36 | + 'no-debugger': 2, // disallow the use of `debugger` |
| 37 | + 'no-dupe-args': 2, // disallow duplicate arguments in function definitions |
| 38 | + 'no-dupe-keys': 2, // disallow duplicate keys in object literals |
| 39 | + 'no-duplicate-case': 2, // disallow duplicate case labels |
| 40 | + 'no-empty': 2, // disallow empty block statements |
| 41 | + 'no-empty-character-class': 2, // disallow empty character classes in regular expressions |
| 42 | + 'no-ex-assign': 2, // disallow reassigning exceptions in `catch` clauses |
| 43 | + 'no-extra-boolean-cast': 2, // disallow unnecessary boolean casts |
| 44 | + 'no-extra-parens': [0, 'all', {returnAssign: false, nestedBinaryExpressions: false}], // disallow unnecessary parentheses |
| 45 | + 'no-extra-semi': 2, // disallow unnecessary semicolons |
| 46 | + 'no-func-assign': 2, // disallow reassigning `function` declarations |
| 47 | + 'no-inner-declarations': [2, 'functions'], // disallow `function` or `var` declarations in nested blocks |
| 48 | + 'no-invalid-regexp': 2, // disallow invalid regular expression strings in RegExp constructors |
| 49 | + 'no-irregular-whitespace': 2, // disallow irregular whitespace outside of strings and comments |
| 50 | + 'no-negated-in-lhs': 2, // disallow negating the left operand in `in` expressions |
| 51 | + 'no-obj-calls': 2, // disallow calling the `Math` and `JSON` objects as functions, |
| 52 | + 'no-prototype-builtins': 0, // Disallow use of `Object.prototypes` builtins directly |
| 53 | + 'no-regex-spaces': 2, // disallow multiple spaces in regular expression literals |
| 54 | + 'no-sparse-arrays': 2, // disallow sparse arrays |
| 55 | + 'no-template-curly-in-string': 1, // disallow template literal placeholder syntax in regular strings |
| 56 | + 'no-unexpected-multiline': 2, // disallow confusing multiline expressions |
| 57 | + 'no-unreachable': 2, // disallow unreachable code after `return`, `throw`, `continue`, and `break` statements |
| 58 | + 'no-unsafe-finally': 1, // disallow control flow statements in `finally` blocks |
| 59 | + 'no-unsafe-negation': 2, // disallow negating the left operand of relational operators |
| 60 | + 'use-isnan': 2, // require calls to `isNaN()` when checking for NaN |
| 61 | + 'valid-jsdoc': 0, // enforce valid JSDoc comments |
| 62 | + 'valid-typeof': 2, // enforce comparing `typeof` expressions against valid strings |
| 63 | + |
| 64 | + // Best Practices |
| 65 | + 'accessor-pairs': 2, // enforce getter and setter pairs in objects |
| 66 | + 'array-callback-return': 0, // enforce `return` statements in callbacks of array methods |
| 67 | + 'block-scoped-var': 0, // enforce the use of variables within the scope they are defined |
| 68 | + 'class-methods-use-this': 1, // enforce that class methods utilize `this` |
| 69 | + 'complexity': [1, {max: 8}], // enforce a maximum cyclomatic complexity allowed in a program |
| 70 | + 'consistent-return': 0, // require return statements to either always or never specify values |
| 71 | + 'curly': [1, 'multi-line', 'consistent'], // enforce consistent brace style for all control statements |
| 72 | + 'default-case': 1, // require `default` cases in switch statements |
| 73 | + 'dot-location': 0, // enforce consistent newlines before and after dots |
| 74 | + 'dot-notation': 1, // enforce dot notation whenever possible |
| 75 | + 'eqeqeq': [1, 'smart'], // require the use of === and !== |
| 76 | + 'guard-for-in': 1, // require `for-in` loops to include an `if` statement |
| 77 | + 'no-alert': 1, // disallow the use of `alert`, `confirm`, and `prompt` |
| 78 | + 'no-caller': 2, // disallow the use of `arguments.caller` or `arguments.callee` |
| 79 | + 'no-case-declarations': 1, // disallow lexical declarations in case clauses |
| 80 | + 'no-div-regex': 2, // disallow division operators explicitly at the beginning of regular expressions |
| 81 | + 'no-else-return': 0, // disallow `else` blocks after `return` statements in `if` statements |
| 82 | + 'no-empty-function': 0, // disallow empty functions |
| 83 | + 'no-empty-pattern': 1, // disallow empty destructuring patterns |
| 84 | + 'no-eq-null': 1, // disallow `null` comparisons without type-checking operators |
| 85 | + 'no-eval': 1, // disallow the use of `eval()` |
| 86 | + 'no-extend-native': 1, // disallow extending native types |
| 87 | + 'no-extra-bind': 1, // disallow unnecessary calls to `.bind()` |
| 88 | + 'no-extra-label': 1, // disallow unnecessary labels |
| 89 | + 'no-fallthrough': 1, // disallow fallthrough of `case` statements |
| 90 | + 'no-floating-decimal': 1, // disallow leading or trailing decimal points in numeric literals |
| 91 | + 'no-global-assign': 1, // disallow assignments to native objects or read-only global variables |
| 92 | + 'no-implicit-coercion': 0, // disallow shorthand type conversions |
| 93 | + 'no-implicit-globals': 0, // disallow `var` and named `function` declarations in the global scope |
| 94 | + 'no-implied-eval': 1, // disallow the use of `eval()`-like methods |
| 95 | + 'no-invalid-this': 0, // disallow `this` keywords outside of classes or class-like objects |
| 96 | + 'no-iterator': 2, // disallow the use of the `__iterator__` property |
| 97 | + 'no-labels': 1, // disallow labeled statements |
| 98 | + 'no-lone-blocks': 1, // disallow unnecessary nested blocks |
| 99 | + 'no-loop-func': 1, // disallow `function` declarations and expressions inside loop statements |
| 100 | + 'no-magic-numbers': [0, {ignore: [0, 1, 24, 60]}], // disallow magic numbers |
| 101 | + 'no-multi-spaces': [0, {exceptions: {VariableDeclarator: true, Property: true}}], // disallow multiple spaces |
| 102 | + 'no-multi-str': 1, // disallow multiline strings |
| 103 | + 'no-native-reassign': 2, // disallow reassigning native objects |
| 104 | + 'no-new': 2, // disallow `new` operators outside of assignments or comparisons |
| 105 | + 'no-new-func': 1, // disallow `new` operators with the `Function` object |
| 106 | + 'no-new-wrappers': 2, // disallow `new` operators with the `String`, `Number`, and `Boolean` objects |
| 107 | + 'no-octal': 2, // disallow octal literals |
| 108 | + 'no-octal-escape': 2, // disallow octal escape sequences in string literals |
| 109 | + 'no-param-reassign': 0, // disallow reassigning `function` parameters |
| 110 | + 'no-proto': 2, // disallow the use of the `__proto__` property |
| 111 | + 'no-redeclare': [1, {builtinGlobals: true}], // disallow `var` redeclaration |
| 112 | + 'no-restricted-properties': 0, // disallow certain properties on certain objects |
| 113 | + 'no-return-assign': [1, 'always'], // disallow assignment operators in `return` statements |
| 114 | + 'no-script-url': 2, // disallow `javascript` urls |
| 115 | + 'no-self-assign': [2, {props: true}], // disallow assignments where both sides are exactly the same |
| 116 | + 'no-self-compare': 2, // disallow comparisons where both sides are exactly the same |
| 117 | + 'no-sequences': 1, // disallow comma operators |
| 118 | + 'no-throw-literal': 1, // disallow throwing literals as exceptions |
| 119 | + 'no-unmodified-loop-condition': 1, // disallow unmodified loop conditions |
| 120 | + 'no-unused-expressions': 2, // disallow unused expressions |
| 121 | + 'no-unused-labels': 2, // disallow unused labels |
| 122 | + 'no-useless-call': 1, // disallow unnecessary calls to `.call()` and `.apply()` |
| 123 | + 'no-useless-concat': 1, // disallow unnecessary concatenation of literals or template literals |
| 124 | + 'no-useless-escape': 1, // disallow unnecessary escape characters |
| 125 | + 'no-useless-return': 1, // disallow redundant return statements |
| 126 | + 'no-void': 1, // disallow `void` operators |
| 127 | + 'no-warning-comments': 1, // disallow specified warning terms in comments |
| 128 | + 'no-with': 2, // disallow `with` statements |
| 129 | + 'radix': 1, // enforce the consistent use of the radix argument when using `parseInt()` |
| 130 | + 'vars-on-top': 0, // require `var` declarations be placed at the top of their containing scope |
| 131 | + 'wrap-iife': [1, 'any'], // require parentheses around immediate function invocations |
| 132 | + 'yoda': 0, // require or disallow “Yoda” conditions |
| 133 | + |
| 134 | + // Strict Mode |
| 135 | + 'strict': 0, // require or disallow strict mode directives |
| 136 | + |
| 137 | + // Variables |
| 138 | + 'init-declarations': 0, // require or disallow initialization in `var` declarations |
| 139 | + 'no-catch-shadow': 1, // disallow `catch` clause parameters from shadowing variables in the outer scope |
| 140 | + 'no-delete-var': 2, // disallow deleting variables |
| 141 | + 'no-label-var': 2, // disallow labels that share a name with a variable |
| 142 | + 'no-restricted-globals': 0, // disallow specified global variables |
| 143 | + 'no-shadow': 1, // disallow `var` declarations from shadowing variables in the outer scope |
| 144 | + 'no-shadow-restricted-names': 2, // disallow identifiers from shadowing restricted names |
| 145 | + 'no-undef': 1, // disallow the use of undeclared variables unless mentioned in `/*global */` comments |
| 146 | + 'no-undef-init': 0, // disallow initializing variables to `undefined` |
| 147 | + 'no-undefined': 0, // disallow the use of `undefined` as an identifier |
| 148 | + 'no-unused-vars': [1, {argsIgnorePattern: 'next'}], // disallow unused variables |
| 149 | + 'no-use-before-define': [1, 'nofunc'], // disallow the use of variables before they are defined |
| 150 | + |
| 151 | + // Node.js and CommonJS |
| 152 | + 'callback-return': 0, // require `return` statements after callbacks |
| 153 | + 'global-require': 0, // require `require()` calls to be placed at top-level module scope |
| 154 | + 'handle-callback-err': [2, '^(err|error|.+Error$)'], // require error handling in max-nested-callbacks |
| 155 | + 'no-mixed-requires': 1, // disallow `require` calls to be mixed with regular `var` declarations |
| 156 | + 'no-new-require': 1, // disallow `new` operators with calls to `require` |
| 157 | + 'no-path-concat': 1, // disallow string concatenation with `__dirname` and `__filename` |
| 158 | + 'no-process-env': 0, // disallow the use of `process.env` |
| 159 | + 'no-process-exit': 0, // disallow the use of `process.exit()` |
| 160 | + 'no-restricted-modules': 0, // disallow specified modules when loaded by `require` |
| 161 | + 'no-sync': 0, // disallow synchronous methods |
| 162 | + |
| 163 | + // Stylistic Issues |
| 164 | + 'array-bracket-spacing': 0, // enforce consistent spacing inside array brackets |
| 165 | + 'block-spacing': 0, // enforce consistent spacing inside single-line blocks |
| 166 | + 'brace-style': 0, // enforce consistent brace style for blocks |
| 167 | + 'camelcase': 1, // enforce camelcase naming convention |
| 168 | + 'comma-spacing': 1, // enforce consistent spacing before and after commas |
| 169 | + 'comma-style': 0, // enforce consistent comma style |
| 170 | + 'computed-property-spacing': 0, // enforce consistent spacing inside computed property brackets |
| 171 | + 'consistent-this': 0, // enforce consistent naming when capturing the current execution context |
| 172 | + 'eol-last': 1, // enforce at least one newline at the end of files |
| 173 | + 'func-call-spacing': 1, // require or disallow spacing between `function` identifiers and their invocations |
| 174 | + 'func-name-matching': 1, // require function names to match the name of the variable or property to which they are assigned |
| 175 | + 'func-names': 0, // enforce named `function` expressions |
| 176 | + 'func-style': 0, // enforce the consistent use of either `function` declarations or expressions |
| 177 | + 'id-blacklist': 0, // disallow specified identifiers |
| 178 | + 'id-length': [1, {exceptions: ['_', '$', 'i', 'j', 'k']}], // enforce minimum and maximum identifier lengths |
| 179 | + 'id-match': 0, // require identifiers to match a specified regular expression |
| 180 | + 'indent': [0, 2, {SwitchCase: 1, VariableDeclarator: {var: 2, let: 2, const: 3}}], // enforce consistent indentation |
| 181 | + 'jsx-quotes': [1, 'prefer-double'], // enforce the consistent use of either double or single quotes in JSX attributes |
| 182 | + 'key-spacing': [1, {mode: 'minimum'}], // enforce consistent spacing between keys and values in object literal properties |
| 183 | + 'keyword-spacing': 1, // enforce consistent spacing before and after keywords |
| 184 | + 'line-comment-position': 0, // enforce position of line comments |
| 185 | + 'linebreak-style': 1, // enforce consistent linebreak style |
| 186 | + 'lines-around-comment': 0, // require empty lines around comments |
| 187 | + 'lines-around-directive': 0, // require or disallow newlines around directives |
| 188 | + 'max-depth': [1, {max: 6}], // enforce a maximum depth that blocks can be nested |
| 189 | + 'max-len': [0, {code: 100, ignoreStrings: true, ignoreTemplateLiterals: true}], // enforce a maximum line length |
| 190 | + 'max-lines': [0, {max: 300}], // enforce a maximum file length |
| 191 | + 'max-nested-callbacks': [1, {max: 6}], // enforce a maximum depth that callbacks can be nested |
| 192 | + 'max-params': [1, {max: 6}], // enforce a maximum number of parameters in `function` definitions |
| 193 | + 'max-statements': [1, 30], // enforce a maximum number of statements allowed in `function` blocks |
| 194 | + 'max-statements-per-line': [1, {max: 2}], // enforce a maximum number of statements allowed per line |
| 195 | + 'new-cap': [1, {capIsNewExceptions: ['Express']}], // require constructor `function` names to begin with a capital letter |
| 196 | + 'new-parens': 0, // require parentheses when invoking a constructor with no arguments |
| 197 | + 'newline-after-var': 0, // require or disallow an empty line after `var` declarations |
| 198 | + 'newline-before-return': 0, // require an empty line before `return` statements |
| 199 | + 'newline-per-chained-call': [1, {ignoreChainWithDepth: 3}], // require a newline after each call in a method chain |
| 200 | + 'no-array-constructor': 1, // disallow `Array` constructors |
| 201 | + 'no-bitwise': [1, {allow: ['~']}], // disallow bitwise operators |
| 202 | + 'no-continue': 0, // disallow `continue` statements |
| 203 | + 'no-inline-comments': 0, // disallow inline comments after code |
| 204 | + 'no-lonely-if': 1, // disallow `if` statements as the only statement in `else` blocks |
| 205 | + 'no-mixed-operators': 0, // disallow mixes of different operators |
| 206 | + 'no-mixed-spaces-and-tabs': [1, 'smart-tabs'], // disallow mixed spaces and tabs for indentation |
| 207 | + 'no-multiple-empty-lines': [1, {max: 2, maxEOF: 1}], // disallow multiple empty lines |
| 208 | + 'no-negated-condition': 0, // disallow negated conditions |
| 209 | + 'no-nested-ternary': 1, // disallow nested ternary expressions |
| 210 | + 'no-new-object': 0, // disallow `Object` constructors |
| 211 | + 'no-plusplus': 0, // disallow the unary operators `++` and `--` |
| 212 | + 'no-restricted-syntax': 0, // disallow specified syntax |
| 213 | + 'no-spaced-func': 1, // disallow spacing between `function` identifiers and their applications |
| 214 | + 'no-tabs': 0, // disallow tabs in file |
| 215 | + 'no-ternary': 0, // disallow ternary operators |
| 216 | + 'no-trailing-spaces': 1, // disallow trailing whitespace at the end of lines |
| 217 | + 'no-underscore-dangle': 0, // disallow dangling underscores in identifiers |
| 218 | + 'no-unneeded-ternary': 1, // disallow ternary operators when simpler alternatives exist |
| 219 | + 'no-whitespace-before-property': 1, // disallow whitespace before properties |
| 220 | + 'object-curly-newline': 0, // enforce consistent line breaks inside braces |
| 221 | + 'object-curly-spacing': 0, // enforce consistent spacing inside braces |
| 222 | + 'object-property-newline': 0, // enforce placing object properties on separate lines |
| 223 | + 'one-var': 0, // enforce variables to be declared either together or separately in functions |
| 224 | + 'one-var-declaration-per-line': 0, // require or disallow newlines around `var` declarations |
| 225 | + 'operator-assignment': 0, // require or disallow assignment operator shorthand where possible |
| 226 | + 'operator-linebreak': 0, // enforce consistent linebreak style for operators |
| 227 | + 'padded-blocks': 0, // require or disallow padding within blocks |
| 228 | + 'quote-props': [1, 'as-needed'], // require quotes around object literal property names |
| 229 | + 'quotes': [1, 'single', {avoidEscape: true, allowTemplateLiterals: true}], // enforce the consistent use of either backticks, double, or single quotes |
| 230 | + 'require-jsdoc': 0, // require JSDoc comments |
| 231 | + 'semi': [0, 'always'], // require or disallow semicolons instead of ASI |
| 232 | + 'semi-spacing': 0, // enforce consistent spacing before and after semicolons |
| 233 | + 'sort-keys': 0, // requires object keys to be sorted |
| 234 | + 'sort-vars': 0, // require variables within the same declaration block to be sorted |
| 235 | + 'space-before-blocks': 0, // enforce consistent spacing before blocks |
| 236 | + 'space-before-function-paren': 0, // enforce consistent spacing before `function` definition opening parenthesis |
| 237 | + 'space-in-parens': 0, // enforce consistent spacing inside parentheses |
| 238 | + 'space-infix-ops': 1, // require spacing around operators |
| 239 | + 'space-unary-ops': 1, // enforce consistent spacing before or after unary operators |
| 240 | + 'spaced-comment': 0, // enforce consistent spacing after the `//` or `/*` in a comment |
| 241 | + 'unicode-bom': 0, // require or disallow the Unicode BOM |
| 242 | + 'wrap-regex': 0, // require parenthesis around regex literals |
| 243 | + |
| 244 | + // ECMAScript 6 |
| 245 | + 'arrow-body-style': 0, // require braces around arrow function bodies |
| 246 | + 'arrow-parens': 0, // require parentheses around arrow function arguments |
| 247 | + 'arrow-spacing': 1, // enforce consistent spacing before and after the arrow in arrow functions |
| 248 | + 'constructor-super': 2, // require `super()` calls in constructors |
| 249 | + 'generator-star-spacing': 1, // enforce consistent spacing around `*` operators in generator functions |
| 250 | + 'no-class-assign': 1, // disallow reassigning class members |
| 251 | + 'no-confusing-arrow': 1, // disallow arrow functions where they could be confused with comparisons |
| 252 | + 'no-const-assign': 2, // disallow reassigning `const` variables |
| 253 | + 'no-dupe-class-members': 0, // disallow duplicate class members |
| 254 | + 'no-duplicate-imports': 1, // disallow duplicate module imports |
| 255 | + 'no-new-symbol': 1, // disallow `new` operators with the `Symbol` object |
| 256 | + 'no-restricted-imports': 0, // disallow specified modules when loaded by `import` |
| 257 | + 'no-this-before-super': 2, // disallow `this`/`super` before calling `super()` in constructors |
| 258 | + 'no-useless-computed-key': 1, // disallow unnecessary computed property keys in object literals |
| 259 | + 'no-useless-constructor': 1, // disallow unnecessary constructors |
| 260 | + 'no-useless-rename': 1, // disallow renaming import, export, and destructured assignments to the same name |
| 261 | + 'no-var': 0, // require `let` or `const` instead of var |
| 262 | + 'object-shorthand': 0, // require or disallow method and property shorthand syntax for object literals |
| 263 | + 'prefer-arrow-callback': 0, // require arrow functions as callbacks |
| 264 | + 'prefer-const': 0, // require `const` declarations for variables that are never reassigned after declared |
| 265 | + 'prefer-numeric-literals': 0, // disallow `parseInt()` in favor of binary, octal, and hexadecimal literals |
| 266 | + 'prefer-reflect': 0, // require `Reflect` methods where applicable |
| 267 | + 'prefer-rest-params': 0, // require rest parameters instead of arguments |
| 268 | + 'prefer-spread': 0, // require spread operators instead of `.apply()` |
| 269 | + 'prefer-template': 0, // require template literals instead of string concatenation |
| 270 | + 'require-yield': 2, // require generator functions to contain `yield` |
| 271 | + 'sort-imports': 0, // enforce sorted import declarations within modules |
| 272 | + 'symbol-description': 1, // require symbol descriptions |
| 273 | + 'template-curly-spacing': 0, // require or disallow spacing around embedded expressions of template strings |
| 274 | + 'yield-star-spacing': 1, // require or disallow spacing around the `*` in `yield*` expressions |
| 275 | + } |
| 276 | +}; |
0 commit comments