【发布时间】:2020-12-05 02:50:00
【问题描述】:
我正在尝试使用 svelte 制作一个应用。
我想设置 prettier 和 eslint,我为 VS Code 安装了这些依赖项和 Svelte 扩展。
"dependencies": {
"eslint": "^7.7.0",
"eslint-plugin-svelte3": "^2.7.3",
"prettier": "^2.0.5",
"prettier-plugin-svelte": "^1.1.0",
"save-dev": "0.0.1-security",
"sirv-cli": "^1.0.0",
"stylelint": "^13.6.1"
}
现在,我无法设置所有内容。
我做了
.eslintrc
{
"plugins": ["eslint-plugin-svelte3"],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": "error"
}
}
.prettierrc
{
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"trailingComma": "es6"
}
我想在 .vscode 下使用 settings.json 自动保存
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.prettier": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.validate": ["svelte"]
}
现在我尝试使用它,但保存时没有任何反应,执行时也没有
"fix": "npx eslint --fix \"src/**/*.svelte\"",
"format": "npx prettier --write \"src/**/*.svelte\""
我错过了什么吗?
【问题讨论】:
-
@Daniel_Knights > 和 Svelte for VS Code 的扩展。我已经有了
-
@Bobby 你能试试这个
.eslintrc配置:github.com/johannchopin/gitmoji-browser-extension/blob/master/…