@lvce-editor/eslint-config 18.16.0 → 19.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +126 -0
  2. package/index.d.ts +2 -0
  3. package/index.js +25 -6
  4. package/package.json +23 -23
package/README.md CHANGED
@@ -45,3 +45,129 @@ rules: {
45
45
  }],
46
46
  }
47
47
  ```
48
+
49
+ The recommended e2e configuration enables `e2e/require-awaited-opfs-cleanup`.
50
+ Create OPFS entries inside `try` and await matching `removeEntry` calls in `finally`;
51
+ use `{ recursive: true }` for directories. Nested entries may share their parent
52
+ directory's recursive cleanup. Writable streams also require an awaited `close()`
53
+ in `finally`, so failed writes and assertions still release test resources.
54
+ Acquisition immediately before the protecting `try` is supported. Conditional,
55
+ unawaited, deferred, mismatched, and unreachable cleanup is rejected.
56
+
57
+ ```ts
58
+ const root = await navigator.storage.getDirectory()
59
+ try {
60
+ const file = await root.getFileHandle('example.txt', { create: true })
61
+ const writable = await file.createWritable()
62
+ try {
63
+ await writable.write('example')
64
+ } finally {
65
+ await writable.close()
66
+ }
67
+ } finally {
68
+ await root.removeEntry('example.txt')
69
+ }
70
+ ```
71
+
72
+ ## E2E test best practices
73
+
74
+ The recommended e2e configuration also enables these rules for files under `e2e/`:
75
+
76
+ | Rule | Enforces |
77
+ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
78
+ | `e2e/require-name-matches-filename` | `export const name` equals the file name without its extension, so failures point at the right file and names stay unique. Auto-fixable. |
79
+ | `e2e/no-manual-retry` | No polling loops (loops that `await` and then `break`, or loop until `Date.now()` reaches a deadline) and no `expect(...)` inside a `try`/`catch` whose `catch` does not rethrow. `expect(...)` already retries on its own. |
80
+ | `e2e/no-sleep-command` | No `Command.execute('Timeout.sleep', ...)`. Like `e2e/no-timeouts`, wait for an observable condition instead. |
81
+ | `e2e/require-assertion` | Each exported `test` function calls `expect(...)`, a `should*` API such as `ClipBoard.shouldHaveText(...)`, an `assert*`/`verify*`/`waitFor*` helper, a helper that receives `expect`, or `throw`s on failure. Empty placeholder tests are reported. |
82
+ | `e2e/require-skip-reason` | An enabled `export const skip` has a comment directly above it or at the end of its line saying why. |
83
+ | `e2e/prefer-settings-update` | `Settings.update(settings)` instead of `Command.execute('Preferences.update', settings)`. Auto-fixable when `Settings` is in scope. |
84
+ | `e2e/no-text-selector` | No `text=` selectors, which match any element on the page. Scope the locator by class or attribute, or pass `{ hasText }`. |
85
+ | `e2e/no-nth-css-pseudo` | No `:nth-child(...)` or `:nth-of-type(...)` in locator selectors. Use `.nth(index)` assigned to a descriptive variable. |
86
+ | `e2e/no-first-last` | No `.first()` or `.last()` on locators, which hide duplicated elements. Make the selector unique instead. |
87
+ | `e2e/no-hardcoded-workspace-uri` | Files that call `FileSystem.getTmpDir()` build URIs from its result instead of hardcoding `memfs://` URIs. |
88
+
89
+ Assertions made through a helper with a different name can be allowed explicitly:
90
+
91
+ ```js
92
+ rules: {
93
+ 'e2e/require-assertion': ['error', { assertionFunctions: ['checkEditorContent'] }],
94
+ }
95
+ ```
96
+
97
+ ```ts
98
+ // webkit does not grant clipboard permissions in CI
99
+ export const skip = ['webkit']
100
+
101
+ export const test: Test = async ({ expect, FileSystem, Locator, Workspace }) => {
102
+ const tmpDir = await FileSystem.getTmpDir()
103
+ await FileSystem.setFiles([{ content: '', uri: `${tmpDir}/file1.txt` }])
104
+ await Workspace.setUri(tmpDir)
105
+ const file1 = Locator('.TreeItem[aria-label="file1.txt"]')
106
+ await expect(file1).toBeVisible()
107
+ }
108
+ ```
109
+
110
+ The default configuration includes type-aware extension provider checks. The
111
+ `recommendedExtension` export also provides these checks as a standalone preset:
112
+
113
+ ```js
114
+ import * as config from '@lvce-editor/eslint-config'
115
+
116
+ export default [...config.default]
117
+ ```
118
+
119
+ This preset uses the TypeScript parser and project service configured by the
120
+ shared default configuration. When using it on its own, configure
121
+ `typescript-eslint` with `parserOptions.projectService: true`.
122
+
123
+ `extension/no-empty-optional-provider-method` reports optional methods declared
124
+ by `@lvce-editor/api` provider interfaces whose result explicitly allows
125
+ `undefined`, when their implementation is empty or
126
+ only returns `undefined` (including async methods and arrow functions). For
127
+ example, omit `CompletionProvider.resolveCompletionItem` when there is nothing
128
+ to resolve. Required methods, optional `void` methods, untyped objects, and methods that return a value
129
+ or do work are left alone. The rule deliberately provides no automatic fix:
130
+ removing a method can affect code that inspects a provider's properties.
131
+
132
+ ## TypeScript strictness
133
+
134
+ The default configuration enables:
135
+
136
+ - `@typescript-eslint/switch-exhaustiveness-check`: a `switch` over a union must handle every member, or have a
137
+ `default` case. Switches over non-union values don't need a `default`.
138
+ - `@typescript-eslint/ban-ts-comment`: use `// @ts-expect-error -- reason` instead of `@ts-ignore` or
139
+ `@ts-nocheck`. Unlike `@ts-ignore`, TypeScript reports an `@ts-expect-error` that is no longer needed.
140
+ - `@typescript-eslint/no-explicit-any`: use a precise type, a generic, or `unknown` instead of `any`.
141
+
142
+ ## GitHub Actions, tsconfig, .nvmrc and virtual-dom rules
143
+
144
+ | Rule | Preset | Enforces |
145
+ | -------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
146
+ | `github-actions/cache-key-includes-arch` | `recommendedActions` | `node_modules` cache keys include `${{ runner.arch }}`, because `runner.os` is the same on x64 and arm runners. Auto-fix. |
147
+ | `github-actions/upload-artifact-if-no-files-found` | `recommendedActions` | `actions/upload-artifact` sets `if-no-files-found: error`, so a wrong path fails instead of warning. Auto-fix. |
148
+ | `github-actions/no-deprecated-actions` | `recommendedActions` | No archived actions such as `actions/upload-release-asset`. Extend the list with the `deprecated` option. |
149
+ | `tsconfig/no-fallthrough-cases-in-switch` | `recommendedTsconfig` | `noFallthroughCasesInSwitch: true`. |
150
+ | `tsconfig/lib-replacement` | `recommendedTsconfig` | `libReplacement: false`, so TypeScript doesn't look up `@typescript/lib-*` packages. |
151
+ | `tsconfig/consistent-option-casing` | `recommendedTsconfig` | Lowercase values for `target`, `module`, `moduleResolution`, `lib` and similar options, as `tsc --init` writes them. Auto-fix. |
152
+ | `tsconfig/no-unchecked-indexed-access` | off, opt in | `noUncheckedIndexedAccess: true`. Off by default because adopting it usually needs many code changes. |
153
+ | `nvmrc/format` | `recommendedNvmrc` | `.nvmrc` contains only the version, such as `26.12.1`, without a `v` prefix. Auto-fix. |
154
+ | `nvmrc/engines-match-nvmrc` | `recommendedNvmrc` | The nearest `.nvmrc` version satisfies `package.json` `engines.node`, and the range doesn't allow Node.js older than `minimumVersion` (default `20.0.0`). |
155
+ | `virtual-dom/no-hardcoded-ui-strings` | `recommendedVirtualDom` | No string literals in `ariaLabel`, `title`, `placeholder`, `alt`, `text` and similar properties, or in `text(...)`. Use a strings module. Off in test files. |
156
+ | `virtual-dom/no-nondeterministic-render` | `recommendedVirtualDom` | No `Date.now()`, `new Date()`, `Math.random()`, `performance.now()` or `crypto.randomUUID()` in functions that build virtual-dom nodes. Off in test files. |
157
+
158
+ To opt in to `noUncheckedIndexedAccess`:
159
+
160
+ ```js
161
+ import * as config from '@lvce-editor/eslint-config'
162
+
163
+ export default [
164
+ ...config.default,
165
+ ...config.recommendedTsconfig,
166
+ {
167
+ files: ['**/tsconfig.json'],
168
+ rules: {
169
+ 'tsconfig/no-unchecked-indexed-access': 'error',
170
+ },
171
+ },
172
+ ]
173
+ ```
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ declare const recommendedVirtualDom: readonly any[]
8
8
  declare const recommendedVirtualDomStrict: readonly any[]
