-
-
Notifications
You must be signed in to change notification settings - Fork 48
Prettier error: Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?
#258
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
Comments
Did you try And I don't think that's a minimal reproduction, can you please try to provide another smaller one? |
Please install Maybe you want a custom prettier configuration according to your // .prettierrc
{
"svelteSortOrder": "options-markup-scripts-styles"
} |
Oh, thank you very much! Would you maybe consider adding such a note to the docs - in the place where you talk about the preset |
We do have a list item mentions:
But I agree we can document it better, please feel free to draft a PR for it from your view! |
Hey, thanks for this. For anyone searching through the issues, this solved two other parsing issues I faced: <script lang="ts" context="module">
// anything typescript gives squiggly red lines
</script> and import type { Readable } from "svelte/store"; // squiggly red lines Since |
Hi 👋🏻 I'm having this issue but the above comments that suggest how to resolve it do not appear to work. This is a fresh Just clone and run
As of 4.2.0 eslint-plugin-prettier supports svelte natively, so it should no longer be necessary to install "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.2",
"@tsconfig/svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-svelte": "^2.9.0",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.7.1",
"svelte": "^3.49.0",
"svelte-check": "^2.8.1",
"svelte-preprocess": "^4.10.7",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vite": "^3.1.0"
}
// .eslintrc.cjs
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
extraFileExtensions: [".svelte"]
},
plugins: ["@typescript-eslint", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:svelte/recommended",
"plugin:prettier/recommended",
"plugin:svelte/prettier"
],
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser"
},
},
]
} |
prettier-plugin-svelte doesn't seem to work well with pnpm, so I think you need to do a workaround. |
What the holy hell?! I would have never guessed that. I used pnpm all the time and haven't had an issue, but it looks like it's common. I guess I haven't used it in the circumstances for having a prettier plugin...?! Thank you for the info (and this great package)! I went through all of the different options, and the minimal fix that worked for both the cli and vscode was to add this to
|
Before You File a Bug Report Please Confirm You Have Done The Following...
What version of ESLint are you using?
8.23.1
What version of
eslint-plugin-svelte
are you using?2.8.0
What did you do?
Configuration
What did you expect to happen?
No prettier error
What actually happened?
I got
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?
error fromeslint-plugin-prettier
Link to Minimal Reproducible Example
I can't get eslint-plugin-prettier running in your playground. For a (non-minimal) repro, see skaut/shared-drive-mover@563b5a9
Additional comments
No response
The text was updated successfully, but these errors were encountered: