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

Compatibility with prettier-plugin-sort-imports #7

Open
wottpal opened this issue Feb 1, 2023 · 2 comments
Open

Compatibility with prettier-plugin-sort-imports #7

wottpal opened this issue Feb 1, 2023 · 2 comments

Comments

@wottpal
Copy link

wottpal commented Feb 1, 2023

Hey @mohammadsiyou, how is it going?

I do not get this plugin to work with @ianvs/prettier-plugin-sort-imports, unfortunately. This is a known issue from previous versions of the base tailwind prettier plugin, but they recently fixed compatibility. So if you might fetch in the latest changes from them this would already fix it 🤷‍♂️

Also, did you make any progress on #1?

@u3u
Copy link
Contributor

u3u commented Feb 9, 2023

My solution

plugins.js

const tailwindPlugin = require('prettier-plugin-twin.macro')
const sortImportsPlugin = require('@trivago/prettier-plugin-sort-imports')
const { mapValues } = require('remeda')

/** @type {import('prettier').Plugin} */
module.exports = {
  options: {
    ...sortImportsPlugin.options,
  },

  parsers: {
    ...mapValues(tailwindPlugin.parsers, (item, key) => ({
      ...item,
      preprocess: sortImportsPlugin.parsers[key].preprocess,
    })),
  },
}

prettier.config.js

/** @type {import('prettier').Config} */
module.exports = {
  importOrderSortSpecifiers: true,
  plugins: [
    require.resolve('./plugins'),
  ],
}

@wottpal
Copy link
Author

wottpal commented Feb 10, 2023

@u3u awesome 🔥 worked instantly 🤩

we should join forces to resolve the other issues in this repo. especially #1 really bothers me.

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

2 participants