-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
85 lines (82 loc) · 2.3 KB
/
eslint.config.js
File metadata and controls
85 lines (82 loc) · 2.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
import { builtinModules } from 'node:module';
import js from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import globals from 'globals';
import prettierConfig from 'eslint-config-prettier';
const restrictedBuiltinImports = builtinModules
.filter((name) => !name.startsWith('_') && !name.startsWith('node:'))
.map((name) => ({
name,
message: `Use node:${name} instead of bare builtin imports.`,
}));
export default defineConfig([
globalIgnores([
'**/node_modules/**',
'**/temp/**',
'**/cache/**',
'**/dist/**',
'**/_site/**',
'**/coverage/**',
'**/.vitepress/cache/**',
'**/.vitepress/dist/**',
]),
js.configs.recommended,
prettierConfig,
{
files: ['**/*.{js,mjs}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.node,
URL: 'readonly',
},
},
rules: {
'no-console': 'warn',
'no-debugger': 'error',
'no-duplicate-imports': 'error',
'no-restricted-imports': [
'error',
{
paths: restrictedBuiltinImports,
},
],
'no-restricted-syntax': [
'error',
{
selector: "CallExpression[callee.type='Identifier'][callee.name='require']",
message: 'Use ESM imports instead of require() in module files.',
},
{
selector:
"AssignmentExpression[left.type='MemberExpression'][left.object.type='Identifier'][left.object.name='module'][left.property.type='Identifier'][left.property.name='exports']",
message: 'Use ESM exports instead of module.exports in module files.',
},
{
selector:
"AssignmentExpression[left.type='MemberExpression'][left.object.type='Identifier'][left.object.name='exports']",
message: 'Use ESM named exports instead of exports.* assignments in module files.',
},
],
},
},
{
files: ['**/*.cjs'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
globals: globals.node,
},
rules: {
'no-console': 'warn',
'no-debugger': 'error',
},
},
{
files: ['test/**/*.{js,mjs,cjs}', '**/*.{spec,test}.{js,mjs,cjs}'],
languageOptions: {
globals: globals.mocha,
},
},
]);