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

Intellij: Prettier fails to run against .svelte files, reports receiving invalid sort order every time #398

Open
ackmanx opened this issue Aug 18, 2023 · 3 comments

Comments

@ackmanx
Copy link

ackmanx commented Aug 18, 2023

Every time I try to run prettier within Intellij, I get the error in the screenshot. It seems to receive scripts-styles-markup as the sort order every time, which is not a supported value. Really not sure how to debug this.

I invoke prettier using the built-in shortcut cmd + shift + p. This seems to be isolated to Intellij, as I can run prettier as a yarn script (using prettier --plugin prettier-plugin-svelte --write .) and it works correctly.

Versions

  • IntelliJ IDEA 2023.2 (Ultimate Edition)
  • "prettier": "^3.0.2",
  • "prettier-plugin-svelte": "^3.0.3",
  • "@sveltejs/kit": "^1.22.6",
  • "svelte": "^4.2.0",

Prettier Config

// prettier.config.cjs
module.exports = {
  semi: false,
  tabWidth: 2,
  trailingComma: 'es5',
  singleQuote: true,
  printWidth: 100,
  plugins: ['prettier-plugin-svelte'],
  svelteSortOrder: 'options-scripts-styles-markup',
}
Screenshot 2023-08-17 at 22 19 30
@dummdidumm
Copy link
Member

I have insufficient experience with Intellij, so can't really help here. My first instinct is that this is related to Intellij's handling of Prettier - maybe they ignore the config (do other setting formats work, like .prettierrc?), maybe they ignore the specific sort order setting. Maybe it's Intellij's Prettier support itself, maybe it's happening as part of the Svelte Plugin. Maybe @tomblachut knows more?

As a workaround you can go back to using Prettier version 2, that should still work.

@ackmanx
Copy link
Author

ackmanx commented Aug 19, 2023

Downgrading to Prettier v2 did indeed work for being able to format Svelte files within Intellij, so thanks for that suggestion.

@tomblachut
Copy link

tomblachut commented Aug 22, 2023

@dummdidumm thanks for pinging me, those are all good leads.

If it works in the terminal it indeed feels like a problem in IDE.

@ackmanx could you open an issue at WebStorm's YouTrack I'm not maintaining Prettier integration so I'm not the best to help but our folks will process the issue properly.

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