oxlint-plugin-effect 0.12.0 → 0.12.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.
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ If the project uses JSON configuration, copy the exported rule map into `rules`;
|
|
|
34
34
|
| `effect/noThrowStatement` | Bans every throw statement |
|
|
35
35
|
| `effect/noNewPromise` | Bans new Promise, Promise calls, and Promise static APIs |
|
|
36
36
|
| `effect/noNewError` | Allows native Error values only as direct arguments to Effect.die, Cause.die, or Exit.die |
|
|
37
|
-
| `effect/noNullish` | Bans null and undefined;
|
|
37
|
+
| `effect/noNullish` | Bans null and undefined; permits `Object.create(null)` for prototype-free dictionaries |
|
|
38
38
|
| `effect/noModuleMocks` | Bans Vitest and Jest module mocks and method spies; use Effect service test layers |
|
|
39
39
|
| `effect/noTernary` | Bans conditional expressions while allowing ordinary if statements |
|
|
40
40
|
| `effect/noManagedRuntimeInEffect` | Keeps ManagedRuntime construction at non-Effect host boundaries |
|
package/dist/rules/no-nullish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { narrow } from "../vendor/effect-oxlint/AST.js";
|
|
1
|
+
import { isMember, narrow } from "../vendor/effect-oxlint/AST.js";
|
|
2
2
|
import { make } from "../vendor/effect-oxlint/Diagnostic.js";
|
|
3
3
|
import { RuleContext } from "../vendor/effect-oxlint/RuleContext.js";
|
|
4
4
|
import { define, meta } from "../vendor/effect-oxlint/Rule.js";
|
|
@@ -8,6 +8,10 @@ import * as Option from "effect/Option";
|
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
//#region src/rules/no-nullish.ts
|
|
10
10
|
const message = "Avoid null and undefined. Use Option for presence or absence. Use a domain enum when the state has more than two cases.";
|
|
11
|
+
const isNullPrototypeArgument = (node) => {
|
|
12
|
+
const parent = node.parent;
|
|
13
|
+
return parent?.type === "CallExpression" && parent.arguments[0] === node && parent.callee.type === "MemberExpression" && isMember(parent.callee, "Object", "create");
|
|
14
|
+
};
|
|
11
15
|
const noNullish = define({
|
|
12
16
|
name: "no-nullish",
|
|
13
17
|
meta: meta({
|
|
@@ -33,7 +37,7 @@ const noNullish = define({
|
|
|
33
37
|
}),
|
|
34
38
|
Literal: (node) => Option.match(narrow(node, "Literal"), {
|
|
35
39
|
onNone: () => Effect.void,
|
|
36
|
-
onSome: (literal) => literal.value === null && !("regex" in literal) ? report(literal) : Effect.void
|
|
40
|
+
onSome: (literal) => literal.value === null && !("regex" in literal) && !isNullPrototypeArgument(literal) ? report(literal) : Effect.void
|
|
37
41
|
}),
|
|
38
42
|
TSNullKeyword: (node) => Option.match(narrow(node, "TSNullKeyword"), {
|
|
39
43
|
onNone: () => Effect.void,
|
|
@@ -211,4 +211,4 @@ const findAncestor = dual(2, (node, type) => {
|
|
|
211
211
|
*/
|
|
212
212
|
const hasAncestor = dual(2, (node, type) => Option.isSome(findAncestor(node, type)));
|
|
213
213
|
//#endregion
|
|
214
|
-
export { AST_exports, calleeName, importSource, matchImport, matchMember, memberNames, narrow };
|
|
214
|
+
export { AST_exports, calleeName, importSource, isMember, matchImport, matchMember, memberNames, narrow };
|