Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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