1

我有一个.Net Core Web Application,我vue在客户端使用。我已经.eslintrtc用所需的规则配置了文件,但编辑器似乎忽略了.vue文件。请看下面我的配置

module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        'plugin:vue/essential',
        '@vue/standard'
    ],
    rules: {
        eqeqeq: 'off', // off
        'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        'no-extend-native': [2, { exceptions: ['Object', 'Array', 'String', 'Number', 'Date'] }],
        indent: ['error', 4, { SwitchCase: 1 }],
        'vue/script-indent': ['error', 4, {
            baseIndent: 1,
            switchCase: 1,
            ignores: []
        }],
        semi: ['error', 'always'],
        'space-before-function-paren': ['error', {
            anonymous: 'always',
            named: 'never',
            asyncArrow: 'always'
        }],
        'prefer-const': 0,
        'no-case-declarations': 0,
        'no-empty-pattern': 0,
        'no-mixed-operators': 0
    },
    parserOptions: {
        parser: 'babel-eslint'
    },
    overrides: [
        {
            files: [
                '**/__tests__/*.{j,t}s?(x)'
            ],
            env: {
                mocha: true
            }
        },
        {
            files: ['*.vue'],
            rules: {
                indent: 'off'
            }
        }
    ]
};

下面列出了 package.json 开发依赖项

"devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-plugin-router": "^4.5.7",
    "@vue/cli-service": "^4.1.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "babel-eslint": "^10.0.3",
    "eslint": "^5.16.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.1",
    "eslint-plugin-vue": "^5.0.0",
    "sass": "^1.18.0",
    "sass-loader": "^10.0.3",
    "vue-template-compiler": "^2.6.12"
}

如何配置Visual Studio 2019为自动 linting.vue文件?我提到在Visual studio Code工作中(但我需要工作Visual Studio 2019

4

1 回答 1

1

因此,目前在 Visual Studio 中,您无法指定扫描的文件类型,并且 ESLint 设置非常有限。默认情况下,Visual Studio 只会扫描 .js 文件。

ESLint 允许您传入命令行选项“--ext”以指定其他文件类型,但无法配置 Visual Studio 来执行此操作...

微软开发者社区有一个开放的建议功能,建议在此处进行更改

于 2021-06-25T13:49:05.017 回答