Skip to content

Commit 35b6a4e

Browse files
committed
refactor: update null checks to use '== null' or '!= null'
1 parent 82fd5f4 commit 35b6a4e

File tree

80 files changed

+950
-843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+950
-843
lines changed

eslint.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ const enableTypeCheckedRules = {
8080
"@typescript-eslint/consistent-type-exports": "error",
8181
"@typescript-eslint/strict-boolean-expressions": ["error", {
8282
allowAny: false,
83-
allowNullableBoolean: true,
83+
allowNullableBoolean: false,
8484
allowNullableEnum: false,
8585
allowNullableNumber: false,
86-
allowNullableObject: true,
86+
allowNullableObject: false,
8787
allowNullableString: false,
8888
allowNumber: true,
8989
allowString: false,

examples/dual-react-dom-lib/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
},
3131
"devDependencies": {
3232
"@eslint-react/eslint-plugin": "^1.23.2",
33-
"@eslint/js": "^9.17.0",
33+
"@eslint/js": "^9.18.0",
3434
"@tsconfig/node22": "^22.0.0",
3535
"@tsconfig/strictest": "^2.0.5",
3636
"@types/node": "^22.10.5",
37-
"@types/react": "^19.0.4",
38-
"eslint": "^9.17.0",
37+
"@types/react": "^19.0.5",
38+
"eslint": "^9.18.0",
3939
"eslint-plugin-react-hooks": "^5.1.0",
4040
"eslint-plugin-vitest": "^0.5.4",
4141
"react": "^19.0.0",

examples/dual-react-dom-lib/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
dts: true,
66
entry: ["src/index.ts"],
77
format: ["cjs", "esm"],
8-
minify: true,
8+
minify: false,
99
outDir: "dist",
1010
platform: "neutral",
1111
shims: false,

examples/next-app/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"devDependencies": {
1919
"@eslint-react/eslint-plugin": "^1.23.2",
2020
"@eslint/config-inspector": "^0.7.1",
21-
"@eslint/js": "^9.17.0",
21+
"@eslint/js": "^9.18.0",
2222
"@next/eslint-plugin-next": "^15.1.4",
2323
"@types/negotiator": "^0.6.3",
2424
"@types/node": "^22.10.5",
25-
"@types/react": "^19.0.4",
26-
"@types/react-dom": "^19.0.2",
25+
"@types/react": "^19.0.5",
26+
"@types/react-dom": "^19.0.3",
2727
"autoprefixer": "10.4.20",
28-
"eslint": "^9.17.0",
28+
"eslint": "^9.18.0",
2929
"eslint-config-flat-gitignore": "^1.0.0",
3030
"eslint-plugin-react-hooks": "^5.1.0",
31-
"eslint-plugin-react-refresh": "^0.4.16",
31+
"eslint-plugin-react-refresh": "^0.4.18",
3232
"postcss": "8.4.49",
3333
"tailwindcss": "3.4.17",
3434
"typescript": "^5.7.3",

examples/vite-react-dom-app/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"devDependencies": {
1818
"@eslint-react/eslint-plugin": "^1.23.2",
1919
"@eslint/config-inspector": "^0.7.1",
20-
"@eslint/js": "^9.17.0",
20+
"@eslint/js": "^9.18.0",
2121
"@tsconfig/node22": "^22.0.0",
2222
"@tsconfig/strictest": "^2.0.5",
23-
"@types/react": "^19.0.4",
24-
"@types/react-dom": "^19.0.2",
23+
"@types/react": "^19.0.5",
24+
"@types/react-dom": "^19.0.3",
2525
"@vitejs/plugin-react": "^4.3.4",
26-
"eslint": "^9.17.0",
26+
"eslint": "^9.18.0",
2727
"eslint-plugin-react-hooks": "^5.1.0",
28-
"eslint-plugin-react-refresh": "^0.4.16",
28+
"eslint-plugin-react-refresh": "^0.4.18",
2929
"typescript": "^5.7.3",
3030
"typescript-eslint": "^8.19.1",
3131
"vite": "^6.0.7"

examples/vite-react-dom-js-app/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"devDependencies": {
1818
"@eslint-react/eslint-plugin": "^1.23.2",
1919
"@eslint/config-inspector": "^0.7.1",
20-
"@eslint/js": "^9.17.0",
21-
"@types/react": "^19.0.4",
22-
"@types/react-dom": "^19.0.2",
20+
"@eslint/js": "^9.18.0",
21+
"@types/react": "^19.0.5",
22+
"@types/react-dom": "^19.0.3",
2323
"@vitejs/plugin-react": "^4.3.4",
24-
"eslint": "^9.17.0",
24+
"eslint": "^9.18.0",
2525
"eslint-plugin-react-hooks": "^5.1.0",
26-
"eslint-plugin-react-refresh": "^0.4.16",
26+
"eslint-plugin-react-refresh": "^0.4.18",
2727
"globals": "^15.14.0",
2828
"vite": "^6.0.7"
2929
},

examples/vite-react-dom-js-with-babel-app/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
},
1717
"devDependencies": {
1818
"@babel/core": "^7.26.0",
19-
"@babel/eslint-parser": "^7.25.9",
19+
"@babel/eslint-parser": "^7.26.5",
2020
"@babel/preset-env": "^7.26.0",
2121
"@babel/preset-react": "^7.26.3",
2222
"@eslint-react/eslint-plugin": "^1.23.2",
2323
"@eslint/config-inspector": "^0.7.1",
24-
"@eslint/js": "^9.17.0",
24+
"@eslint/js": "^9.18.0",
2525
"@types/babel__core": "~7.20.5",
2626
"@types/babel__preset-env": "~7.9.7",
27-
"@types/react": "^19.0.4",
28-
"@types/react-dom": "^19.0.2",
27+
"@types/react": "^19.0.5",
28+
"@types/react-dom": "^19.0.3",
2929
"@vitejs/plugin-react": "^4.3.4",
30-
"eslint": "^9.17.0",
30+
"eslint": "^9.18.0",
3131
"eslint-plugin-react-hooks": "^5.1.0",
32-
"eslint-plugin-react-refresh": "^0.4.16",
32+
"eslint-plugin-react-refresh": "^0.4.18",
3333
"globals": "^15.14.0",
3434
"vite": "^6.0.7"
3535
},

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@
5353
"devDependencies": {
5454
"@changesets/cli": "^2.27.11",
5555
"@eslint/config-inspector": "^0.7.1",
56-
"@eslint/js": "^9.17.0",
56+
"@eslint/js": "^9.18.0",
5757
"@eslint/markdown": "^6.2.1",
5858
"@napi-rs/canvas": "^0.1.65",
5959
"@stylistic/eslint-plugin": "^2.12.1",
6060
"@susisu/eslint-plugin-safe-typescript": "^0.9.2",
61-
"@swc/core": "^1.10.6",
61+
"@swc/core": "^1.10.7",
6262
"@tsconfig/node22": "^22.0.0",
6363
"@tsconfig/strictest": "^2.0.5",
6464
"@types/node": "^22.10.5",
65-
"@types/react": "^19.0.4",
66-
"@types/react-dom": "^19.0.2",
65+
"@types/react": "^19.0.5",
66+
"@types/react-dom": "^19.0.3",
6767
"@typescript-eslint/parser": "^8.19.1",
6868
"@typescript-eslint/rule-tester": "^8.19.1",
6969
"@typescript-eslint/types": "^8.19.1",
@@ -75,7 +75,7 @@
7575
"dedent": "^1.5.3",
7676
"dprint": "^0.48.0",
7777
"esbuild": "^0.24.2",
78-
"eslint": "^9.17.0",
78+
"eslint": "^9.18.0",
7979
"eslint-config-flat-gitignore": "^1.0.0",
8080
"eslint-import-resolver-oxc": "^0.8.0",
8181
"eslint-plugin-eslint-plugin": "^6.4.0",
@@ -88,11 +88,11 @@
8888
"eslint-plugin-vitest": "^0.5.4",
8989
"fixpkg": "^1.0.2",
9090
"importx": "^0.5.1",
91-
"lefthook": "^1.10.1",
91+
"lefthook": "^1.10.3",
9292
"markdownlint": "^0.37.3",
9393
"ofetch": "^1.4.1",
9494
"picocolors": "^1.1.1",
95-
"publint": "^0.3.0",
95+
"publint": "^0.3.1",
9696
"react": "^19.0.0",
9797
"react-dom": "^19.0.0",
9898
"skott": "^0.35.4",
@@ -116,17 +116,17 @@
116116
"packageManager": "[email protected]",
117117
"pnpm": {
118118
"overrides": {
119-
"@types/react": "^19.0.4",
120-
"@types/react-dom": "^19.0.2",
121-
"cross-spawn": "^7.0.6",
122119
"is-core-module": "npm:@nolyfill/is-core-module@^1.0.39",
120+
"safe-buffer": "npm:@nolyfill/safe-buffer@^1.0.41",
121+
"safer-buffer": "npm:@nolyfill/safer-buffer@^1.0.41",
122+
"typedarray": "npm:@nolyfill/typedarray@^1.0.29",
123+
"@types/react": "^19.0.5",
124+
"@types/react-dom": "^19.0.3",
125+
"cross-spawn": "^7.0.6",
123126
"next": "^15.1.4",
124127
"react": "^19.0.0",
125128
"react-dom": "^19.0.0",
126-
"safe-buffer": "npm:@nolyfill/safe-buffer@^1.0.41",
127-
"safer-buffer": "npm:@nolyfill/safer-buffer@^1.0.41",
128129
"ts-api-utils": "^2.0.0",
129-
"typedarray": "npm:@nolyfill/typedarray@^1.0.29",
130130
"typescript": "^5.7.3"
131131
}
132132
}

packages/core/docs/functions/getComponentNameFromIdentifier.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
# Function: getComponentNameFromIdentifier()
88

9-
> **getComponentNameFromIdentifier**(`node`): `string`
9+
> **getComponentNameFromIdentifier**(`node`): `undefined` \| `string`
1010
1111
## Parameters
1212

1313
### node
1414

15-
`Identifier` | `Identifier`[]
15+
`undefined` | `Identifier` | `Identifier`[]
1616

1717
## Returns
1818

19-
`string`
19+
`undefined` \| `string`

packages/core/src/component/component-collector.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ function hasValidHierarchy(node: AST.TSESTreeFunction, context: RuleContext, hin
4343
T.ClassBody,
4444
]),
4545
);
46-
return !boundaryNode || boundaryNode.type !== T.JSXExpressionContainer;
46+
return boundaryNode == null || boundaryNode.type !== T.JSXExpressionContainer;
4747
}
4848

4949
function getComponentFlag(initPath: ERFunctionComponent["initPath"]) {
5050
let flag = ERFunctionComponentFlag.None;
51-
if (initPath && AST.hasCallInFunctionInitPath("memo")(initPath)) {
51+
if (initPath != null && AST.hasCallInFunctionInitPath("memo")(initPath)) {
5252
flag |= ERFunctionComponentFlag.Memo;
5353
}
54-
if (initPath && AST.hasCallInFunctionInitPath("forwardRef")(initPath)) {
54+
if (initPath != null && AST.hasCallInFunctionInitPath("forwardRef")(initPath)) {
5555
flag |= ERFunctionComponentFlag.ForwardRef;
5656
}
5757
return flag;
@@ -76,7 +76,7 @@ export function useComponentCollector(
7676
};
7777
const onFunctionExit = () => {
7878
const entry = functionEntries.at(-1);
79-
if (!entry) return;
79+
if (entry == null) return;
8080
if (!entry.isComponent) {
8181
return functionEntries.pop();
8282
}
@@ -85,7 +85,7 @@ export function useComponentCollector(
8585
.reverse()
8686
.some((r) => {
8787
return context.sourceCode.getScope(r).block === entry.node
88-
&& !!r.argument
88+
&& r.argument != null
8989
&& !JSX.isJSXValue(r.argument, jsxCtx, hint);
9090
});
9191
if (shouldDrop) {
@@ -110,7 +110,7 @@ export function useComponentCollector(
110110
":function[type]:exit": onFunctionExit,
111111
"ArrowFunctionExpression[type][body.type!='BlockStatement']"() {
112112
const entry = getCurrentEntry();
113-
if (!entry) {
113+
if (entry == null) {
114114
return;
115115
}
116116
const { body } = entry.node;
@@ -122,7 +122,7 @@ export function useComponentCollector(
122122
}
123123
const initPath = AST.getFunctionInitPath(entry.node);
124124
const id = getFunctionComponentIdentifier(entry.node, context);
125-
const name = id && getComponentNameFromIdentifier(id);
125+
const name = getComponentNameFromIdentifier(id);
126126
const key = getId();
127127
components.set(key, {
128128
_: key,
@@ -146,7 +146,7 @@ export function useComponentCollector(
146146
: _;
147147
const component = [...components.values()]
148148
.findLast(({ name }) => name != null && name === componentName);
149-
if (!component) {
149+
if (component == null) {
150150
return;
151151
}
152152
components.set(component._, {
@@ -159,15 +159,15 @@ export function useComponentCollector(
159159
return;
160160
}
161161
const entry = getCurrentEntry();
162-
if (!entry) {
162+
if (entry == null) {
163163
return;
164164
}
165165
functionEntries.pop();
166166
functionEntries.push({ ...entry, hookCalls: [...entry.hookCalls, node] });
167167
},
168168
"ReturnStatement[type]"(node: TSESTree.ReturnStatement) {
169169
const entry = getCurrentEntry();
170-
if (!entry) {
170+
if (entry == null) {
171171
return;
172172
}
173173
const isComponent = hasNoneOrValidComponentName(entry.node, context)
@@ -180,7 +180,7 @@ export function useComponentCollector(
180180
functionEntries.push({ ...entry, isComponent });
181181
const initPath = AST.getFunctionInitPath(entry.node);
182182
const id = getFunctionComponentIdentifier(entry.node, context);
183-
const name = id && getComponentNameFromIdentifier(id);
183+
const name = getComponentNameFromIdentifier(id);
184184
components.set(entry.key, {
185185
_: entry.key,
186186
id,

0 commit comments

Comments
 (0)