|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + 'env': { |
| 5 | + 'es6': true, |
| 6 | + 'node': true, |
| 7 | + }, |
| 8 | + 'extends': [ |
| 9 | + 'eslint:recommended' |
| 10 | + ], |
| 11 | + 'plugins': [ |
| 12 | + 'jsdoc' |
| 13 | + ], |
| 14 | + 'rules': { |
| 15 | + /* |
| 16 | + * Possible errors |
| 17 | + */ |
| 18 | + |
| 19 | + // Enforce "for" loop update clause moving the counter |
| 20 | + // in the right direction |
| 21 | + 'for-direction': 'error', |
| 22 | + |
| 23 | + // Disallow unnecessary parentheses |
| 24 | + 'no-extra-parens': 'error', |
| 25 | + |
| 26 | + // Disallow template literal placeholder syntax in regular string |
| 27 | + 'no-template-curly-in-string': 'error', |
| 28 | + |
| 29 | + /* |
| 30 | + * Best practices |
| 31 | + */ |
| 32 | + |
| 33 | + // Enforce consistent brace style for all control statements |
| 34 | + 'curly': 'error', |
| 35 | + |
| 36 | + // Require the use of === and !== |
| 37 | + 'eqeqeq': 'error', |
| 38 | + |
| 39 | + // Disallow `else` blocks after `return` statements in `if` statements |
| 40 | + 'no-else-return': 'error', |
| 41 | + |
| 42 | + // Disallow empty functions |
| 43 | + 'no-empty-function': 'error', |
| 44 | + |
| 45 | + // Disallow function declarations and expressions inside loop statements |
| 46 | + 'no-loop-func': 'error', |
| 47 | + |
| 48 | + // Disallow new operators with the String, Number, and Boolean objects |
| 49 | + 'no-new-wrappers': 'error', |
| 50 | + |
| 51 | + // Disallow reassigning function parameters |
| 52 | + 'no-param-reassign': 'error', |
| 53 | + |
| 54 | + // Disallow unnecessary concatenation of strings |
| 55 | + 'no-useless-concat': 'error', |
| 56 | + |
| 57 | + // Disallow redundant return statements |
| 58 | + 'no-useless-return': 'error', |
| 59 | + |
| 60 | + /* |
| 61 | + * Strict mode |
| 62 | + */ |
| 63 | + |
| 64 | + // Require global strict mode directive |
| 65 | + 'strict': ['error', 'global'], |
| 66 | + |
| 67 | + /* |
| 68 | + * Stylistic issues |
| 69 | + */ |
| 70 | + |
| 71 | + // Require 'one true brace style', in which the opening brace |
| 72 | + // of a block is placed on the same line as its corresponding |
| 73 | + // statement or declaration |
| 74 | + 'brace-style': ['error', '1tbs'], |
| 75 | + |
| 76 | + // Disallow spaces inside of brackets |
| 77 | + 'array-bracket-spacing': ['error', 'never'], |
| 78 | + |
| 79 | + // Require CamelCase |
| 80 | + 'camelcase': ['error', { 'properties': 'never' }], |
| 81 | + |
| 82 | + // Require space after comma |
| 83 | + 'comma-spacing': ['error', { 'after': true }], |
| 84 | + |
| 85 | + // Require newline at the end of files |
| 86 | + 'eol-last': ['error', 'always'], |
| 87 | + |
| 88 | + // Disallow spacing between function identifiers and their invocations |
| 89 | + 'func-call-spacing': 'error', |
| 90 | + |
| 91 | + // Use tabs as indentation |
| 92 | + // Enforce indentation level for case clauses in switch statements |
| 93 | + 'indent': [ |
| 94 | + 'error', 'tab', { 'SwitchCase': 1 } |
| 95 | + ], |
| 96 | + |
| 97 | + // Require space after colon in object literal properties |
| 98 | + 'key-spacing': [ |
| 99 | + 'error', { 'afterColon': true } |
| 100 | + ], |
| 101 | + |
| 102 | + // Require space before and after keywords |
| 103 | + 'keyword-spacing': 'error', |
| 104 | + |
| 105 | + // Require Unix line endings |
| 106 | + 'linebreak-style': ['error', 'unix'], |
| 107 | + |
| 108 | + // Disallow empty block statements |
| 109 | + 'no-empty': [ |
| 110 | + 'error', { 'allowEmptyCatch': true } |
| 111 | + ], |
| 112 | + |
| 113 | + // Disallow `if` statements as the only statement in `else` blocks |
| 114 | + 'no-lonely-if': 'error', |
| 115 | + |
| 116 | + // Disallow multiple spaces |
| 117 | + 'no-multi-spaces': 'error', |
| 118 | + |
| 119 | + // Disallow nested ternary expressions |
| 120 | + 'no-nested-ternary': 'error', |
| 121 | + |
| 122 | + // Disallow trailing whitespace at the end of lines |
| 123 | + 'no-trailing-spaces': 'error', |
| 124 | + |
| 125 | + // Disallow ternary operators when simpler alternatives exist |
| 126 | + 'no-unneeded-ternary': 'error', |
| 127 | + |
| 128 | + // Disallow whitespace before properties |
| 129 | + 'no-whitespace-before-property': 'error', |
| 130 | + |
| 131 | + 'one-var': ['error', 'never'], |
| 132 | + |
| 133 | + // Require spaces inside curly braces |
| 134 | + 'object-curly-spacing': ['error', 'always'], |
| 135 | + |
| 136 | + // Require single quotes |
| 137 | + 'quotes': ['error', 'single'], |
| 138 | + |
| 139 | + // Require space before blocks |
| 140 | + 'space-before-blocks': ['error', 'always'], |
| 141 | + |
| 142 | + // Disallow a space before function parenthesis |
| 143 | + 'space-before-function-paren': ['error', 'never'], |
| 144 | + |
| 145 | + // Disallow spaces inside of parentheses |
| 146 | + 'space-in-parens': 'error', |
| 147 | + |
| 148 | + // Require spacing around infix operators |
| 149 | + 'space-infix-ops': 'error', |
| 150 | + |
| 151 | + // Enforce consistent spacing after the // or /* in a comment |
| 152 | + 'spaced-comment': 'error', |
| 153 | + |
| 154 | + // Require semicolon at the end of statement |
| 155 | + 'semi': ['error', 'always'], |
| 156 | + |
| 157 | + // Enforce spacing around colons of switch statements |
| 158 | + 'switch-colon-spacing': [ |
| 159 | + 'error', { 'after': true, 'before': false } |
| 160 | + ], |
| 161 | + |
| 162 | + /* |
| 163 | + * ECMAScript 6 |
| 164 | + */ |
| 165 | + |
| 166 | + // Require parentheses around arrow function arguments |
| 167 | + 'arrow-parens': 'error', |
| 168 | + 'arrow-spacing': 'error', |
| 169 | + |
| 170 | + // Require let or const instead of var |
| 171 | + 'no-var': 'error', |
| 172 | + |
| 173 | + // Require method and property shorthand syntax for object literals |
| 174 | + 'object-shorthand': ['error', 'always'], |
| 175 | + |
| 176 | + // Require `const` declarations for variables |
| 177 | + // that are never reassigned after declared |
| 178 | + 'prefer-const': [ |
| 179 | + 'error', { 'destructuring': 'all' } |
| 180 | + ], |
| 181 | + |
| 182 | + // Require template literals instead of string concatenation |
| 183 | + 'prefer-template': 'error', |
| 184 | + |
| 185 | + // Disallow spacing around embedded expressions of template strings |
| 186 | + 'template-curly-spacing': 'error', |
| 187 | + |
| 188 | + /* |
| 189 | + * JSDoc plugin |
| 190 | + */ |
| 191 | + |
| 192 | + 'jsdoc/check-param-names': 'warn', |
| 193 | + 'jsdoc/check-syntax': 'warn', |
| 194 | + 'jsdoc/check-tag-names': 'warn', |
| 195 | + 'jsdoc/check-types': [ |
| 196 | + 'warn', { 'noDefaults': true } |
| 197 | + ], |
| 198 | + 'jsdoc/no-undefined-types': 'warn', |
| 199 | + 'jsdoc/require-param': 'warn', |
| 200 | + 'jsdoc/require-param-description': 'warn', |
| 201 | + 'jsdoc/require-param-name': 'warn', |
| 202 | + 'jsdoc/require-param-type': 'warn', |
| 203 | + 'jsdoc/require-returns-check': 'warn', |
| 204 | + 'jsdoc/require-returns-description': 'warn', |
| 205 | + 'jsdoc/require-returns-type': 'warn', |
| 206 | + 'jsdoc/valid-types': 'warn', |
| 207 | + }, |
| 208 | + 'settings': { |
| 209 | + 'jsdoc': { |
| 210 | + 'tagNamePreference': { |
| 211 | + 'class': 'constructor', 'returns': 'return' |
| 212 | + } |
| 213 | + }, |
| 214 | + }, |
| 215 | +}; |
0 commit comments