Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanner does not find "default as" imports #39

Closed
drewbrend opened this issue Apr 13, 2021 · 0 comments · Fixed by #40
Closed

Scanner does not find "default as" imports #39

drewbrend opened this issue Apr 13, 2021 · 0 comments · Fixed by #40

Comments

@drewbrend
Copy link
Contributor

I am trying to switch from an old in-house built solution to react-scanner and found one case that ours worked with but react-scanner does not. We have some instances of this import syntax that get missed:

import { default as Header } from "my-design-system";

Here is a test that shows the issue, just add it to src/scan.test.js:


Scan("importedFrom default export as", ({ getReport }) => {
  const report = getReport(
    "imported-from-default-export.js",
    `
    import { default as Header } from "my-design-system";
    import Box from "other-module";
    
    <Box>
      <Header />
    </Box>
  `,
    { importedFrom: /my-design-system/ }
  );

  assert.equal(report, {
    Header: {
      instances: [
        {
          importInfo: {
            local: "Header",
            moduleName: "my-design-system",
            importType: "ImportDefaultSpecifier",
          },
          props: {},
          propsSpread: false,
          location: {
            file: "imported-from-default-export.js",
            start: {
              line: 6,
              column: 7,
            },
          },
        },
      ],
    },
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant