Commit | Line | Data |
---|---|---|
3adb62b7 | 1 | { |
66a91dda | 2 | 'plugins': [ |
c53f86d4 | 3 | 'babel', |
66a91dda DP |
4 | 'promise', |
5 | ], | |
3adb62b7 DP |
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 | |
037de719 DP |
16 | // rules. |
17 | ||
3adb62b7 | 18 | // === Possible Errors === |
037de719 | 19 | 'comma-dangle': 'off', |
9702503f | 20 | 'no-compare-neg-zero': 'error', |
3adb62b7 DP |
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', | |
037de719 | 29 | 'no-empty': 'warn', |
3adb62b7 DP |
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', | |
3adb62b7 DP |
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', | |
00c714f0 | 46 | 'no-unsafe-negation': 'error', |
3adb62b7 | 47 | 'use-isnan': 'error', |
0d06a200 | 48 | 'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }], |
3adb62b7 DP |
49 | 'valid-typeof': 'error', |
50 | ||
51 | // === Best Practices === | |
52 | // (these mostly match our jshint config) | |
037de719 DP |
53 | 'array-callback-return': 'warn', |
54 | 'block-scoped-var': 'warn', | |
55 | 'complexity': 'warn', | |
56 | 'consistent-return': 'warn', | |
3adb62b7 DP |
57 | 'curly': 'error', |
58 | 'dot-notation': 'warn', | |
59 | 'no-alert': 'warn', | |
60 | 'no-caller': 'error', | |
61 | 'no-case-declarations': 'error', | |
037de719 | 62 | 'no-div-regex': 'error', |
3adb62b7 DP |
63 | 'no-empty-pattern': 'error', |
64 | 'no-empty-function': 'warn', | |
037de719 | 65 | 'no-eq-null': 'error', |
3adb62b7 | 66 | 'no-eval': 'error', |
037de719 DP |
67 | 'no-extend-native': 'error', |
68 | 'no-extra-bind': 'warn', | |
3adb62b7 | 69 | 'no-fallthrough': 'error', |
037de719 | 70 | 'no-floating-decimal': 'warn', |
00c714f0 | 71 | 'no-global-assign': 'warn', |
3adb62b7 DP |
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', | |
3adb62b7 DP |
79 | 'no-new-func': 'error', |
80 | 'no-new-wrappers': 'error', | |
037de719 DP |
81 | 'no-octal': 'error', |
82 | 'no-octal-escape': 'error', | |
3adb62b7 DP |
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', | |
037de719 DP |
89 | 'no-sequences': 'warn', |
90 | 'no-throw-literal': 'warn', | |
3adb62b7 | 91 | 'no-unmodified-loop-condition': 'error', |
ad3f8cd1 | 92 | 'no-unused-expressions': 'error', |
3adb62b7 | 93 | 'no-unused-labels': 'error', |
037de719 | 94 | 'no-useless-call': 'warn', |
3adb62b7 | 95 | 'no-useless-escape': 'warn', |
037de719 | 96 | 'no-with': 'error', |
3adb62b7 DP |
97 | 'wrap-iife': ['error', 'any'], |
98 | ||
99 | // === Variables === | |
100 | 'no-delete-var': 'error', | |
ad3f8cd1 | 101 | 'no-undef': 'error', |
037de719 | 102 | 'no-undef-init': 'error', |
00c714f0 | 103 | 'no-unused-vars': ['error', { 'caughtErrors': 'none' }], |
3adb62b7 DP |
104 | |
105 | // === Stylistic Issues === | |
106 | 'array-bracket-spacing': 'warn', | |
107 | 'block-spacing': 'warn', | |
108 | 'brace-style': ['warn', '1tbs'], | |
109 | 'camelcase': 'warn', | |
9702503f | 110 | 'capitalized-comments': ['warn', 'always', { 'ignoreConsecutiveComments': true }], |
3adb62b7 DP |
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', | |
00c714f0 | 116 | 'func-call-spacing': ['warn', 'never'], |
3adb62b7 DP |
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', | |
037de719 DP |
127 | 'max-depth': 'warn', |
128 | 'max-nested-callbacks': ['warn', 5], | |
3adb62b7 DP |
129 | 'max-params': 'off', |
130 | 'max-statements': 'off', | |
037de719 | 131 | 'max-statements-per-line': ['warn', { max: 2 }], |
0d06a200 | 132 | 'new-cap': ['warn', { 'properties': false }], |
3adb62b7 DP |
133 | 'new-parens': 'warn', |
134 | 'newline-after-var': 'off', | |
135 | 'newline-before-return': 'off', | |
037de719 | 136 | 'newline-per-chained-call': 'off', |
3adb62b7 DP |
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', | |
00c714f0 | 149 | 'no-tabs': 'error', |
3adb62b7 DP |
150 | 'no-ternary': 'off', |
151 | 'no-trailing-spaces': 'error', | |
152 | 'no-underscore-dangle': 'off', | |
037de719 | 153 | 'no-unneeded-ternary': 'off', |
3adb62b7 | 154 | 'no-whitespace-before-property': 'warn', |
037de719 DP |
155 | 'object-curly-newline': 'off', |
156 | 'object-curly-spacing': 'warn', | |
157 | 'object-property-newline': 'off', | |
3adb62b7 | 158 | 'one-var': 'off', |
037de719 | 159 | 'one-var-declaration-per-line': ['warn', 'initializations'], |
3adb62b7 DP |
160 | 'operator-assignment': 'off', |
161 | 'operator-linebreak': 'off', | |
162 | 'padded-blocks': 'off', | |
037de719 | 163 | 'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}], |
3adb62b7 DP |
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', | |
00c714f0 | 177 | |
66a91dda DP |
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 | ||
00c714f0 DP |
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 | }], | |
66a91dda | 194 | |
6f601313 DP |
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 | { | |
f59ac416 | 207 | files: ["**/amd/src/*.js", "**/amd/src/**/*.js", "*.js"], |
c53f86d4 RW |
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', | |
6f601313 DP |
215 | // Check AMD with some slightly stricter rules. |
216 | rules: { | |
217 | 'no-unused-vars': 'error', | |
c53f86d4 RW |
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' | |
6f601313 DP |
246 | } |
247 | } | |
248 | ] | |
3adb62b7 | 249 | } |