VSCode Eslint+Prettier配置

本文详细介绍如何在Visual Studio Code中调整字体、设置自动格式化、ESLint与Prettier配置,确保代码高效整洁。涉及JSON、TS、React等语言的美化和规则应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打开VSCode设置

{
    "editor.fontLigatures": true,
    "editor.fontFamily": "Fira Code Light , Consolas, 'Courier New', monospace",
    "editor.maxTokenizationLineLength": 2000000,
    // 保存时自动格式化代码
    "editor.formatOnSave": true,
    // eslint配置项,保存时自动修复错误
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    },
    // 终端
    "terminal.integrated.profiles.windows": {
        "cmder": {
            "path": "C:\\WINDOWS\\System32\\cmd.exe"
        }
    },
    "terminal.integrated.defaultProfile.windows": "cmder",
    // json 最大编译值
    "json.maxItemsComputed": 500000,
    // 文件后缀支持
    "files.associations": {
        "*.tpl": "html"
    },
    "security.workspace.trust.emptyWindow": false,
    "security.workspace.trust.enabled": false,
    "editor.wordWrap": "on",
    /** 格式化 */
    "[json]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    /************** ESlint *****************/
    // "eslint.enable": true,
    "eslint.format.enable": true,
    "eslint.run": "onType",
    "eslint.nodePath": "",
    "eslint.options": {
        "extensions": [
            ".js",
            ".vue",
            ".ts",
            ".tsx"
        ]
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue"
    ],
    "eslint.codeAction.showDocumentation": {
        "enable": true
    },
    /************** Prettier *****************/
    // "editor.defaultFormatter": "esbenp.prettier-vscode",
    // #去掉代码结尾的分号
    // "prettier.semi": true,
    // #使用单引号替代双引号
    // "prettier.singleQuote": true,
    // "editor.fontWeight": null,
    // "explorer.confirmDelete": false,
    // "[html]": {
    //     "editor.defaultFormatter": "esbenp.prettier-vscode"
    // },
    // "less.compile": {
    //     "out": "${workspaceRoot}/"
    // },
    // // "[typescriptreact]": {
    // //     "editor.defaultFormatter": "esbenp.prettier-vscode"
    // // },
    // "[typescript]": {
    //     "editor.defaultFormatter": "esbenp.prettier-vscode"
    // },
    // "[javascript]": {
    //     "editor.defaultFormatter": "esbenp.prettier-vscode"
    // },
    // "js/ts.implicitProjectConfig.experimentalDecorators": true,
    // "[typescriptreact]": {
    //     "editor.defaultFormatter": "esbenp.prettier-vscode"
    // },
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值