eslint检查和自动格式化

1.vscode 搜索、安装插件 prettier

eslint检查和自动格式化_第1张图片

2.配置prettier.eslintIntegrationtrue ,格式化会按eslint规则进行

在首选项--设置--找到如下

eslint检查和自动格式化_第2张图片

3.eslint开启保存格式化

eslint检查和自动格式化_第3张图片

 FAQ  typescript格式化不自动修复代码题

 

将如下代码修改为:

{
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
        "typescript",
        "typescriptreact"
    ]
}

 需要注意的是,这里面只有javascript是默认支持自动修复的,其他的并不支持,所以要改成:

 对typescript加上自动修复

{
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
        {
            "language": "typescript",
            "autoFix": true
        },
        "typescriptreact"
    ]
}

 

你可能感兴趣的:(eslint检查和自动格式化)