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

SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag #199

Closed
Henvy-Mango opened this issue Dec 30, 2022 · 1 comment
Closed

Comments

@Henvy-Mango
Copy link

When I use the plugin to format vue file, it noticed that SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag.
But if I remove the plugin, it turns to normal.

Here is the minimal reproduction.

This is my vue file.

<template>
    <router-view />
</template>
  
<style lang="less">
#app {
height: 100%;
background-color: inherit;
}
</style>

This is my .prettierrc.js.

module.exports = {
  importOrder: ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
  importOrderSeparation: true,
  importOrderSortSpecifiers: true,
};

And this is my package.json

{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "build": "vite build",
    "dev": "vite",
    "lint:prettier": "prettier --write  \"src/**/*.{js,json,jsx,css,less,scss,vue,html,md}\""
  },
  "dependencies": {
    "vue": "^3.2.45"
  },
  "devDependencies": {
    "@trivago/prettier-plugin-sort-imports": "^4.0.0",
    "@vitejs/plugin-vue": "^4.0.0",
    "prettier": "^2.8.1",
    "vite": "^4.0.3"
  }
}
@IanVS
Copy link

IanVS commented May 12, 2023

The jsx plugin is included by default in importOrderParserPlugins, along with typescript. You could try changing your config to be:

module.exports = {
  importOrder: ["^@core/(.*)$", "^@server/(.*)$", "^@ui/(.*)$", "^[./]"],
  importOrderSeparation: true,
  importOrderSortSpecifiers: true,
  importOrderParserPlugins: []
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants