2016-05-11 10:19:30 +01:00
|
|
|
{
|
2016-12-16 10:13:25 +00:00
|
|
|
'plugins': [
|
2022-03-23 11:40:32 +00:00
|
|
|
'@babel',
|
2016-12-16 10:13:25 +00:00
|
|
|
'promise',
|
2022-03-23 11:40:32 +00:00
|
|
|
'jsdoc'
|
|
|
|
],
|
|
|
|
'extends': [
|
2022-02-01 09:34:00 +00:00
|
|
|
'eslint:recommended',
|
|
|
|
'plugin:promise/recommended'
|
2016-12-16 10:13:25 +00:00
|
|
|
],
|
2016-05-11 10:19:30 +01:00
|
|
|
'env': {
|
|
|
|
'browser': true,
|
2022-08-03 16:46:00 +08:00
|
|
|
// Enable ES6+ features by default.
|
|
|
|
// See http://eslint.org/docs/user-guide/configuring#specifying-environments
|
|
|
|
// Note: The YUI override must exactly match this when disabling the ES6+ version because those features are not supported by Shifter.
|
|
|
|
'es2020': true,
|
2016-05-11 10:19:30 +01:00
|
|
|
'amd': true
|
|
|
|
},
|
|
|
|
'globals': {
|
|
|
|
'M': true,
|
|
|
|
'Y': true
|
|
|
|
},
|
2022-03-23 13:42:22 +00:00
|
|
|
// Warn about unused eslint-disable statements.
|
|
|
|
'reportUnusedDisableDirectives': true,
|
2016-05-11 10:19:30 +01:00
|
|
|
'rules': {
|
|
|
|
// See http://eslint.org/docs/rules/ for all rules and explanations of all
|
2016-06-28 21:03:27 +01:00
|
|
|
// rules.
|
|
|
|
|
2016-05-11 10:19:30 +01:00
|
|
|
// === Possible Errors ===
|
2016-06-28 21:03:27 +01:00
|
|
|
'comma-dangle': 'off',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-console': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-empty': 'warn',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-extra-parens': 'off',
|
|
|
|
'no-prototype-builtins': 'off',
|
|
|
|
'no-unreachable': 'warn',
|
|
|
|
|
|
|
|
// === Best Practices ===
|
|
|
|
// (these mostly match our jshint config)
|
2016-06-28 21:03:27 +01:00
|
|
|
'array-callback-return': 'warn',
|
|
|
|
'block-scoped-var': 'warn',
|
|
|
|
'complexity': 'warn',
|
|
|
|
'consistent-return': 'warn',
|
2016-05-11 10:19:30 +01:00
|
|
|
'curly': 'error',
|
|
|
|
'dot-notation': 'warn',
|
|
|
|
'no-alert': 'warn',
|
|
|
|
'no-caller': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-div-regex': 'error',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-empty-function': 'warn',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-eq-null': 'error',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-eval': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-extend-native': 'error',
|
|
|
|
'no-extra-bind': 'warn',
|
|
|
|
'no-floating-decimal': 'warn',
|
2016-09-01 14:27:11 +01:00
|
|
|
'no-global-assign': 'warn',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-implied-eval': 'error',
|
|
|
|
'no-invalid-this': 'error',
|
|
|
|
'no-iterator': 'error',
|
|
|
|
'no-labels': 'error',
|
|
|
|
'no-loop-func': 'error',
|
|
|
|
'no-multi-spaces': 'warn',
|
|
|
|
'no-multi-str': 'error',
|
|
|
|
'no-new-func': 'error',
|
|
|
|
'no-new-wrappers': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-octal-escape': 'error',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-proto': 'error',
|
|
|
|
'no-redeclare': 'warn',
|
2022-11-25 16:37:04 +00:00
|
|
|
'no-restricted-globals': ['error', { 'name': 'Notification' }],
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-return-assign': 'error',
|
|
|
|
'no-script-url': 'error',
|
|
|
|
'no-self-compare': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-sequences': 'warn',
|
|
|
|
'no-throw-literal': 'warn',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-unmodified-loop-condition': 'error',
|
2016-06-29 16:31:31 +01:00
|
|
|
'no-unused-expressions': 'error',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-useless-call': 'warn',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-useless-escape': 'warn',
|
|
|
|
'wrap-iife': ['error', 'any'],
|
|
|
|
|
|
|
|
// === Variables ===
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-undef-init': 'error',
|
2016-09-01 14:27:11 +01:00
|
|
|
'no-unused-vars': ['error', { 'caughtErrors': 'none' }],
|
2016-05-11 10:19:30 +01:00
|
|
|
|
|
|
|
// === Stylistic Issues ===
|
|
|
|
'array-bracket-spacing': 'warn',
|
|
|
|
'block-spacing': 'warn',
|
|
|
|
'brace-style': ['warn', '1tbs'],
|
|
|
|
'camelcase': 'warn',
|
2017-08-08 11:21:45 +01:00
|
|
|
'capitalized-comments': ['warn', 'always', { 'ignoreConsecutiveComments': true }],
|
2016-05-11 10:19:30 +01:00
|
|
|
'comma-spacing': ['warn', { 'before': false, 'after': true }],
|
|
|
|
'comma-style': ['warn', 'last'],
|
|
|
|
'computed-property-spacing': 'error',
|
|
|
|
'consistent-this': 'off',
|
|
|
|
'eol-last': 'off',
|
2016-09-01 14:27:11 +01:00
|
|
|
'func-call-spacing': ['warn', 'never'],
|
2016-05-11 10:19:30 +01:00
|
|
|
'func-names': 'off',
|
|
|
|
'func-style': 'off',
|
|
|
|
// indent currently not doing well with our wrapping style, so disabled.
|
|
|
|
'indent': ['off', 4, { 'SwitchCase': 1 }],
|
|
|
|
'key-spacing': ['warn', { 'beforeColon': false, 'afterColon': true, 'mode': minimum }],
|
|
|
|
'keyword-spacing': 'warn',
|
|
|
|
'linebreak-style': ['error', 'unix'],
|
|
|
|
'lines-around-comment': 'off',
|
|
|
|
'max-len': ['error', 132],
|
|
|
|
'max-lines': 'off',
|
2016-06-28 21:03:27 +01:00
|
|
|
'max-depth': 'warn',
|
|
|
|
'max-nested-callbacks': ['warn', 5],
|
2016-05-11 10:19:30 +01:00
|
|
|
'max-params': 'off',
|
|
|
|
'max-statements': 'off',
|
2016-06-28 21:03:27 +01:00
|
|
|
'max-statements-per-line': ['warn', { max: 2 }],
|
2016-06-16 19:20:08 +01:00
|
|
|
'new-cap': ['warn', { 'properties': false }],
|
2016-05-11 10:19:30 +01:00
|
|
|
'new-parens': 'warn',
|
2016-06-28 21:03:27 +01:00
|
|
|
'newline-per-chained-call': 'off',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-array-constructor': 'off',
|
|
|
|
'no-bitwise': 'error',
|
|
|
|
'no-continue': 'off',
|
|
|
|
'no-inline-comments': 'off',
|
|
|
|
'no-lonely-if': 'off',
|
|
|
|
'no-mixed-operators': 'off',
|
|
|
|
'no-multiple-empty-lines': 'warn',
|
|
|
|
'no-negated-condition': 'off',
|
|
|
|
'no-nested-ternary': 'warn',
|
|
|
|
'no-new-object': 'off',
|
|
|
|
'no-plusplus': 'off',
|
2016-09-01 14:27:11 +01:00
|
|
|
'no-tabs': 'error',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-ternary': 'off',
|
|
|
|
'no-trailing-spaces': 'error',
|
|
|
|
'no-underscore-dangle': 'off',
|
2016-06-28 21:03:27 +01:00
|
|
|
'no-unneeded-ternary': 'off',
|
2016-05-11 10:19:30 +01:00
|
|
|
'no-whitespace-before-property': 'warn',
|
2016-06-28 21:03:27 +01:00
|
|
|
'object-curly-newline': 'off',
|
|
|
|
'object-curly-spacing': 'warn',
|
|
|
|
'object-property-newline': 'off',
|
2016-05-11 10:19:30 +01:00
|
|
|
'one-var': 'off',
|
2016-06-28 21:03:27 +01:00
|
|
|
'one-var-declaration-per-line': ['warn', 'initializations'],
|
2016-05-11 10:19:30 +01:00
|
|
|
'operator-assignment': 'off',
|
|
|
|
'operator-linebreak': 'off',
|
|
|
|
'padded-blocks': 'off',
|
2016-06-28 21:03:27 +01:00
|
|
|
'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}],
|
2016-05-11 10:19:30 +01:00
|
|
|
'quotes': 'off',
|
|
|
|
'semi': 'error',
|
|
|
|
'semi-spacing': ['warn', {'before': false, 'after': true}],
|
|
|
|
'sort-vars': 'off',
|
|
|
|
'space-before-blocks': 'warn',
|
|
|
|
'space-before-function-paren': ['warn', 'never'],
|
|
|
|
'space-in-parens': 'warn',
|
|
|
|
'space-infix-ops': 'warn',
|
|
|
|
'space-unary-ops': 'warn',
|
|
|
|
'spaced-comment': 'warn',
|
|
|
|
'unicode-bom': 'error',
|
|
|
|
'wrap-regex': 'off',
|
2016-09-01 14:27:11 +01:00
|
|
|
|
2022-02-01 09:34:00 +00:00
|
|
|
// === Promises (override plugin:promise/recommended) ===
|
2016-12-16 10:13:25 +00:00
|
|
|
'promise/always-return': 'warn',
|
|
|
|
'promise/no-return-wrap': 'warn',
|
|
|
|
'promise/param-names': 'warn',
|
2023-05-22 09:09:12 +08:00
|
|
|
'promise/catch-or-return': ['warn', {terminationMethod: ['catch', 'fail', 'always'], allowFinally: true}],
|
2016-12-16 10:13:25 +00:00
|
|
|
'promise/no-native': 'warn',
|
|
|
|
'promise/avoid-new': 'warn',
|
|
|
|
|
2016-09-01 14:27:11 +01:00
|
|
|
// === Deprecations ===
|
|
|
|
"no-restricted-properties": ['warn', {
|
|
|
|
'object': 'M',
|
|
|
|
'property': 'str',
|
2022-03-23 11:40:32 +00:00
|
|
|
'message': 'Use "core/str" module or M.util.get_string()'
|
2016-09-01 14:27:11 +01:00
|
|
|
}],
|
2017-08-08 14:27:55 +01:00
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: ["**/yui/src/**/*.js"],
|
2022-08-03 16:46:00 +08:00
|
|
|
'env': {
|
|
|
|
// Disable ES6+ for YUI files.
|
|
|
|
'es2020': false,
|
|
|
|
},
|
2017-08-08 14:27:55 +01:00
|
|
|
// Disable some rules which we can't safely define for YUI rollups.
|
|
|
|
rules: {
|
|
|
|
'no-undef': 'off',
|
|
|
|
'no-unused-vars': 'off',
|
2021-10-14 16:43:51 +08:00
|
|
|
'no-unused-expressions': 'off',
|
|
|
|
|
|
|
|
// === JSDocs ===
|
|
|
|
"jsdoc/check-access": 'off',
|
|
|
|
"jsdoc/check-alignment": 'off',
|
|
|
|
"jsdoc/check-param-names": 'off',
|
|
|
|
"jsdoc/check-property-names": 'off',
|
|
|
|
"jsdoc/empty-tags": 'off',
|
|
|
|
"jsdoc/implements-on-classes": 'off',
|
|
|
|
"jsdoc/multiline-blocks": 'off',
|
|
|
|
"jsdoc/require-jsdoc": 'off',
|
|
|
|
"jsdoc/require-param": 'off',
|
|
|
|
"jsdoc/require-param-name": 'off',
|
|
|
|
"jsdoc/require-param-type": 'off',
|
|
|
|
"jsdoc/require-property": 'off',
|
|
|
|
"jsdoc/require-property-name": 'off',
|
|
|
|
"jsdoc/require-property-type": 'off',
|
2017-08-08 14:27:55 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-03-15 09:49:39 +08:00
|
|
|
files: ["**/amd/src/*.js", "**/amd/src/**/*.js", "Gruntfile.js", ".grunt/*.js", ".grunt/tasks/*.js", "jsdoc.conf.js"],
|
2018-07-11 15:54:52 +08:00
|
|
|
// We're using babel transpiling so use their parser
|
|
|
|
// for linting.
|
2022-02-18 08:52:45 +08:00
|
|
|
parser: '@babel/eslint-parser',
|
2017-08-08 14:27:55 +01:00
|
|
|
// Check AMD with some slightly stricter rules.
|
|
|
|
rules: {
|
2018-07-11 15:54:52 +08:00
|
|
|
'no-implicit-globals': 'error',
|
|
|
|
// Disable all of the rules that have babel versions.
|
|
|
|
'new-cap': 'off',
|
|
|
|
// Not using this rule for the time being because it isn't
|
|
|
|
// compatible with jQuery and ES6.
|
|
|
|
'no-invalid-this': 'off',
|
|
|
|
'object-curly-spacing': 'off',
|
|
|
|
'quotes': 'off',
|
|
|
|
'semi': 'off',
|
|
|
|
'no-unused-expressions': 'off',
|
|
|
|
// Enable all of the babel version of these rules.
|
2022-03-23 11:40:32 +00:00
|
|
|
'@babel/new-cap': ['warn', { 'properties': false }],
|
2018-07-11 15:54:52 +08:00
|
|
|
// Not using this rule for the time being because it isn't
|
|
|
|
// compatible with jQuery and ES6.
|
2022-03-23 11:40:32 +00:00
|
|
|
'@babel/no-invalid-this': 'off',
|
|
|
|
'@babel/object-curly-spacing': 'warn',
|
|
|
|
'@babel/semi': 'error',
|
|
|
|
'@babel/no-unused-expressions': 'error',
|
2018-07-11 15:54:52 +08:00
|
|
|
// === Promises ===
|
|
|
|
// We have Promise now that we're using ES6.
|
|
|
|
'promise/no-native': 'off',
|
2021-10-14 16:43:51 +08:00
|
|
|
'promise/avoid-new': 'off',
|
|
|
|
|
|
|
|
// === JSDocs ===
|
2022-03-22 20:31:14 +00:00
|
|
|
'jsdoc/check-access': 'error',
|
|
|
|
'jsdoc/check-alignment': 1, // Recommended.
|
|
|
|
'jsdoc/check-param-names': 'error',
|
|
|
|
'jsdoc/check-property-names': 'error',
|
|
|
|
'jsdoc/empty-tags': 'error',
|
|
|
|
'jsdoc/implements-on-classes': 'error',
|
|
|
|
'jsdoc/multiline-blocks': 'error',
|
|
|
|
'jsdoc/require-jsdoc': 'error',
|
|
|
|
'jsdoc/require-param': 'error',
|
|
|
|
'jsdoc/require-param-name': 'error',
|
|
|
|
'jsdoc/require-param-type': 'error',
|
|
|
|
'jsdoc/require-property': 'error',
|
|
|
|
'jsdoc/require-property-name': 'error',
|
|
|
|
'jsdoc/require-property-type': 'error'
|
2018-07-11 15:54:52 +08:00
|
|
|
},
|
|
|
|
parserOptions: {
|
2022-02-18 08:52:45 +08:00
|
|
|
'sourceType': 'module',
|
2022-03-23 11:40:32 +00:00
|
|
|
'requireConfigFile': false
|
2017-08-08 14:27:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2016-05-11 10:19:30 +01:00
|
|
|
}
|