我正在使用intellij,我已经开始了一个react typescript项目,并添加了eslint和prettier,以及lint-staged。在最初使用单引号之后,我想为jsx配置双引号。我设置了prettier
配置文件如下:
{
"semi": false,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"plugins": [
"prettier-plugin-tailwindcss"
]
}
字符串eslintrc.json
文件看起来像这样:
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"react-hooks",
"@typescript-eslint",
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"camelcase": "error",
"spaced-comment": "error",
"jsx-quotes": [
"error",
"prefer-double"
],
"quotes": [
"error",
"single"
],
"no-duplicate-imports": "error"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
型
但是,每当我在intellij中保存或运行带双引号的重新格式化代码时,它会将其重新格式化为单引号,就像我的App.tsx
中的这行:
<div className='p-2 bg-blue-500 text-white'>
型
在package.json
文件中,我有以下脚本:
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,css,md,json}": "npm run format --",
"*.{js,jsx,ts,tsx,json}": "npm run lint:fix --"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext 'src/**/*.{js,jsx,ts,tsx,json}' --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx,json}'",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc",
"preview": "vite preview",
"prepare": "husky install"
},
型
如果我运行更漂亮的脚本代码被正确地格式化为双引号。似乎Intellij由于某种原因设置错误。我试过使缓存无效并重新启动它,但如果我在编辑器中保存一些东西,它总是同样的事情,它会再次重新格式化为单引号。我该怎么解决这个问题?
1条答案
按热度按时间6ojccjat1#
该问题在WEB-50619上进行跟踪,请投票支持它以获得任何进展的通知