【发布时间】:2022-01-09 14:34:46
【问题描述】:
我有一个带有 Vite 捆绑器的 Svelte 应用。我的 linter 是带有 Prettier 和 vite-plugin-svelte 插件的 Eslint。 linting 效果很好,但我想让应用程序在 Vite hmr 覆盖层中显示所有 linting 错误,就像这张图片中的语法错误一样
我的问题是: 甚至可以用 Vite 制作类似的东西吗?我在文档中发现 Vite 的 hmr 覆盖没有任何帮助,或者我只是在 Eslint/Prettier 配置中遗漏了一些东西?
这里是配置文件:
.eslintrc:
{
"extends": ["eslint:recommended", "airbnb-base", "prettier"],
"plugins": ["svelte3", "prettier"],
"env": {
"es6": true,
"browser": true,
"node": true
},
"overrides": [
{
"files": ["*.svelte"],
"processor": "svelte3/svelte3"
}
],
"parserOptions": {
"project": "./jsconfig.json"
},
"rules": {
"prefer-arrow-callback": "off",
"arrow-body-style": "off",
"import/prefer-default-export": "off",
"import/no-anonymous-default-export": [
"error",
{
"allowArray": true,
"allowArrowFunction": false,
"allowAnonymousClass": false,
"allowAnonymousFunction": false,
"allowCallExpression": true,
"allowLiteral": false,
"allowObject": true
}
],
"dot-notation": "off"
}
}
.prettierrc.js
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
printWidth: 80,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
overrides: [
{
files: 'package*.json',
options: {
printWidth: 1000,
},
},
],
};
vite.config.js
export default defineConfig({
plugins: [
svelte({
preprocess: preprocess(),
}),
],
});
【问题讨论】:
标签: eslint svelte prettier svelte-3 vite