2019-07-18 03:27:54 +08:00
|
|
|
module.exports = {
|
2019-07-18 03:30:57 +08:00
|
|
|
env: {
|
|
|
|
es6: true,
|
|
|
|
browser: true,
|
|
|
|
node: true,
|
|
|
|
},
|
2019-07-18 03:27:54 +08:00
|
|
|
extends: [
|
|
|
|
'standard',
|
|
|
|
'plugin:import/errors',
|
|
|
|
'plugin:import/warnings',
|
|
|
|
],
|
|
|
|
plugins: [
|
2020-08-12 19:24:32 +08:00
|
|
|
'html',
|
2019-07-18 03:27:54 +08:00
|
|
|
'unicorn',
|
|
|
|
],
|
|
|
|
settings: {
|
|
|
|
'import/resolver': {
|
2019-07-18 04:11:55 +08:00
|
|
|
node: { extensions: ['.js', '.mjs'] },
|
|
|
|
},
|
2019-07-18 03:27:54 +08:00
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
// import
|
|
|
|
'import/order': 'error',
|
|
|
|
'import/first': 'error',
|
|
|
|
'import/no-mutable-exports': 'error',
|
|
|
|
'import/no-unresolved': 'off',
|
2020-08-22 00:02:01 +08:00
|
|
|
'import/no-absolute-path': 'off',
|
2019-07-18 03:27:54 +08:00
|
|
|
|
|
|
|
// Common
|
2020-08-12 20:08:06 +08:00
|
|
|
semi: [2, 'never'],
|
|
|
|
curly: [2, 'multi-or-nest', 'consistent'],
|
|
|
|
quotes: ['error', 'single'],
|
2019-07-18 03:27:54 +08:00
|
|
|
'no-unused-vars': 'warn',
|
|
|
|
'no-param-reassign': 'off',
|
|
|
|
'array-bracket-spacing': ['error', 'never'],
|
2020-08-12 20:08:06 +08:00
|
|
|
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
2019-07-18 03:27:54 +08:00
|
|
|
'block-spacing': ['error', 'always'],
|
2020-08-12 20:08:06 +08:00
|
|
|
camelcase: 'off',
|
2019-07-18 03:27:54 +08:00
|
|
|
'comma-spacing': ['error', { before: false, after: true }],
|
|
|
|
'comma-style': ['error', 'last'],
|
|
|
|
'comma-dangle': ['error', 'always-multiline'],
|
|
|
|
'no-constant-condition': 'warn',
|
|
|
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
|
|
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
|
|
'no-cond-assign': ['error', 'always'],
|
|
|
|
'func-call-spacing': ['off', 'never'],
|
|
|
|
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
2020-08-12 20:08:06 +08:00
|
|
|
indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
|
2019-07-18 03:27:54 +08:00
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
'DebuggerStatement',
|
|
|
|
'ForInStatement',
|
|
|
|
'LabeledStatement',
|
|
|
|
'WithStatement',
|
|
|
|
],
|
|
|
|
'no-spaced-func': 'error',
|
|
|
|
'object-curly-spacing': ['error', 'always'],
|
|
|
|
'no-return-await': 'off',
|
2020-01-30 16:08:22 +08:00
|
|
|
'space-before-function-paren': ['error', 'never'],
|
2019-07-18 03:27:54 +08:00
|
|
|
|
|
|
|
// es6
|
|
|
|
'no-var': 'error',
|
|
|
|
'prefer-const': ['error', {
|
|
|
|
destructuring: 'any',
|
|
|
|
ignoreReadBeforeAssign: true,
|
|
|
|
}],
|
|
|
|
'prefer-arrow-callback': ['error', {
|
|
|
|
allowNamedFunctions: false,
|
|
|
|
allowUnboundThis: true,
|
|
|
|
}],
|
|
|
|
'object-shorthand': ['error', 'always', {
|
|
|
|
ignoreConstructors: false,
|
|
|
|
avoidQuotes: true,
|
|
|
|
}],
|
|
|
|
'prefer-rest-params': 'error',
|
|
|
|
'prefer-spread': 'error',
|
|
|
|
'prefer-template': 'error',
|
|
|
|
'template-curly-spacing': 'error',
|
|
|
|
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
|
|
|
|
'generator-star-spacing': 'off',
|
|
|
|
|
|
|
|
// best-practice
|
|
|
|
'array-callback-return': 'error',
|
|
|
|
'block-scoped-var': 'error',
|
|
|
|
'consistent-return': 'off',
|
2020-08-12 20:08:06 +08:00
|
|
|
complexity: ['off', 11],
|
|
|
|
eqeqeq: ['error', 'allow-null'],
|
2019-07-18 03:27:54 +08:00
|
|
|
'no-alert': 'warn',
|
|
|
|
'no-case-declarations': 'error',
|
|
|
|
'no-multi-spaces': 'error',
|
|
|
|
'no-multi-str': 'error',
|
|
|
|
'no-with': 'error',
|
|
|
|
'no-void': 'error',
|
|
|
|
'no-useless-escape': 'error',
|
|
|
|
'vars-on-top': 'error',
|
|
|
|
'require-await': 'off',
|
|
|
|
'no-return-assign': 'off',
|
|
|
|
'operator-linebreak': [2, 'before'],
|
|
|
|
|
|
|
|
// unicorns
|
|
|
|
// Pass error message when throwing errors
|
|
|
|
'unicorn/error-message': 'error',
|
|
|
|
// Uppercase regex escapes
|
|
|
|
'unicorn/escape-case': 'error',
|
|
|
|
// Array.isArray instead of instanceof
|
|
|
|
'unicorn/no-array-instanceof': 'error',
|
|
|
|
// Prevent deprecated `new Buffer()`
|
|
|
|
'unicorn/no-new-buffer': 'error',
|
|
|
|
// Keep regex literals safe!
|
|
|
|
'unicorn/no-unsafe-regex': 'off',
|
|
|
|
// Lowercase number formatting for octal, hex, binary (0x12 instead of 0X12)
|
|
|
|
'unicorn/number-literal-case': 'error',
|
|
|
|
// ** instead of Math.pow()
|
|
|
|
'unicorn/prefer-exponentiation-operator': 'error',
|
|
|
|
// includes over indexOf when checking for existence
|
|
|
|
'unicorn/prefer-includes': 'error',
|
|
|
|
// String methods startsWith/endsWith instead of more complicated stuff
|
|
|
|
'unicorn/prefer-starts-ends-with': 'error',
|
|
|
|
// textContent instead of innerText
|
|
|
|
'unicorn/prefer-text-content': 'error',
|
|
|
|
// Enforce throwing type error when throwing error while checking typeof
|
|
|
|
'unicorn/prefer-type-error': 'error',
|
|
|
|
// Use new when throwing error
|
|
|
|
'unicorn/throw-new-error': 'error',
|
2019-07-18 04:11:55 +08:00
|
|
|
},
|
2019-07-18 03:27:54 +08:00
|
|
|
}
|