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

Not working with prettier-plugin-organize-imports #26

Closed
jacobwgillespie opened this issue Jan 26, 2022 · 3 comments
Closed

Not working with prettier-plugin-organize-imports #26

jacobwgillespie opened this issue Jan 26, 2022 · 3 comments

Comments

@jacobwgillespie
Copy link

It appears that either prettier-plugin-tailwindcss or prettier-plugin-organize-imports affect the file, based on which one appears last in the config plugin list, but not both.

Prettier Version: 2.5.1
prettier-plugin-tailwindcss version: 0.1.4
prettier-plugin-organize-imports version: 2.3.4

I am currently able to somewhat merge the two plugins manually by using the preprocess function from prettier-plugin-organize-imports, but it would be nice if the two got along without the patch:

// merged-prettier-plugin.js

const tailwind = require('prettier-plugin-tailwindcss')
const organizeImports = require('prettier-plugin-organize-imports')

const combinedFormatter = {
  ...tailwind,
  parsers: {
    ...tailwind.parsers,
    ...Object.keys(organizeImports.parsers).reduce((acc, key) => {
      acc[key] = {
        ...tailwind.parsers[key],
        preprocess(code, options) {
          return organizeImports.parsers[key].preprocess(code, options)
        },
      }
      return acc
    }, {}),
  },
}

module.exports = combinedFormatter
// .prettierrc.js

module.exports = {
  plugins: [require('./merged-prettier-plugin.js')],
  ...
}
@joshmedeski
Copy link

I have the same issue. I'm going to wait until this has been resolved to use the tailwind plugin.

@reinink
Copy link
Member

reinink commented Jan 28, 2022

Hey! Thanks for reporting this. I've created a new issue (#31) dedicated to keeping track of Prettier plugins that are not compatible with this plugin. Closing this issue in favor of that 👍

Please feel free to post this incompatibility with prettier-plugin-organize-imports in that issue, it would be great to have it there for quick reference.

@reinink
Copy link
Member

reinink commented Nov 14, 2022

Update on this one — we've added support for this plugin in the latest (beta) version of our Prettier plugin. You can read more about that here: #31 (comment)

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

No branches or pull requests

3 participants