Skip to content

Commit b8d2954

Browse files
When testing import paths, only use string literals. (#389)
Prior to this change, code with template literals inside of `require` calls would break. This is because the check of `t.isLiteral` is far too broad for this usage, and assumes that all literals have a `value` property. Since `TemplateLiteral` nodes do not, they would cause `picomatch` to fail on an `undefined` input.
1 parent f8e9fb4 commit b8d2954

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/visitors/assignStyledRequired.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default t => (path, state) => {
2020
init.callee.name === 'require' &&
2121
init.arguments &&
2222
init.arguments[0] &&
23-
t.isLiteral(init.arguments[0]) &&
23+
t.isStringLiteral(init.arguments[0]) &&
2424
isValidTopLevelImport(init.arguments[0].value, state)
2525
) {
2626
state.styledRequired = path.node.id.name

0 commit comments

Comments
 (0)