| 1 | { |
| 2 | 'plugins': [ |
| 3 | 'babel', |
| 4 | 'promise', |
| 5 | ], |
| 6 | 'env': { |
| 7 | 'browser': true, |
| 8 | 'amd': true |
| 9 | }, |
| 10 | 'globals': { |
| 11 | 'M': true, |
| 12 | 'Y': true |
| 13 | }, |
| 14 | 'rules': { |
| 15 | // See http://eslint.org/docs/rules/ for all rules and explanations of all |
| 16 | // rules. |
| 17 | |
| 18 | // === Possible Errors === |
| 19 | 'comma-dangle': 'off', |
| 20 | 'no-compare-neg-zero': 'error', |
| 21 | 'no-cond-assign': 'error', |
| 22 | 'no-console': 'error', |
| 23 | 'no-constant-condition': 'error', |
| 24 | 'no-control-regex': 'error', |
| 25 | 'no-debugger': 'error', |
| 26 | 'no-dupe-args': 'error', |
| 27 | 'no-dupe-keys': 'error', |
| 28 | 'no-duplicate-case': 'error', |
| 29 | 'no-empty': 'warn', |
| 30 | 'no-empty-character-class': 'error', |
| 31 | 'no-ex-assign': 'error', |
| 32 | 'no-extra-boolean-cast': 'error', |
| 33 | 'no-extra-parens': 'off', |
| 34 | 'no-extra-semi': 'error', |
| 35 | 'no-func-assign': 'error', |
| 36 | 'no-inner-declarations': 'error', |
| 37 | 'no-invalid-regexp': 'error', |
| 38 | 'no-irregular-whitespace': 'error', |
| 39 | 'no-obj-calls': 'error', |
| 40 | 'no-prototype-builtins': 'off', |
| 41 | 'no-regex-spaces': 'error', |
| 42 | 'no-sparse-arrays': 'error', |
| 43 | 'no-unexpected-multiline': 'error', |
| 44 | 'no-unreachable': 'warn', |
| 45 | 'no-unsafe-finally': 'error', |
| 46 | 'no-unsafe-negation': 'error', |
| 47 | 'use-isnan': 'error', |
| 48 | 'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }], |
| 49 | 'valid-typeof': 'error', |
| 50 | |
| 51 | // === Best Practices === |
| 52 | // (these mostly match our jshint config) |
| 53 | 'array-callback-return': 'warn', |
| 54 | 'block-scoped-var': 'warn', |
| 55 | 'complexity': 'warn', |
| 56 | 'consistent-return': 'warn', |
| 57 | 'curly': 'error', |
| 58 | 'dot-notation': 'warn', |
| 59 | 'no-alert': 'warn', |
| 60 | 'no-caller': 'error', |
| 61 | 'no-case-declarations': 'error', |
| 62 | 'no-div-regex': 'error', |
| 63 | 'no-empty-pattern': 'error', |
| 64 | 'no-empty-function': 'warn', |
| 65 | 'no-eq-null': 'error', |
| 66 | 'no-eval': 'error', |
| 67 | 'no-extend-native': 'error', |
| 68 | 'no-extra-bind': 'warn', |
| 69 | 'no-fallthrough': 'error', |
| 70 | 'no-floating-decimal': 'warn', |
| 71 | 'no-global-assign': 'warn', |
| 72 | 'no-implied-eval': 'error', |
| 73 | 'no-invalid-this': 'error', |
| 74 | 'no-iterator': 'error', |
| 75 | 'no-labels': 'error', |
| 76 | 'no-loop-func': 'error', |
| 77 | 'no-multi-spaces': 'warn', |
| 78 | 'no-multi-str': 'error', |
| 79 | 'no-new-func': 'error', |
| 80 | 'no-new-wrappers': 'error', |
| 81 | 'no-octal': 'error', |
| 82 | 'no-octal-escape': 'error', |
| 83 | 'no-proto': 'error', |
| 84 | 'no-redeclare': 'warn', |
| 85 | 'no-return-assign': 'error', |
| 86 | 'no-script-url': 'error', |
| 87 | 'no-self-assign': 'error', |
| 88 | 'no-self-compare': 'error', |
| 89 | 'no-sequences': 'warn', |
| 90 | 'no-throw-literal': 'warn', |
| 91 | 'no-unmodified-loop-condition': 'error', |
| 92 | 'no-unused-expressions': 'error', |
| 93 | 'no-unused-labels': 'error', |
| 94 | 'no-useless-call': 'warn', |
| 95 | 'no-useless-escape': 'warn', |
| 96 | 'no-with': 'error', |
| 97 | 'wrap-iife': ['error', 'any'], |
| 98 | |
| 99 | // === Variables === |
| 100 | 'no-delete-var': 'error', |
| 101 | 'no-undef': 'error', |
| 102 | 'no-undef-init': 'error', |
| 103 | 'no-unused-vars': ['error', { 'caughtErrors': 'none' }], |
| 104 | |
| 105 | // === Stylistic Issues === |
| 106 | 'array-bracket-spacing': 'warn', |
| 107 | 'block-spacing': 'warn', |
| 108 | 'brace-style': ['warn', '1tbs'], |
| 109 | 'camelcase': 'warn', |
| 110 | 'capitalized-comments': ['warn', 'always', { 'ignoreConsecutiveComments': true }], |
| 111 | 'comma-spacing': ['warn', { 'before': false, 'after': true }], |
| 112 | 'comma-style': ['warn', 'last'], |
| 113 | 'computed-property-spacing': 'error', |
| 114 | 'consistent-this': 'off', |
| 115 | 'eol-last': 'off', |
| 116 | 'func-call-spacing': ['warn', 'never'], |
| 117 | 'func-names': 'off', |
| 118 | 'func-style': 'off', |
| 119 | // indent currently not doing well with our wrapping style, so disabled. |
| 120 | 'indent': ['off', 4, { 'SwitchCase': 1 }], |
| 121 | 'key-spacing': ['warn', { 'beforeColon': false, 'afterColon': true, 'mode': minimum }], |
| 122 | 'keyword-spacing': 'warn', |
| 123 | 'linebreak-style': ['error', 'unix'], |
| 124 | 'lines-around-comment': 'off', |
| 125 | 'max-len': ['error', 132], |
| 126 | 'max-lines': 'off', |
| 127 | 'max-depth': 'warn', |
| 128 | 'max-nested-callbacks': ['warn', 5], |
| 129 | 'max-params': 'off', |
| 130 | 'max-statements': 'off', |
| 131 | 'max-statements-per-line': ['warn', { max: 2 }], |
| 132 | 'new-cap': ['warn', { 'properties': false }], |
| 133 | 'new-parens': 'warn', |
| 134 | 'newline-after-var': 'off', |
| 135 | 'newline-before-return': 'off', |
| 136 | 'newline-per-chained-call': 'off', |
| 137 | 'no-array-constructor': 'off', |
| 138 | 'no-bitwise': 'error', |
| 139 | 'no-continue': 'off', |
| 140 | 'no-inline-comments': 'off', |
| 141 | 'no-lonely-if': 'off', |
| 142 | 'no-mixed-operators': 'off', |
| 143 | 'no-mixed-spaces-and-tabs': 'error', |
| 144 | 'no-multiple-empty-lines': 'warn', |
| 145 | 'no-negated-condition': 'off', |
| 146 | 'no-nested-ternary': 'warn', |
| 147 | 'no-new-object': 'off', |
| 148 | 'no-plusplus': 'off', |
| 149 | 'no-tabs': 'error', |
| 150 | 'no-ternary': 'off', |
| 151 | 'no-trailing-spaces': 'error', |
| 152 | 'no-underscore-dangle': 'off', |
| 153 | 'no-unneeded-ternary': 'off', |
| 154 | 'no-whitespace-before-property': 'warn', |
| 155 | 'object-curly-newline': 'off', |
| 156 | 'object-curly-spacing': 'warn', |
| 157 | 'object-property-newline': 'off', |
| 158 | 'one-var': 'off', |
| 159 | 'one-var-declaration-per-line': ['warn', 'initializations'], |
| 160 | 'operator-assignment': 'off', |
| 161 | 'operator-linebreak': 'off', |
| 162 | 'padded-blocks': 'off', |
| 163 | 'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}], |
| 164 | 'quotes': 'off', |
| 165 | 'require-jsdoc': 'warn', |
| 166 | 'semi': 'error', |
| 167 | 'semi-spacing': ['warn', {'before': false, 'after': true}], |
| 168 | 'sort-vars': 'off', |
| 169 | 'space-before-blocks': 'warn', |
| 170 | 'space-before-function-paren': ['warn', 'never'], |
| 171 | 'space-in-parens': 'warn', |
| 172 | 'space-infix-ops': 'warn', |
| 173 | 'space-unary-ops': 'warn', |
| 174 | 'spaced-comment': 'warn', |
| 175 | 'unicode-bom': 'error', |
| 176 | 'wrap-regex': 'off', |
| 177 | |
| 178 | // === Promises === |
| 179 | 'promise/always-return': 'warn', |
| 180 | 'promise/no-return-wrap': 'warn', |
| 181 | 'promise/param-names': 'warn', |
| 182 | 'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail']}], |
| 183 | 'promise/no-native': 'warn', |
| 184 | 'promise/no-promise-in-callback': 'warn', |
| 185 | 'promise/no-callback-in-promise': 'warn', |
| 186 | 'promise/avoid-new': 'warn', |
| 187 | |
| 188 | // === Deprecations === |
| 189 | "no-restricted-properties": ['warn', { |
| 190 | 'object': 'M', |
| 191 | 'property': 'str', |
| 192 | 'message': 'Use AMD module "core/str" or M.util.get_string()' |
| 193 | }], |
| 194 | |
| 195 | }, |
| 196 | overrides: [ |
| 197 | { |
| 198 | files: ["**/yui/src/**/*.js"], |
| 199 | // Disable some rules which we can't safely define for YUI rollups. |
| 200 | rules: { |
| 201 | 'no-undef': 'off', |
| 202 | 'no-unused-vars': 'off', |
| 203 | 'no-unused-expressions': 'off' |
| 204 | } |
| 205 | }, |
| 206 | { |
| 207 | files: ["**/amd/src/*.js", "**/amd/src/**/*.js", "Gruntfile*.js", "babel-plugin-add-module-to-define.js"], |
| 208 | // We support es6 now. Woot! |
| 209 | env: { |
| 210 | es6: true |
| 211 | }, |
| 212 | // We're using babel transpiling so use their parser |
| 213 | // for linting. |
| 214 | parser: 'babel-eslint', |
| 215 | // Check AMD with some slightly stricter rules. |
| 216 | rules: { |
| 217 | 'no-unused-vars': 'error', |
| 218 | 'no-implicit-globals': 'error', |
| 219 | // Disable all of the rules that have babel versions. |
| 220 | 'new-cap': 'off', |
| 221 | // Not using this rule for the time being because it isn't |
| 222 | // compatible with jQuery and ES6. |
| 223 | 'no-invalid-this': 'off', |
| 224 | 'object-curly-spacing': 'off', |
| 225 | 'quotes': 'off', |
| 226 | 'semi': 'off', |
| 227 | 'no-unused-expressions': 'off', |
| 228 | // Enable all of the babel version of these rules. |
| 229 | 'babel/new-cap': ['warn', { 'properties': false }], |
| 230 | // Not using this rule for the time being because it isn't |
| 231 | // compatible with jQuery and ES6. |
| 232 | 'babel/no-invalid-this': 'off', |
| 233 | 'babel/object-curly-spacing': 'warn', |
| 234 | // This is off in the original style int. |
| 235 | 'babel/quotes': 'off', |
| 236 | 'babel/semi': 'error', |
| 237 | 'babel/no-unused-expressions': 'error', |
| 238 | // === Promises === |
| 239 | // We have Promise now that we're using ES6. |
| 240 | 'promise/no-native': 'off', |
| 241 | 'promise/avoid-new': 'off' |
| 242 | }, |
| 243 | parserOptions: { |
| 244 | 'ecmaVersion': 9, |
| 245 | 'sourceType': 'module' |
| 246 | } |
| 247 | } |
| 248 | ] |
| 249 | } |