Skip to content

Commit 9c5fd3d

Browse files
Rel1cxCopilot
andauthored
Update packages/core/src/utils/is-from-source.ts
Co-authored-by: Copilot <[email protected]> Signed-off-by: REL1CX <[email protected]>
1 parent 75e29ba commit 9c5fd3d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/core/src/utils/is-from-source.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ export function isInitializedFromSource(
3838
const { node, parent } = latestDef;
3939
if (node.type === T.VariableDeclarator && node.init != null) {
4040
const { init } = node;
41-
// check for: `variable = React.variable`
41+
// check for: variable = Source.variable
4242
if (init.type === T.MemberExpression && init.object.type === T.Identifier) {
4343
return isInitializedFromSource(init.object.name, source, initialScope);
4444
}
45-
// check for: `{ variable } = React`
45+
// check for: { variable } = Source
4646
if (init.type === T.Identifier) {
4747
return isInitializedFromSource(init.name, source, initialScope);
4848
}
49-
// check for: `variable = require('react')` or `variable = require('react').variable`
49+
// check for: variable = require('source') or variable = require('source').variable
5050
const args = getRequireExpressionArguments(init);
5151
const arg0 = args?.[0];
5252
if (arg0 == null || !AST.isLiteral(arg0, "string")) {
5353
return false;
5454
}
55-
// check for: `require('react')` or `require('react/...')`
55+
// check for: require('source') or require('source/...')
5656
return arg0.value === source || arg0.value.startsWith(`${source}/`);
5757
}
58-
// latest definition is an import declaration: import { variable } from 'react'
58+
// latest definition is an import declaration: import { variable } from 'source'
5959
return parent?.type === T.ImportDeclaration && parent.source.value === source;
6060
}

0 commit comments

Comments
 (0)