Skip to content

Commit 2991f2e

Browse files
authored
fix: rule dynamic-import-chunkname crash due to ts migration (#346)
1 parent 2a53fcb commit 2991f2e

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.changeset/pink-readers-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-import-x": patch
3+
---
4+
5+
fix: rule `dynamic-import-chunkname` crash due to ts migration

src/rules/dynamic-import-chunkname.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ export default createRule<[Options?], MessageId>({
232232
if (
233233
// @ts-expect-error - legacy parser type
234234
node.callee.type !== 'Import' &&
235-
'name' in node.callee &&
236-
!importFunctions.includes(node.callee.name)
235+
(!('name' in node.callee) ||
236+
!importFunctions.includes(node.callee.name))
237237
) {
238238
return
239239
}

test/rules/dynamic-import-chunkname.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,26 @@ describe('TypeScript', () => {
11361136
)`,
11371137
options,
11381138
},
1139+
{
1140+
code: `import { useSyncExternalStore } from "use-sync-external-store/shim";
1141+
1142+
export default function useAbortSignal(signal: AbortSignal): boolean {
1143+
return useSyncExternalStore(
1144+
(callback: () => void) => {
1145+
const unsubscribe = new AbortController();
1146+
signal.addEventListener("abort", callback, {
1147+
signal: unsubscribe.signal,
1148+
once: true,
1149+
});
1150+
return () => {
1151+
unsubscribe.abort();
1152+
};
1153+
},
1154+
() => signal.aborted,
1155+
);
1156+
}`,
1157+
options,
1158+
},
11391159
],
11401160
invalid: [
11411161
{

0 commit comments

Comments
 (0)