2021-03-26 20:16:16 +08:00
|
|
|
|
/** @type {import('eslint').Linter.Config} */
|
|
|
|
|
module.exports = {
|
2021-04-03 18:47:16 +08:00
|
|
|
|
root: true,
|
2021-06-14 01:53:03 +08:00
|
|
|
|
plugins: ['jsdoc', 'regexp'],
|
2021-03-26 20:16:16 +08:00
|
|
|
|
extends: 'eslint:recommended',
|
|
|
|
|
rules: {
|
2021-04-18 22:14:33 +08:00
|
|
|
|
'no-use-before-define': ['error', { 'functions': false, 'classes': false }],
|
|
|
|
|
|
2021-04-18 04:26:40 +08:00
|
|
|
|
// stylistic rules
|
2021-04-18 22:13:48 +08:00
|
|
|
|
'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
|
2021-05-25 18:46:45 +08:00
|
|
|
|
'curly': ['warn', 'all'],
|
2021-05-25 18:49:30 +08:00
|
|
|
|
'eol-last': 'warn',
|
|
|
|
|
'no-multiple-empty-lines': ['warn', { max: 2, maxBOF: 0, maxEOF: 0 }],
|
2021-05-01 20:37:02 +08:00
|
|
|
|
'no-tabs': ['warn', { allowIndentationTabs: true }],
|
2021-04-18 04:35:25 +08:00
|
|
|
|
'no-var': 'error',
|
2021-05-14 18:40:12 +08:00
|
|
|
|
'one-var': ['warn', 'never'],
|
2021-04-18 04:26:40 +08:00
|
|
|
|
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
|
2021-04-18 04:30:39 +08:00
|
|
|
|
'semi': 'warn',
|
2021-04-18 21:55:05 +08:00
|
|
|
|
'wrap-iife': 'warn',
|
2021-04-18 04:26:40 +08:00
|
|
|
|
|
2021-05-14 18:40:12 +08:00
|
|
|
|
// spaces and indentation
|
2021-05-01 20:53:38 +08:00
|
|
|
|
'arrow-spacing': 'warn',
|
|
|
|
|
'block-spacing': 'warn',
|
|
|
|
|
'comma-spacing': 'warn',
|
|
|
|
|
'computed-property-spacing': 'warn',
|
|
|
|
|
'func-call-spacing': 'warn',
|
|
|
|
|
'generator-star-spacing': 'warn',
|
2021-05-14 18:40:12 +08:00
|
|
|
|
'indent': ['warn', 'tab', { SwitchCase: 1 }],
|
2021-05-01 20:53:38 +08:00
|
|
|
|
'key-spacing': 'warn',
|
|
|
|
|
'keyword-spacing': 'warn',
|
|
|
|
|
'no-multi-spaces': ['warn', { ignoreEOLComments: true }],
|
|
|
|
|
'no-trailing-spaces': 'warn',
|
|
|
|
|
'no-whitespace-before-property': 'warn',
|
|
|
|
|
'object-curly-spacing': ['warn', 'always'],
|
|
|
|
|
'rest-spread-spacing': 'warn',
|
|
|
|
|
'semi-spacing': 'warn',
|
|
|
|
|
'space-before-blocks': 'warn',
|
|
|
|
|
'space-before-function-paren': ['warn', { named: 'never' }],
|
|
|
|
|
'space-in-parens': 'warn',
|
|
|
|
|
'space-infix-ops': ['warn', { int32Hint: true }],
|
|
|
|
|
'space-unary-ops': 'warn',
|
|
|
|
|
'switch-colon-spacing': 'warn',
|
|
|
|
|
'template-curly-spacing': 'warn',
|
|
|
|
|
'yield-star-spacing': 'warn',
|
|
|
|
|
|
2021-05-01 20:40:00 +08:00
|
|
|
|
// JSDoc
|
|
|
|
|
'jsdoc/check-alignment': 'warn',
|
|
|
|
|
'jsdoc/check-syntax': 'warn',
|
|
|
|
|
'jsdoc/check-param-names': 'warn',
|
|
|
|
|
'jsdoc/require-hyphen-before-param-description': ['warn', 'never'],
|
|
|
|
|
'jsdoc/check-tag-names': 'warn',
|
|
|
|
|
'jsdoc/check-types': 'warn',
|
|
|
|
|
'jsdoc/empty-tags': 'warn',
|
|
|
|
|
'jsdoc/newline-after-description': 'warn',
|
|
|
|
|
'jsdoc/require-param-name': 'warn',
|
|
|
|
|
'jsdoc/require-property-name': 'warn',
|
|
|
|
|
|
2021-06-14 01:53:03 +08:00
|
|
|
|
// regexp
|
2021-06-18 04:29:51 +08:00
|
|
|
|
'regexp/no-dupe-disjunctions': 'error',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/no-empty-alternative': 'error',
|
2021-08-28 00:41:39 +08:00
|
|
|
|
'regexp/no-empty-capturing-group': 'error',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/no-empty-lookarounds-assertion': 'error',
|
|
|
|
|
'regexp/no-lazy-ends': 'error',
|
|
|
|
|
'regexp/no-obscure-range': 'error',
|
|
|
|
|
'regexp/no-optional-assertion': 'error',
|
|
|
|
|
'regexp/no-standalone-backslash': 'error',
|
2021-08-28 00:41:39 +08:00
|
|
|
|
'regexp/no-super-linear-backtracking': 'error',
|
|
|
|
|
'regexp/no-unused-capturing-group': 'error',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/no-zero-quantifier': 'error',
|
|
|
|
|
'regexp/optimal-lookaround-quantifier': 'error',
|
|
|
|
|
|
|
|
|
|
'regexp/match-any': 'warn',
|
|
|
|
|
'regexp/negation': 'warn',
|
|
|
|
|
'regexp/no-dupe-characters-character-class': 'warn',
|
|
|
|
|
'regexp/no-trivially-nested-assertion': 'warn',
|
|
|
|
|
'regexp/no-trivially-nested-quantifier': 'warn',
|
|
|
|
|
'regexp/no-useless-character-class': 'warn',
|
2021-10-14 20:01:11 +08:00
|
|
|
|
'regexp/no-useless-flag': 'warn',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/no-useless-lazy': 'warn',
|
2021-10-14 20:06:25 +08:00
|
|
|
|
'regexp/no-useless-range': 'warn',
|
2021-10-19 20:27:57 +08:00
|
|
|
|
'regexp/prefer-d': ['warn', { insideCharacterClass: 'ignore' }],
|
2021-10-14 19:59:51 +08:00
|
|
|
|
'regexp/prefer-plus-quantifier': 'warn',
|
|
|
|
|
'regexp/prefer-question-quantifier': 'warn',
|
|
|
|
|
'regexp/prefer-star-quantifier': 'warn',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/prefer-w': 'warn',
|
2021-09-26 17:52:18 +08:00
|
|
|
|
'regexp/sort-alternatives': 'warn',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
'regexp/sort-flags': 'warn',
|
2021-06-27 20:56:07 +08:00
|
|
|
|
'regexp/strict': 'warn',
|
2021-06-14 01:53:03 +08:00
|
|
|
|
|
2021-03-26 20:16:16 +08:00
|
|
|
|
// I turned this rule off because we use `hasOwnProperty` in a lot of places
|
|
|
|
|
// TODO: Think about re-enabling this rule
|
|
|
|
|
'no-prototype-builtins': 'off',
|
|
|
|
|
// TODO: Think about re-enabling this rule
|
|
|
|
|
'no-inner-declarations': 'off',
|
|
|
|
|
// TODO: Think about re-enabling this rule
|
|
|
|
|
'no-sparse-arrays': 'off',
|
|
|
|
|
|
|
|
|
|
// turning off some regex rules
|
|
|
|
|
// these are supposed to protect against accidental use but we need those quite often
|
|
|
|
|
'no-control-regex': 'off',
|
|
|
|
|
'no-empty-character-class': 'off',
|
|
|
|
|
'no-useless-escape': 'off'
|
|
|
|
|
},
|
2021-05-01 20:40:00 +08:00
|
|
|
|
settings: {
|
2021-06-14 01:53:03 +08:00
|
|
|
|
jsdoc: { mode: 'typescript' },
|
|
|
|
|
regexp: {
|
|
|
|
|
// allow alphanumeric and cyrillic ranges
|
|
|
|
|
allowedCharacterRanges: ['alphanumeric', 'а-я', 'А-Я']
|
|
|
|
|
}
|
2021-05-01 20:40:00 +08:00
|
|
|
|
},
|
2021-03-26 20:16:16 +08:00
|
|
|
|
ignorePatterns: [
|
|
|
|
|
'*.min.js',
|
|
|
|
|
'vendor/',
|
|
|
|
|
'docs/',
|
|
|
|
|
'components.js',
|
|
|
|
|
'prism.js',
|
|
|
|
|
'node_modules'
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
overrides: [
|
|
|
|
|
{
|
|
|
|
|
// Languages and plugins
|
|
|
|
|
files: [
|
|
|
|
|
'components/*.js',
|
|
|
|
|
'plugins/*/prism-*.js'
|
|
|
|
|
],
|
|
|
|
|
excludedFiles: 'components/index.js',
|
|
|
|
|
env: {
|
|
|
|
|
browser: true,
|
|
|
|
|
node: true,
|
|
|
|
|
worker: true
|
|
|
|
|
},
|
|
|
|
|
globals: {
|
2022-02-10 19:32:49 +08:00
|
|
|
|
'Prism': true,
|
|
|
|
|
// Allow Set and Map. They are partially supported by IE11
|
|
|
|
|
'Set': true,
|
|
|
|
|
'Map': true
|
2021-04-18 04:35:25 +08:00
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
'no-var': 'off'
|
2021-03-26 20:16:16 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// `loadLanguages` function for Node.js
|
|
|
|
|
files: 'components/index.js',
|
|
|
|
|
env: {
|
|
|
|
|
es6: true,
|
|
|
|
|
node: true
|
|
|
|
|
},
|
|
|
|
|
parserOptions: {
|
|
|
|
|
ecmaVersion: 6
|
|
|
|
|
},
|
|
|
|
|
globals: {
|
|
|
|
|
'Prism': true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// Gulp and Danger
|
|
|
|
|
files: 'dependencies.js',
|
|
|
|
|
env: {
|
|
|
|
|
browser: true,
|
|
|
|
|
node: true
|
2021-04-18 04:35:25 +08:00
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
'no-var': 'off'
|
2021-03-26 20:16:16 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// The scripts that run on our website
|
|
|
|
|
files: 'assets/*.js',
|
|
|
|
|
env: {
|
|
|
|
|
browser: true
|
|
|
|
|
},
|
|
|
|
|
globals: {
|
|
|
|
|
'components': true,
|
|
|
|
|
'getLoader': true,
|
|
|
|
|
'PrefixFree': true,
|
|
|
|
|
'Prism': true,
|
|
|
|
|
'Promise': true,
|
|
|
|
|
'saveAs': true,
|
|
|
|
|
'$': true,
|
|
|
|
|
'$$': true,
|
|
|
|
|
'$u': true
|
2021-04-18 04:35:25 +08:00
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
'no-var': 'off'
|
2021-03-26 20:16:16 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// Test files
|
|
|
|
|
files: 'tests/**',
|
|
|
|
|
env: {
|
|
|
|
|
es6: true,
|
|
|
|
|
mocha: true,
|
|
|
|
|
node: true
|
|
|
|
|
},
|
|
|
|
|
parserOptions: {
|
|
|
|
|
ecmaVersion: 2018
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2021-08-17 02:08:13 +08:00
|
|
|
|
// Gulp, Danger, and benchmark
|
2021-03-26 20:16:16 +08:00
|
|
|
|
files: [
|
|
|
|
|
'gulpfile.js/**',
|
2021-08-17 02:08:13 +08:00
|
|
|
|
'dangerfile.js',
|
|
|
|
|
'benchmark/**',
|
2021-03-26 20:16:16 +08:00
|
|
|
|
],
|
|
|
|
|
env: {
|
|
|
|
|
es6: true,
|
|
|
|
|
node: true
|
|
|
|
|
},
|
|
|
|
|
parserOptions: {
|
|
|
|
|
ecmaVersion: 2018
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// This file
|
|
|
|
|
files: '.eslintrc.js',
|
|
|
|
|
env: {
|
|
|
|
|
node: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
};
|