Skip to content

Commit 034a818

Browse files
committed
Fixes lint issues
1 parent b44fcc8 commit 034a818

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

packages/babel-plugin-component-annotate/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ module.exports = {
99
tsconfigRootDir: __dirname,
1010
project: ["./src/tsconfig.json", "./test/tsconfig.json"],
1111
},
12+
globals: {
13+
Set: "readonly",
14+
},
1215
env: {
1316
node: true,
1417
},

packages/babel-plugin-component-annotate/src/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,20 @@ function collectFragmentContext(programPath: Babel.NodePath): FragmentContext {
520520
// Handle destructuring assignments: const { Fragment } = React
521521
if (varPath.node.id.type === 'ObjectPattern') {
522522
if (init.type === 'Identifier' && reactNamespaceAliases.has(init.name)) {
523-
(varPath.node.id as any).properties.forEach((prop: any) => {
524-
if (prop.type === 'ObjectProperty' &&
525-
prop.key?.type === 'Identifier' &&
526-
prop.value?.type === 'Identifier' &&
527-
prop.key.name === 'Fragment') {
523+
const properties = varPath.node.id.properties;
524+
525+
for (const prop of properties) {
526+
if (
527+
prop.type === 'ObjectProperty' &&
528+
prop.key &&
529+
prop.key.type === 'Identifier' &&
530+
prop.value &&
531+
prop.value.type === 'Identifier' &&
532+
prop.key.name === 'Fragment'
533+
) {
528534
fragmentAliases.add(prop.value.name);
529535
}
530-
});
536+
}
531537
}
532538
}
533539
}

packages/babel-plugin-component-annotate/test/test-plugin.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,9 +1848,7 @@ export default function TestComponent() {
18481848
plugins: [plugin],
18491849
}
18501850
);
1851-
1852-
console.log("Generated code:", result?.code);
1853-
1851+
18541852
// Let's see what's happening
18551853
expect(result?.code).toBeDefined();
18561854
});

0 commit comments

Comments
 (0)