@zukhruf/eslint 0.6.13 → 0.6.14
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 +5 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -59,7 +59,11 @@ Put framework configs (for example [`@zukhruf/eslint/react`](#react)) **before**
|
|
|
59
59
|
|
|
60
60
|
`zukhruf/no-promise-field` reads each class field's type, so it also sees a promise behind an alias, in a type argument (`Map<string, Promise<X>>`, `Record<string, Promise<X>>`), in a union or an intersection, in a `PromiseWithResolvers`, or inferred from the initializer. It also looks inside a record that the project declares, such as `Map<string, { key: string; answer: Promise<boolean> }>`, up to four properties deep. It stops at a class, because the rule checks the fields of that class on their own, and at a library's type, because its promises belong to the library. A field that holds a function returning a promise is fine: that is a memoized function. A record of functions that settle a promise, `{ resolve, reject }`, is fine too: the caller keeps the promise. To wait until something has happened, use a state object or a one-shot latch. See [ADR 0006](./docs/adr/0006-no-promise-field-stops-at-the-class-boundary.md).
|
|
61
61
|
|
|
62
|
-
`zukhruf/no-phase-flag` reads each class field's type too. It reports a field that is a boolean, or that can be `undefined`, when code outside the constructor sets it. A callback that the constructor creates runs later, so its assignment counts as outside. Such a field records a phase, and every reader must know which phase holds. Push the fact as an event, wait on a one-shot latch, keep the phases in state objects, or ask the platform for the fact.
|
|
62
|
+
`zukhruf/no-phase-flag` reads each class field's type too. It reports a field that is a boolean, or that can be `undefined` or `null`, when code outside the constructor sets it. A callback that the constructor creates runs later, so its assignment counts as outside. Such a field records a phase, and every reader must know which phase holds. Push the fact as an event, wait on a one-shot latch, keep the phases in state objects, or ask the platform for the fact.
|
|
63
|
+
|
|
64
|
+
The rule also reports a `let` with the same types when a function that its function returns sets it. Such a function runs after the return, as a method runs after the constructor: a method of the returned object or class, a returned function, or the cleanup that a React effect returns. Thus `let closed = false; return { close() { closed = true; } }` is reported. A callback that the function calls before it returns, such as the callback of `map`, is not reported. A `let` that only its own function body sets is not reported.
|
|
65
|
+
|
|
66
|
+
A lazy memo is not a phase, so the rule does not report it. In a lazy memo, each write is `x ??= …` (for a field, the private `this.#x ??= …`), so the value never becomes empty again. Each read is the value of that `??=`, or comes after an `x ??= …;` statement at the top level of the same function body, as in `this.#x ??= build(); return this.#x;` or `return () => (value ??= read());`. A field or `let` that has `??=` writes but no read is a flag, and the rule reports it.
|
|
63
67
|
|
|
64
68
|
`zukhruf/no-test-lifecycle-hooks` keeps the arrange and the teardown of a test in that test. A hook moves them out, so the reader does not see the full test, and the state that one test leaves can reach the next test. A per-test `t.after()` of node:test also moves the teardown out of the flow of the test. The rule reads the names of the scope, not only the text. It reports a hook from the Vitest, Jest or Mocha globals, and from an import, also under a different name (`import { after as cleanup }`). It reports a hook on `test` or `it` of node:test, or on its namespace (`test.after()`). It reports a hook on a test context: the first parameter of a test callback or a subtest callback of node:test, or a parameter of the type `TestContext`. A function of the file that has the name `after` is not a hook. Put the teardown in `try`/`finally`, or use `await using` with a disposable.
|
|
65
69
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/eslint",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
4
4
|
"description": "ESLint rules and configs shared across workspaces. Every check is its own named rule, so a repo's own config cannot silently erase it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"ts-api-utils": "^2.5.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@zukhruf/testing": "^0.6.
|
|
65
|
+
"@zukhruf/testing": "^0.6.14"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@eslint-react/eslint-plugin": "^5.28.8",
|