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

ImportJS misidentifies import methods to be Dynamic Import #529

Open
arggh opened this issue Mar 18, 2019 · 3 comments
Open

ImportJS misidentifies import methods to be Dynamic Import #529

arggh opened this issue Mar 18, 2019 · 3 comments

Comments

@arggh
Copy link

arggh commented Mar 18, 2019

I just run ImportJS on a huge codebase and the results are mostly good, but this one seemed peculiar enough for me to report it:

importjsbug

I'm not too familiar with the lib, but in this case it broke the code by sorting two variable assignments in false order.

Used ImportJS 3.2.0 on Mac OS, via CLI:

find ./client -name "**.js*" -exec importjs fix --overwrite {} \;
//.importjs.js
module.exports = {
    declarationKeyword: 'import',
    environments: ['meteor', 'node'],
    excludes: ['.meteor/local/**', '.vscode/**'],
    mergableOptions: {
        globals: false,
    },
    useRelativePaths: true
}
@mweber-ak
Copy link

mweber-ak commented Aug 28, 2019

image
What I see after hitting ctrl + shift + i

Once I click through all the options all import statements disappear. But I can ctrl + z to go back to the block pictured above.

@mikabytes
Copy link
Collaborator

I couldn't reproduce this behavior. Probably it has been fixed since this issue was created (we're on v5.2 now, this issue is for 3.2).

I'll close this, but please reopen if anyone can reproduce. Thanks.

@mikabytes
Copy link
Collaborator

Apologies, my test had a typo. I can now reproduce some of it.

On current master, empty project with no dependencies:

import Quill from "quill";

const Parchment = Quill.import("parchment");
const Block = Parchment.query("block");

const a = "some code after";

becomes

import Quill from "quill"

const Parchment = Quill.import("parchment")

const a = "some code after";

While it didn't move the line for me, it still deleted it. I'm guessing ImportJS somehow misinterprets the Quill.import method to be a dynamic import.

This is the smallest reproducible I could achieve:

let l = a.import("")

These conditions need to be present for this bug:

  • const, var, or let before the variable
  • foo.import where foo is non-zero length string (let l = import("") does not work)
  • Argument to import must be double quote or single quote. Blockquotes does not trigger the bug.

@mikabytes mikabytes reopened this Feb 3, 2024
@mikabytes mikabytes changed the title Weird result after running ImportJS ImportJS misidentifies import methods to be Dynamic Import Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants