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

Comment above directive duplicated under imports #238

Closed
1 task
ClementDreptin opened this issue Jul 4, 2023 · 1 comment
Closed
1 task

Comment above directive duplicated under imports #238

ClementDreptin opened this issue Jul 4, 2023 · 1 comment

Comments

@ClementDreptin
Copy link

Your Environment

  • Prettier version: 2.8.8
  • node version: 20.1.0
  • package manager: npm@9.6.4
  • IDE: neovim

Describe the bug

If a comment is present on the line before a directive, such as use client in Next.js 13, the comment is duplicated after the import statements on each prettier run.

To Reproduce

  • Create a file that looks like this
    // comment
    "use client";
    
    import foo from "bar";
  • Execute prettier and see the following output
    // comment
    "use client";
    
    import foo from "bar";
    
    // comment
  • Execute prettier a second time and see the following output (the cycle repeats)
    // comment
    "use client";
    
    import foo from "bar";
    
    // comment
    
    // comment

Expected behavior

I expect the original file to remain unchanged.

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

$ cat .prettierrc.js
module.exports = {
  plugins: [require("@trivago/prettier-plugin-sort-imports")],
};

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇
@ClementDreptin
Copy link
Author

Oops, I was searching for an existing issue about this and somehow didn't see #229, my bad...

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

1 participant