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

Sorts not being applied on .prettierrc.js #33

Closed
1 task done
FranciscoKloganB opened this issue Jul 24, 2022 · 3 comments
Closed
1 task done

Sorts not being applied on .prettierrc.js #33

FranciscoKloganB opened this issue Jul 24, 2022 · 3 comments
Assignees

Comments

@FranciscoKloganB
Copy link

FranciscoKloganB commented Jul 24, 2022

Your Environment

  • Prettier version: 2.7.1
  • node version: v16.5
  • package manager: 8.5.5
  • IDE: [VScode, CLI]

Describe the bug

When a file is .prettierrc imports are sorted. When the file is .prettierrc.js imports are not sorted.

Expected behavior

Given a .prettierrc.js file imports should be sorted.
However, this only appears to work when using .prettierrc as a JSON or json5 file.

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

// .prettierrc.js
module.exports = {
  importOrder: [
    "<THIRD_PARTY_MODULES>",
    "",
    "^~/clients/(.*)$",
    "^~/components/(.*)$",
    "^~/config/(.*)$",
    "^~/cypress/(.*)$",
    "^~/hooks/(.*)$",
    "^~/layouts/(.*)$",
    "^~/locales/(.*)$",
    "^~/mocks/(.*)$",
    "^~/pages/(.*)$",
    "^~/providers/(.*)$",
    "^~/public/(.*)$",
    "^~/server/(.*)$",
    "^~/styles/(.*)$",
    "^~/themes/(.*)$",
    "^~/types/(.*)$",
    "^~/utils/(.*)$",
    "",
    "^[./]",
    "^[../]",
    ""
  ],
  importOrderSeparation: true,
  importOrderSortSpecifiers: true,
  jsxBracketSameLine: false,
  plugins: [require("prettier-plugin-tailwindcss")],
  printWidth: 100,
  semi: false,
  singleQuote: false,
  trailingComma: "none"
}

Error log

Tried using VSCode format on save and CLI. Both runs terminate successfully, but imports are not sorted.

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

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

FranciscoKloganB commented Jul 24, 2022

it appears the issue has nothing to do with this or the "parent" prettier plugin but rather an incompatibility between two plugins for prettier. See here.

The reason why imports were being sorted when using .prettierrc instead of .prettierrc.js was due to the fact that "prettier-plugin-tailwindcss" was either being imported incorrectly or can not be imported in a non-js file? Idk

Either way, I fixed it using the linked solution.

Do not know if there is a way of eliminating this conflict without having to create a "in-project" plugin

@IanVS
Copy link
Owner

IanVS commented Jul 25, 2022

Thanks for finding the issue and reporting back. I don't think there's anything we can do for now, and tailwindlabs/prettier-plugin-tailwindcss#31 seems to be where the activity is happening. I'm going to close this for now, since it's not a bug in this plugin per se, but thanks again for bringing it up.

@IanVS IanVS closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2022
@IanVS
Copy link
Owner

IanVS commented Jul 25, 2022

Also, we're tracking this in #27 as well.

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