9
9
  declare const recommendedE2e: readonly any[]
10
10
  declare const recommendedDevcontainer: readonly any[]
11
+ declare const recommendedExtension: readonly any[]
11
12
  declare const recommendedExtensionJson: readonly any[]
12
13
  declare const recommendedRpc: readonly any[]
13
14
  declare const recommendedEslintConfig: readonly any[]
@@ -21,6 +22,7 @@ export { recommendedVirtualDom }
21
22
  export { recommendedVirtualDomStrict }
22
23
  export { recommendedE2e }
23
24
  export { recommendedDevcontainer }
25
+ export { recommendedExtension }
24
26
  export { recommendedExtensionJson }
25
27
  export { recommendedRpc }
26
28
  export { recommendedEslintConfig }
package/index.js CHANGED
@@ -27,10 +27,10 @@ import * as e2ePlugin from '@lvce-editor/eslint-plugin-e2e'
27
27
 
28
28
  import * as devcontainerPlugin from '@lvce-editor/eslint-plugin-devcontainer'
29
29
 
30
- import * as extensionJsonPlugin from '@lvce-editor/eslint-plugin-extension-json'
31
-
32
30
  import * as rpcPlugin from '@lvce-editor/eslint-plugin-rpc'
33
31
 
32
+ import * as extensionPlugin from '@lvce-editor/eslint-plugin-extension-json'
33
+
34
34
  const root = process.cwd()
