-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patheslint.config.js
More file actions
136 lines (128 loc) · 3.88 KB
/
Copy patheslint.config.js
File metadata and controls
136 lines (128 loc) · 3.88 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import js from '@eslint/js';
import importX from 'eslint-plugin-import-x';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';
// House rule deltas — crypto/reference-port code legitimately needs what
// generic style guides ban. Defined once and shared by every JS/MJS block so
// the rules cannot drift between the source and the tooling that guards it.
const houseRules = {
'prettier/prettier': 'error',
'import-x/extensions': ['error', 'ignorePackages'],
'import-x/namespace': 'off', // parsing issues with TS deps in node_modules
'max-classes-per-file': 'off',
'no-bitwise': 'off',
'no-plusplus': 'off',
'no-param-reassign': 'off',
'no-continue': 'off',
'no-constant-condition': 'off',
'no-shadow': 'off',
'prefer-destructuring': 'off',
'no-use-before-define': ['error', { functions: false }],
};
export default [
// Lint EVERYTHING executable, not just src/test. The fuzz engine + 8
// harnesses, the release tooling, browser-test shims, and the cross-verify
// JS are all code that can carry bugs — `eslint .` covers them in one pass.
// Excluded: build output, vendored/committed artifacts, generated typings
// (checked by `npm run typecheck`), Go modules, and non-JS files.
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'**/*.lcov',
'fuzz-results/**',
'**/fuzz/corpus/**',
'**/*.d.ts',
'**/*.d.mts',
'**/*.d.cts',
'test/types/**', // TypeScript consumer-compile fixtures — `npm run typecheck`
'.github/cross-verify/*-go/**', // Go modules
'**/*.html',
'**/wallaby*.js', // local dev test-runner config, not shipped
'**/wallaby*.cjs',
],
},
js.configs.recommended,
importX.flatConfigs.recommended,
prettierConfig,
// Crypto source + unit tests (ES2020 target, matching the build).
{
files: ['packages/*/src/**/*.js', 'packages/*/test/**/*.js'],
plugins: { prettier },
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.mocha,
...globals.es2020,
},
},
rules: houseRules,
},
// Tooling: fuzz engine + harnesses, release/check scripts, cross-verify
// signers/verifiers, and the config files themselves. Node ESM.
{
files: [
'scripts/**/*.js',
'scripts/**/*.mjs',
'packages/*/fuzz/**/*.mjs',
'.github/cross-verify/**/*.js',
'packages/*/playwright.config.js',
'eslint.config.js',
],
plugins: { prettier },
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
...globals.es2021,
},
},
rules: houseRules,
},
// Browser-test shims + specs run in Chromium via Playwright; they touch
// browser globals and the mocha globals the shim re-exports.
{
files: ['packages/*/browser-tests/**/*.js'],
plugins: { prettier },
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
...globals.es2021,
},
},
rules: houseRules,
},
// CommonJS helpers (node test setup shim).
{
files: ['**/*.cjs'],
plugins: { prettier },
languageOptions: {
ecmaVersion: 2022,
sourceType: 'commonjs',
globals: { ...globals.node },
},
rules: {
'prettier/prettier': 'error',
},
},
// This config file uses the documented `import importX from
// 'eslint-plugin-import-x'; importX.flatConfigs.recommended` pattern; the
// default-vs-named warnings are false positives for that intended usage.
{
files: ['eslint.config.js'],
rules: {
'import-x/no-named-as-default': 'off',
'import-x/no-named-as-default-member': 'off',
},
},
];