-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.js
More file actions
341 lines (324 loc) · 9.13 KB
/
Copy patheslint.config.js
File metadata and controls
341 lines (324 loc) · 9.13 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
// @ts-check
import { OptionDefaults } from 'typedoc';
import { configs as endoConfigs, hardenedGlobals } from '@endo/eslint-plugin';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import jessieNoNestedAwait from '@jessie.js/eslint-plugin/lib/rules/no-nested-await.js';
import jessieSafeAwaitSeparator from '@jessie.js/eslint-plugin/lib/rules/safe-await-separator.js';
import jessieUseJessieProcessor from '@jessie.js/eslint-plugin/lib/processors/use-jessie.js';
import eslintPluginPlugin from 'eslint-plugin-eslint-plugin';
// The published Jessie config eagerly constructs a legacy FlatCompat instance.
// That instance cannot resolve Endo's restored `eslint:recommended` baseline
// under ESLint 10, so wire the small Jessie flat surface directly instead.
const jessiePlugin = {
meta: { name: '@jessie.js/eslint-plugin', version: '0.4.3' },
rules: {
'no-nested-await': jessieNoNestedAwait,
'safe-await-separator': jessieSafeAwaitSeparator,
},
};
// The Jessie processor predates ESLint's required processor metadata.
// Keep its behavior while supplying the metadata used by `--print-config`.
const jessieProcessor = {
...jessieUseJessieProcessor,
meta: { name: '@jessie.js/use-jessie' },
};
const importResolverSettingsFor = condition => ({
'import/resolver': {
exports: { conditions: [condition] },
node: {},
},
'import-x/resolver': {
exports: { conditions: [condition] },
node: {},
},
});
export default defineConfig(
// jessie config comes first since it imports the "strict" config from @endo/eslint-plugin;
// subsequent configs are applied in order
{
plugins: { '@jessie.js': jessiePlugin },
rules: { '@jessie.js/safe-await-separator': 'warn' },
processor: jessieProcessor,
},
endoConfigs['flat/internal'],
// packages which use the "ses" config scheme
{
files: [
'packages/ses/**',
'packages/env-options/**',
'packages/immutable-arraybuffer/**',
'packages/cache-map/**',
],
extends: [endoConfigs['flat/ses']],
},
// packages which use the "daemon" config scheme
{
files: ['packages/cli/**', 'packages/daemon/**'],
extends: [endoConfigs['flat/daemon']],
},
// override resolution for certain dev deps which are resolved from the workspace root instead
{
files: ['packages/*/test/**', 'packages/**/*.test-d.ts'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/test/**', '**/*.test-d.ts'],
whitelist: ['ava', 'tsd', 'typescript'],
},
],
},
},
// specific to @endo/eslint-plugin
{
files: ['packages/eslint-plugin/**'],
extends: [eslintPluginPlugin.configs.recommended],
},
{
files: ['packages/eslint-plugin/test/**/*.js'],
extends: [eslintPluginPlugin.configs['tests-recommended']],
},
// package-specific export conditions used by resolver fixtures
{
files: ['packages/eventual-send-test/**'],
settings: importResolverSettingsFor('test-endo-eventual-send'),
},
{
files: ['packages/harden-test/**'],
settings: importResolverSettingsFor('test-endo-harden'),
},
{
files: ['packages/hex-test/**'],
settings: importResolverSettingsFor('test-endo-hex'),
},
{
files: ['packages/ses-test/**'],
settings: importResolverSettingsFor('test-endo-ses'),
},
// packages/dirs where Node.js globals are used
{
files: [
'packages/ses-ava/**',
'packages/*/test/**',
'packages/cli/**',
'packages/eslint-plugin/**',
'packages/chat/playwright.config.ts',
'browser-test/**/*',
'packages/compartment-mapper/demo/**',
'**/scripts/**/*',
],
languageOptions: {
globals: { ...hardenedGlobals, ...globals.node },
},
},
// packages whose sources run in a browser realm
{
files: [
'packages/chat/**',
'packages/monaco-wrapper/**',
'packages/preact-container/**',
'packages/space-channel/**',
'packages/space-chat/**',
'packages/space-file-explorer/**',
'packages/space-floot/**',
'packages/space-inventory-graph/**',
'packages/space-peers/**',
'packages/space-whylip/**',
'packages/spaces-util/**',
],
languageOptions: {
globals: { ...hardenedGlobals, ...globals.browser },
},
},
// fork-package policy formerly carried in package.json eslintConfig fields
{
files: ['packages/familiar/**'],
rules: {
'no-restricted-globals': 'off',
},
},
{
files: ['packages/familiar/scripts/*.mjs'],
rules: {
'@endo/harden-exports': 'off',
},
},
{
files: ['packages/goblin-chat/**'],
rules: {
'import/no-unresolved': [
'error',
{ ignore: ['ava', '^@endo/ocapn(?:/.*)?$'] },
],
},
},
{
files: ['packages/module-source/**'],
rules: {
'import/no-unresolved': [
'error',
{ ignore: ['^@endo/module-source(?:/.*)?$'] },
],
'jsdoc/check-tag-names': ['error', { definedTags: ['privateRemarks'] }],
},
},
{
files: ['packages/module-source/**/*.ts'],
rules: {
'vars-on-top': 'off',
'no-var': 'off',
},
},
{
files: ['packages/ocapn-noise/**'],
rules: {
'import/no-unresolved': [
'error',
{
ignore: ['^@endo/ocapn/', '^@endo/ocapn-noise/', '^@endo/ses-ava/'],
},
],
},
},
{
files: ['packages/preact-container/**'],
rules: {
'no-underscore-dangle': 'off',
'no-bitwise': 'off',
'no-continue': 'off',
'no-plusplus': 'off',
'no-control-regex': 'off',
'@endo/restrict-comparison-operands': 'off',
},
},
{
files: ['packages/daemon/src/bus-xs-host-globals.d.ts'],
rules: {
// Ambient declarations intentionally use `declare var` for host globals.
'no-var': 'off',
},
},
{
files: ['packages/compartment-mapper/demo/**'],
rules: {
// The demo resolves its policy fixtures and self-package imports at
// runtime, rather than through the demo directory's package boundary.
'import/no-extraneous-dependencies': 'off',
'no-restricted-globals': 'off',
},
},
{
files: ['packages/*/test/*fixture*/**/*.cjs'],
rules: {
// These fixtures deliberately exercise CommonJS and transpiler output.
camelcase: 'off',
'global-require': 'off',
'no-useless-return': 'off',
'no-var': 'off',
},
},
{
files: [
'packages/preact-container/test/**/*.js',
'packages/preact-container/vitest.config.mjs',
],
languageOptions: {
globals: {
...hardenedGlobals,
...globals.browser,
...globals.node,
describe: 'readonly',
it: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
expect: 'readonly',
},
},
rules: {
'no-undef': 'off',
'no-unused-vars': 'off',
'no-plusplus': 'off',
'no-script-url': 'off',
'no-extend-native': 'off',
'no-restricted-globals': 'off',
'max-classes-per-file': 'off',
'class-methods-use-this': 'off',
'import/no-extraneous-dependencies': 'off',
'no-shadow': 'off',
},
},
// scripts are a little loosey-goosey
{
files: ['scripts/**/*'],
rules: {
'@jessie.js/safe-await-separator': 'off',
'no-await-in-loop': 'off',
'no-continue': 'off',
'no-shadow': 'off',
'no-empty': 'off',
},
},
// force CommonJS
{
files: ['browser-test/**/*'],
languageOptions: {
sourceType: 'script',
},
},
// overrides for tsd tests
{
files: ['**/*.test-d.ts'],
rules: {
'no-useless-assignment': 'off',
'no-restricted-globals': 'off',
'@endo/no-polymorphic-call': 'off',
},
},
// allow any tag supported by TypeDoc
{
files: ['packages/**'],
rules: {
'jsdoc/check-tag-names': [
'error',
{
// these tags from TypeDoc all begin with @ which the eslint plugin
// doesn't expect
definedTags: [
...OptionDefaults.blockTags,
...OptionDefaults.modifierTags,
].map(tag => tag.slice(1)),
inlineTags: OptionDefaults.inlineTags.map(tag => tag.slice(1)),
},
],
},
},
// Repository-wide ignores formerly provided by .eslintignore.
{
ignores: [
'api-docs/',
'rust/',
'**/*.json',
'packages/test262-runner/prelude/',
'packages/chat/test/**/probe.mjs',
'packages/chat/test/**/run.mjs',
'packages/daemon/scripts/*.mjs',
'packages/thixotrope/dist-xs/',
'packages/thixotrope/scripts/*.mjs',
'packages/familiar/preload.mjs',
'packages/git/src/git-askpass-helper.cjs',
'packages/x402/demo/verify.mjs',
'packages/base64/types/',
'packages/bundle-source/scripts/',
'packages/familiar/out/',
'packages/module-source/test/fixtures/',
'packages/module-source/src/external.types.js',
'packages/pass-style/src/types.js',
'packages/nat/integration-test/',
'packages/captp/scripts/',
'packages/marshal/src/bundles/',
'packages/bundle-source/demo/',
'packages/init/**/bundle-*.js',
],
},
);