35
35
 
36
36
  /**
@@ -74,6 +74,7 @@ const defaultConfig = tseslint.config(
74
74
  'Iconreplace',
75
75
  'Poiner',
76
76
  'barfoo',
77
+ 'buildx',
77
78
  'offscreencanvas',
78
79
  'ylet',
79
80
  'Consolas',
@@ -323,10 +324,25 @@ const defaultConfig = tseslint.config(
323
324
  'no-console': ['error', { allow: ['warn', 'error'] }],
324
325
  'prefer-destructuring': ['error', { object: true, array: false }],
325
326
  '@typescript-eslint/no-deprecated': 'error',
327
+ '@typescript-eslint/switch-exhaustiveness-check': [
328
+ 'error',
329
+ {
330
+ considerDefaultExhaustiveForUnions: true,
331
+ requireDefaultForNonUnion: false,
332
+ },
333
+ ],
334
+ '@typescript-eslint/ban-ts-comment': [
335
+ 'error',
336
+ {
337
+ 'ts-check': false,
338
+ 'ts-expect-error': 'allow-with-description',
339
+ 'ts-ignore': true,
340
+ 'ts-nocheck': true,
341
+ },
342
+ ],
343
+ '@typescript-eslint/no-explicit-any': 'error',
326
344
 
327
345
  // off
328
- '@typescript-eslint/no-explicit-any': 'off',
329
- '@typescript-eslint/ban-ts-comment': 'off',
330
346
  '@typescript-eslint/no-unsafe-member-access': 'off',
331
347
  '@typescript-eslint/no-unsafe-assignment': 'off',
332
348
  '@typescript-eslint/no-unsafe-call': 'off',
@@ -519,7 +535,8 @@ const defaultConfig = tseslint.config(
519
535
  ...virtualDomPlugin.recommendedDependencies,
520
536
  ...e2ePlugin.default,
521
537
  ...devcontainerPlugin.default,
522
- ...extensionJsonPlugin.default,
538
+ ...extensionPlugin.recommendedExtensionJson,
539
+ ...extensionPlugin.default,
523
540
  ...rpcPlugin.default,
524
541
  ...eslintConfigPlugin.default,
525
542
  )
@@ -557,7 +574,9 @@ export const recommendedE2e = [...e2ePlugin.default]
557
574
 
558
575
  export const recommendedDevcontainer = [...devcontainerPlugin.default]
559
576
 
560
- export const recommendedExtensionJson = [...extensionJsonPlugin.default]
577
+ export const recommendedExtension = [...extensionPlugin.default]
578
+
579
+ export const recommendedExtensionJson = [...extensionPlugin.recommendedExtensionJson]
561
580
 
562
581
  export const recommendedRpc = [...rpcPlugin.default]
563
582
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-config",
3
- "version": "18.16.0",
3
+ "version": "19.0.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",
@@ -22,29 +22,29 @@
22
22
  "homepage": "https://github.com/lvce-editor/eslint-config#readme",
23
23
  "description": "Shared ESLint configuration for Lvce Editor projects.",
24
24
  "dependencies": {
25
- "@cspell/eslint-plugin": "10.0.1",
26
- "@e18e/eslint-plugin": "^0.5.1",
25
+ "@cspell/eslint-plugin": "10.7.0",
26
+ "@e18e/eslint-plugin": "^0.8.1",
27
27
  "@eslint/js": "10.0.1",
28
- "@eslint/json": "2.0.1",
29
- "@eslint/markdown": "8.0.3",
30
- "eslint-plugin-jest": "29.15.4",
31
- "eslint-plugin-n": "18.2.1",
32
- "eslint-plugin-package-json": "1.5.0",
33
- "eslint-plugin-perfectionist": "5.10.0",
34
- "eslint-plugin-sonarjs": "4.1.0",
35
- "eslint-plugin-unicorn": "71.1.0",
36
- "eslint-plugin-yml": "3.6.0",
37
- "typescript-eslint": "8.63.0",
38
- "@lvce-editor/eslint-plugin-eslint-config": "18.16.0",
39
- "@lvce-editor/eslint-plugin-tsconfig": "18.16.0",
40
- "@lvce-editor/eslint-plugin-github-actions": "18.16.0",
41
- "@lvce-editor/eslint-plugin-nvmrc": "18.16.0",
42
- "@lvce-editor/eslint-plugin-regex": "18.16.0",
43
- "@lvce-editor/eslint-plugin-virtual-dom": "18.16.0",
44
- "@lvce-editor/eslint-plugin-e2e": "18.16.0",
45
- "@lvce-editor/eslint-plugin-devcontainer": "18.16.0",
46
- "@lvce-editor/eslint-plugin-extension-json": "18.16.0",
47
- "@lvce-editor/eslint-plugin-rpc": "18.16.0"
28
+ "@eslint/json": "2.1.1",
29
+ "@eslint/markdown": "9.0.0",
30
+ "eslint-plugin-jest": "29.17.2",
31
+ "eslint-plugin-n": "18.6.0",
32
+ "eslint-plugin-package-json": "1.14.0",
33
+ "eslint-plugin-perfectionist": "5.14.0",
34
+ "eslint-plugin-sonarjs": "4.2.3",
35
+ "eslint-plugin-unicorn": "80.0.0",
36
+ "eslint-plugin-yml": "3.10.1",
37
+ "typescript-eslint": "8.74.0",
38
+ "@lvce-editor/eslint-plugin-extension-json": "19.0.1",
39
+ "@lvce-editor/eslint-plugin-eslint-config": "19.0.1",
40
+ "@lvce-editor/eslint-plugin-tsconfig": "19.0.1",
41
+ "@lvce-editor/eslint-plugin-github-actions": "19.0.1",
42
+ "@lvce-editor/eslint-plugin-nvmrc": "19.0.1",
43
+ "@lvce-editor/eslint-plugin-regex": "19.0.1",
44
+ "@lvce-editor/eslint-plugin-virtual-dom": "19.0.1",
45
+ "@lvce-editor/eslint-plugin-e2e": "19.0.1",
46
+ "@lvce-editor/eslint-plugin-devcontainer": "19.0.1",
47
+ "@lvce-editor/eslint-plugin-rpc": "19.0.1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "eslint": ">=10.0.0 <11.0.0-0"