Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
100 lines (99 loc) · 3.3 KB
/
Copy patheslint.config.js
File metadata and controls
100 lines (99 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const globals = require('globals');
const hexo = require('eslint-config-hexo/eslint');
const json = require('eslint-plugin-json');
const mocha = require('eslint-plugin-mocha');
const react = require('eslint-plugin-react');
module.exports = [
{
ignores: ['node_modules/', 'test/.tmp/', 'package-lock.json', 'source/js/pjax-core.js']
},
...hexo.map(config => Object.assign({ files: ['**/*.js', '**/*.jsx'] }, config)),
{
files: ['**/*.js', '**/*.jsx'],
plugins: { react },
languageOptions: {
ecmaVersion: 'latest',
// As before the flat config: no 'use strict' required in CommonJS files.
sourceType: 'module',
parserOptions: {
ecmaFeatures: { jsx: true }
}
},
settings: {
react: { version: '16.0' },
n: { tryExtensions: ['.js', '.jsx', '.json'] }
},
rules: {
...react.configs.flat.recommended.rules,
'indent': ['error', 4, { SwitchCase: 1 }],
// ESLint 8 behaviour: unused `catch (e)` bindings are fine
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],
'react/jsx-uses-vars': 'error',
'react/no-unknown-property': ['error', {
ignore: ['class', 'onclick', 'onload', 'onsubmit', 'onerror', 'crossorigin']
}],
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'react/display-name': 'off',
'react/jsx-key': 'off',
'react/jsx-no-target-blank': ['error', { allowReferrer: true }]
}
},
// Scripts that run in the browser
{
files: ['source/js/**/*.js'],
languageOptions: {
globals: { ...globals.browser, ...globals.jquery }
},
rules: {
'n/no-unsupported-features/node-builtins': 'off'
}
},
// Test suite (needs a newer Node.js than the theme itself)
{
files: ['test/**/*.js'],
settings: {
n: { version: '>=20.19.0' }
},
rules: {
'n/no-unpublished-require': 'off',
// stable in practice on the Node.js versions the tests run on
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['fs.cpSync'] }]
}
},
// mocha test files
{
files: ['test/unit/**/*.test.js', 'test/integration/**/*.test.js'],
plugins: { mocha },
languageOptions: {
globals: { ...globals.mocha }
},
rules: {
...mocha.configs.flat.recommended.rules,
'mocha/no-mocha-arrows': 'off',
'mocha/max-top-level-suites': 'off',
// tests are generated from data tables inside describe()
'mocha/no-setup-in-describe': 'off'
}
},
{
files: ['test/support/known-bug.js'],
languageOptions: {
globals: { ...globals.mocha }
}
},
{
files: ['test/e2e/**/*.js'],
languageOptions: {
globals: { ...globals.browser }
},
rules: {
// page.evaluate() callbacks run in the browser
'n/no-unsupported-features/node-builtins': 'off'
}
},
{
files: ['**/*.json'],
...json.configs.recommended
}
];