6

我无法让templatelinter 对我的 .vue 文件的一部分进行 lint。您对我需要更改配置有什么意见吗?

总的来说,我希望 linter 调整如下:

<template>
  <v-container>
              <h1>Home</h1>
  </v-container>
</template>

对此:

<template>
  <v-container>
    <h1>Home</h1>
  </v-container>
</template>

这是我的配置:

// .eslintrc
module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    '@vue/standard'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  },
  parserOptions: {
    parser: 'babel-eslint'
  }
}

和依赖项:

// package.json
{
  "name": "mobile.zmittag",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
    "postinstall": "npm run build",
    "start": "node server.js",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "auth0-js": "^9.10.1",
    "axios": "^0.18.0",
    "connect-history-api-fallback": "^1.6.0",
    "core-js": "^2.6.5",
    "express": "^4.16.4",
    "register-service-worker": "^1.6.2",
    "serve-static": "^1.13.2",
    "vue": "^2.6.6",
    "vue-i18n": "^8.0.0",
    "vue-router": "^3.0.1",
    "vuetify": "^1.5.5",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@kazupon/vue-i18n-loader": "^0.3.0",
    "@vue/cli-plugin-babel": "^3.5.0",
    "@vue/cli-plugin-eslint": "^3.5.1",
    "@vue/cli-plugin-pwa": "^3.5.0",
    "@vue/cli-plugin-unit-jest": "^3.5.0",
    "@vue/cli-service": "^3.5.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "fibers": "^3.1.1",
    "sass": "^1.17.2",
    "sass-loader": "^7.1.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1",
    "vue-cli-plugin-i18n": "^0.6.0",
    "vue-cli-plugin-vuetify": "^0.5.0",
    "vue-template-compiler": "^2.5.21",
    "vuetify-loader": "^1.0.5"
  }
}
4

4 回答 4

1

eslint 默认命令 lint 仅 JS 文件

尝试在您的内部更改您的 lint 命令package.json

"lint": "vue-cli-service lint""lint": "vue-cli-service lint --ext .js,.vue"

这应该允许 eslint 对您的.vue文件进行 lint

于 2019-04-15T09:51:43.257 回答
0

问题是你需要一个自定义的 vue/eslint 插件。查看文档以获取更多信息和可用规则。

于 2019-10-27T11:18:18.543 回答
0

有点晚了......我面临同样的事情,并在配置中注意到“'plugin:vue/vue3-essential'”。将其更改为“'plugin:vue/vue3-recommended'”也开始对模板部分进行 linting。

extends:{
  'plugin:vue/vue3-recommended',
  '@vue/standard'
}

https://eslint.vuejs.org/user-guide/#bundle-configurations

于 2021-05-24T18:40:27.933 回答
0

如果您使用的是vscode编辑器,那么您只需要按下ctrl+shift+i并根据需要查看结果。

于 2019-10-22T05:59:58.583 回答