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