-
Notifications
You must be signed in to change notification settings - Fork 678
Expand file tree
/
Copy patheslint.config.js
More file actions
73 lines (65 loc) · 2.87 KB
/
eslint.config.js
File metadata and controls
73 lines (65 loc) · 2.87 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
const fs = require('fs');
const path = require('path');
const json5 = require('json5');
const js = require('@eslint/js');
const { FlatCompat } = require('@eslint/eslintrc');
const hammerheadPlugin = require('eslint-plugin-hammerhead');
function wrapLegacyRule (rule) {
if (typeof rule !== 'function')
return rule;
return {
meta: {},
create: rule,
};
}
hammerheadPlugin.rules = Object.fromEntries(
Object.entries(hammerheadPlugin.rules).map(([name, rule]) => [name, wrapLegacyRule(rule)])
);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
function readConfig (relativePath) {
return json5.parse(fs.readFileSync(path.join(__dirname, relativePath), 'utf8'));
}
function scopeConfigs (files, configs) {
return configs.map(config => ({
...config,
files,
}));
}
module.exports = [
{
ignores: ['test/server/data/**/*.js'],
},
...compat.config(readConfig('.eslintrc')),
...scopeConfigs(['examples/**/*.js'], compat.config(readConfig('examples/.eslintrc'))),
...scopeConfigs(['src/**/*.{js,ts}'], compat.config(readConfig('src/.eslintrc'))),
...scopeConfigs(['src/cli/**/*.{js,ts}'], compat.config(readConfig('src/cli/.eslintrc'))),
...scopeConfigs(['src/client/**/*.{js,ts}'], compat.config(readConfig('src/client/.eslintrc'))),
...scopeConfigs(['src/client/browser/**/*.{js,ts}'], compat.config(readConfig('src/client/browser/.eslintrc'))),
...scopeConfigs(['test/docker/**/*.js'], compat.config(readConfig('test/docker/.eslintrc'))),
...scopeConfigs(['test/client/**/*.js'], compat.config(readConfig('test/client/.eslintrc'))),
...scopeConfigs(['test/client/fixtures/**/*.js'], compat.config(readConfig('test/client/fixtures/.eslintrc'))),
...scopeConfigs(['test/functional/**/*.js'], compat.config(readConfig('test/functional/.eslintrc'))),
...scopeConfigs(['test/functional/fixtures/**/*.js'], compat.config(readConfig('test/functional/fixtures/.eslintrc'))),
...scopeConfigs(['test/functional/legacy-fixtures/**/*.js'], compat.config(readConfig('test/functional/legacy-fixtures/.eslintrc'))),
...scopeConfigs(['test/server/**/*.js'], compat.config(readConfig('test/server/.eslintrc'))),
{
files: ['src/client/rollup.config.js'],
languageOptions: {
globals: {
__dirname: 'readonly',
__filename: 'readonly',
Buffer: 'readonly',
clearInterval: 'readonly',
clearTimeout: 'readonly',
global: 'readonly',
process: 'readonly',
setInterval: 'readonly',
setTimeout: 'readonly',
},
},
},
];