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