Skip to content

Commit

Permalink
When testing import paths, only use string literals. (#389)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maisano-patreon authored May 19, 2023
1 parent f8e9fb4 commit b8d2954
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/visitors/assignStyledRequired.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default t => (path, state) => {
init.callee.name === 'require' &&
init.arguments &&
init.arguments[0] &&
t.isLiteral(init.arguments[0]) &&
t.isStringLiteral(init.arguments[0]) &&
isValidTopLevelImport(init.arguments[0].value, state)
) {
state.styledRequired = path.node.id.name
Expand Down

0 comments on commit b8d2954

Please sign in to comment.