@lvce-editor/eslint-config 19.0.1 → 19.1.0
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.
- package/README.md +49 -0
- package/index.d.ts +18 -14
- package/index.js +14 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -69,6 +69,41 @@ try {
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
## Declared dependencies
|
|
73
|
+
|
|
74
|
+
The default configuration enables `n/no-extraneous-import`: every imported package must be declared in a `package.json`
|
|
75
|
+
of the project. In npm workspaces, the root and every workspace package count. Packages that are only installed as
|
|
76
|
+
a transitive dependency, such as `@jest/globals` through `jest`, are reported.
|
|
77
|
+
|
|
78
|
+
## RPC packages
|
|
79
|
+
|
|
80
|
+
`rpc/no-low-level-rpc-packages` (default config) reports imports of `@lvce-editor/ipc` and `@lvce-editor/json-rpc`.
|
|
81
|
+
Use `@lvce-editor/rpc`, which wraps both. For known classes the message names the replacement, for example
|
|
82
|
+
`IpcParentWithNodeWorker` → `NodeWorkerRpcParent`. The `rpc` package itself can allow them:
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
rules: {
|
|
86
|
+
'rpc/no-low-level-rpc-packages': ['error', { allow: ['@lvce-editor/ipc', '@lvce-editor/json-rpc'] }],
|
|
87
|
+
'virtual-dom/no-restricted-dependencies': ['error', { restrictions: { '@lvce-editor/ipc': '*', '@lvce-editor/json-rpc': '*' } }],
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`virtual-dom/no-restricted-dependencies` also forbids these two packages in `package.json`, and requires
|
|
92
|
+
`@lvce-editor/rpc` `>=6.0.0`, `@lvce-editor/rpc-registry` `>=9.0.0` and `@lvce-editor/virtual-dom-worker` `>=11.0.0`.
|
|
93
|
+
|
|
94
|
+
## RPC calls
|
|
95
|
+
|
|
96
|
+
Both rules are in the default config.
|
|
97
|
+
|
|
98
|
+
- `rpc/prefer-registry-method` reports `X.invoke('Command.id', ...)` when `X` is imported from `@lvce-editor/rpc-registry`
|
|
99
|
+
and the registry has a wrapper that passes its parameters straight through, for example
|
|
100
|
+
`RendererWorker.invoke('Preferences.get', key)` → `RendererWorker.getPreference(key)`. It auto-fixes when the argument
|
|
101
|
+
count matches the wrapper. The wrapper table is generated from a published `@lvce-editor/rpc-registry` version; update it with
|
|
102
|
+
`npm run update-rpc-registry-methods [version]`.
|
|
103
|
+
- `rpc/no-manual-json-rpc-messages` reports hand-built `{ jsonrpc: '2.0', method: 'Namespace.method', ... }` objects. Use
|
|
104
|
+
`rpc.send(...)` or `rpc.invoke(...)` from `@lvce-editor/rpc`. Messages for other protocols, such as Language Server Protocol
|
|
105
|
+
methods like `initialize` or `textDocument/didOpen`, are not reported.
|
|
106
|
+
|
|
72
107
|
## E2E test best practices
|
|
73
108
|
|
|
74
109
|
The recommended e2e configuration also enables these rules for files under `e2e/`:
|
|
@@ -139,6 +174,19 @@ The default configuration enables:
|
|
|
139
174
|
`@ts-nocheck`. Unlike `@ts-ignore`, TypeScript reports an `@ts-expect-error` that is no longer needed.
|
|
140
175
|
- `@typescript-eslint/no-explicit-any`: use a precise type, a generic, or `unknown` instead of `any`.
|
|
141
176
|
|
|
177
|
+
## Unit tests
|
|
178
|
+
|
|
179
|
+
The default configuration enables `unit-test/no-real-timers` for `**/*.test.ts` (also available on its own as
|
|
180
|
+
`recommendedUnitTest`). It reports `setTimeout` and `setInterval` calls, including `globalThis.setTimeout` and
|
|
181
|
+
`await setTimeout(ms)` from `node:timers/promises`, because waiting for real time makes tests slow and flaky. Await the
|
|
182
|
+
promise or event under test instead. Files that call `jest.useFakeTimers()` are not checked, since their timers don't
|
|
183
|
+
wait for real time.
|
|
184
|
+
|
|
185
|
+
## .nvmrc version defaults
|
|
186
|
+
|
|
187
|
+
`nvmrc/valid-version` accepts `20.0.0` up to `26.14.0` by default, and `nvmrc/insecure-version` rejects releases affected by
|
|
188
|
+
CVE-2026-111497. The default maximum is a release that both rules accept, so `recommendedNvmrc` works without options.
|
|
189
|
+
|
|
142
190
|
## GitHub Actions, tsconfig, .nvmrc and virtual-dom rules
|
|
143
191
|
|
|
144
192
|
| Rule | Preset | Enforces |
|
|
@@ -152,6 +200,7 @@ The default configuration enables:
|
|
|
152
200
|
| `tsconfig/no-unchecked-indexed-access` | off, opt in | `noUncheckedIndexedAccess: true`. Off by default because adopting it usually needs many code changes. |
|
|
153
201
|
| `nvmrc/format` | `recommendedNvmrc` | `.nvmrc` contains only the version, such as `26.12.1`, without a `v` prefix. Auto-fix. |
|
|
154
202
|
| `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`). |
|
|
203
|
+
| `virtual-dom/no-element-helper` (extended) | `recommendedVirtualDom` | No tree helpers that take a `VirtualDomElements.*` type: `element(...)`, and local `node(...)` / `Dom.node(...)` helpers. Build flat node arrays instead. |
|
|
155
204
|
| `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
205
|
| `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
206
|
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
1
|
+
import type { Linter } from 'eslint'
|
|
2
|
+
|
|
3
|
+
declare const config: readonly Linter.Config[]
|
|
4
|
+
declare const recommendedNode: readonly Linter.Config[]
|
|
5
|
+
declare const recommendedTsconfig: readonly Linter.Config[]
|
|
6
|
+
declare const recommendedActions: readonly Linter.Config[]
|
|
7
|
+
declare const recommendedNvmrc: readonly Linter.Config[]
|
|
8
|
+
declare const recommendedRegex: readonly Linter.Config[]
|
|
9
|
+
declare const recommendedVirtualDom: readonly Linter.Config[]
|
|
10
|
+
declare const recommendedVirtualDomStrict: readonly Linter.Config[]
|
|
11
|
+
declare const recommendedE2e: readonly Linter.Config[]
|
|
12
|
+
declare const recommendedUnitTest: readonly Linter.Config[]
|
|
13
|
+
declare const recommendedDevcontainer: readonly Linter.Config[]
|
|
14
|
+
declare const recommendedExtension: readonly Linter.Config[]
|
|
15
|
+
declare const recommendedExtensionJson: readonly Linter.Config[]
|
|
16
|
+
declare const recommendedRpc: readonly Linter.Config[]
|
|
17
|
+
declare const recommendedEslintConfig: readonly Linter.Config[]
|
|
15
18
|
|
|
16
19
|
export { recommendedNode }
|
|
17
20
|
export { recommendedTsconfig }
|
|
@@ -21,6 +24,7 @@ export { recommendedRegex }
|
|
|
21
24
|
export { recommendedVirtualDom }
|
|
22
25
|
export { recommendedVirtualDomStrict }
|
|
23
26
|
export { recommendedE2e }
|
|
27
|
+
export { recommendedUnitTest }
|
|
24
28
|
export { recommendedDevcontainer }
|
|
25
29
|
export { recommendedExtension }
|
|
26
30
|
export { recommendedExtensionJson }
|
package/index.js
CHANGED
|
@@ -532,8 +532,20 @@ const defaultConfig = tseslint.config(
|
|
|
532
532
|
'e18e/ban-dependencies': 'off',
|
|
533
533
|
},
|
|
534
534
|
},
|
|
535
|
+
{
|
|
536
|
+
// Imported packages must be declared in a package.json of the project (in npm workspaces, any workspace
|
|
537
|
+
// package or the root counts), instead of only being installed as a transitive dependency.
|
|
538
|
+
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
|
|
539
|
+
plugins: {
|
|
540
|
+
n: nodePlugin,
|
|
541
|
+
},
|
|
542
|
+
rules: {
|
|
543
|
+
'n/no-extraneous-import': 'error',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
535
546
|
...virtualDomPlugin.recommendedDependencies,
|
|
536
547
|
...e2ePlugin.default,
|
|
548
|
+
...e2ePlugin.recommendedUnitTest,
|
|
537
549
|
...devcontainerPlugin.default,
|
|
538
550
|
...extensionPlugin.recommendedExtensionJson,
|
|
539
551
|
...extensionPlugin.default,
|
|
@@ -572,6 +584,8 @@ export const recommendedVirtualDomStrict = [...virtualDomPlugin.strict]
|
|
|
572
584
|
|
|
573
585
|
export const recommendedE2e = [...e2ePlugin.default]
|
|
574
586
|
|
|
587
|
+
export const recommendedUnitTest = [...e2ePlugin.recommendedUnitTest]
|
|
588
|
+
|
|
575
589
|
export const recommendedDevcontainer = [...devcontainerPlugin.default]
|
|
576
590
|
|
|
577
591
|
export const recommendedExtension = [...extensionPlugin.default]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/eslint-config",
|
|
3
|
-
"version": "19.0
|
|
3
|
+
"version": "19.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"eslint-plugin-unicorn": "80.0.0",
|
|
36
36
|
"eslint-plugin-yml": "3.10.1",
|
|
37
37
|
"typescript-eslint": "8.74.0",
|
|
38
|
-
"@lvce-editor/eslint-plugin-extension-json": "19.0
|
|
39
|
-
"@lvce-editor/eslint-plugin-eslint-config": "19.0
|
|
40
|
-
"@lvce-editor/eslint-plugin-tsconfig": "19.0
|
|
41
|
-
"@lvce-editor/eslint-plugin-github-actions": "19.0
|
|
42
|
-
"@lvce-editor/eslint-plugin-nvmrc": "19.0
|
|
43
|
-
"@lvce-editor/eslint-plugin-regex": "19.0
|
|
44
|
-
"@lvce-editor/eslint-plugin-virtual-dom": "19.0
|
|
45
|
-
"@lvce-editor/eslint-plugin-e2e": "19.0
|
|
46
|
-
"@lvce-editor/eslint-plugin-devcontainer": "19.0
|
|
47
|
-
"@lvce-editor/eslint-plugin-rpc": "19.0
|
|
38
|
+
"@lvce-editor/eslint-plugin-extension-json": "19.1.0",
|
|
39
|
+
"@lvce-editor/eslint-plugin-eslint-config": "19.1.0",
|
|
40
|
+
"@lvce-editor/eslint-plugin-tsconfig": "19.1.0",
|
|
41
|
+
"@lvce-editor/eslint-plugin-github-actions": "19.1.0",
|
|
42
|
+
"@lvce-editor/eslint-plugin-nvmrc": "19.1.0",
|
|
43
|
+
"@lvce-editor/eslint-plugin-regex": "19.1.0",
|
|
44
|
+
"@lvce-editor/eslint-plugin-virtual-dom": "19.1.0",
|
|
45
|
+
"@lvce-editor/eslint-plugin-e2e": "19.1.0",
|
|
46
|
+
"@lvce-editor/eslint-plugin-devcontainer": "19.1.0",
|
|
47
|
+
"@lvce-editor/eslint-plugin-rpc": "19.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"eslint": ">=10.0.0 <11.0.0-0"
|