我已经创建了一个默认的Nuxt项目,并选择了ESLint和更漂亮的项目。我已经打开了应用程序,并按了快捷键重新格式化的代码。当我运行nuxt项目时,ESLint会在index.vue页面上显示错误,用于缩进。
以下是ESLint、EditorConfig和index.vue代码。
ESLint:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'plugin:vue/recommended',
'plugin:prettier/recommended'
],
// required to lint *.vue files
plugins: [
'vue',
'prettier'
],
// add your custom rules here
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}EditorConfig:
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = falseindex.vue:
<template>
<section class="container">
...
</section>
</template>
<script>
import Logo from '~/components/Logo.vue'
export default {
components: {
Logo
}
}
</script>
<style>
.container {
min-height: 100vh;
...
}
...
</style>因此,错误发生在<script>...</script>和<style>...</style>部分。有人能指导我如何让ESLint与EditorConfig缩进一起工作吗?如果有帮助的话,我将使用Webstorm作为IDE。
发布于 2019-01-12 14:27:54
你能看到哪些错误?是关于<style>和<script>中的代码向右移动而不是与标记对齐吗?这是一个已知的问题,原因是缺乏针对.vue文件的专用代码样式设置;它是在WEB-30382中跟踪的。
作为一种解决办法,尝试将script和style条目添加到设置-设置-编辑器-代码样式
https://stackoverflow.com/questions/54158458
复制相似问题