{"id":21329,"date":"2024-11-19T15:24:50","date_gmt":"2024-11-19T07:24:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21329\/"},"modified":"2024-11-19T15:24:50","modified_gmt":"2024-11-19T07:24:50","slug":"vscode%e4%bb%a3%e7%a0%81%e6%a0%bc%e5%bc%8f%e5%8c%96%e6%80%8e%e4%b9%88%e6%94%b9%e8%a7%84%e8%8c%83","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21329\/","title":{"rendered":"vscode\u4ee3\u7801\u683c\u5f0f\u5316\u600e\u4e48\u6539\u89c4\u8303"},"content":{"rendered":"<blockquote><p>\n  \u901a\u8fc7\u5b89\u88c5 eslint \u63d2\u4ef6\uff0c\u521b\u5efa\u6216\u7f16\u8f91 .eslintrc \u6587\u4ef6\u6765\u914d\u7f6e\u89c4\u5219\uff0c\u8fd0\u884c eslint \u547d\u4ee4\u4fee\u590d\u4ee3\u7801\uff0c\u4fdd\u5b58\u5e76\u63d0\u4ea4\u66f4\u6539\uff0c\u5373\u53ef\u66f4\u6539 visual studio code \u4e2d\u7684\u4ee3\u7801\u683c\u5f0f\u89c4\u8303\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052710153166662.jpg\" class=\"aligncenter\" title=\"vscode\u4ee3\u7801\u683c\u5f0f\u5316\u600e\u4e48\u6539\u89c4\u8303\u63d2\u56fe\" alt=\"vscode\u4ee3\u7801\u683c\u5f0f\u5316\u600e\u4e48\u6539\u89c4\u8303\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u66f4\u6539 Visual Studio Code \u4e2d\u7684\u4ee3\u7801\u683c\u5f0f\u89c4\u8303<\/strong><\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u5b89\u88c5 ESLint \u63d2\u4ef6<\/strong><\/p>\n<p>\u5728 Visual Studio Code \u4e2d\uff0c\u8f6c\u5230\u6269\u5c55\u7a0b\u5e8f\u9762\u677f\u5e76\u641c\u7d22\u201cESLint\u201d\u3002\u5b89\u88c5 ESLint \u63d2\u4ef6\u3002<\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u521b\u5efa\u6216\u7f16\u8f91 .eslintrc \u6587\u4ef6<\/strong><\/p>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a .eslintrc \u7684 JSON \u6587\u4ef6\u3002\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u6b64\u6587\u4ef6\uff0c\u5219\u6253\u5f00\u5b83\u3002<\/p>\n<p><strong>\u6b65\u9aa4 3\uff1a\u914d\u7f6e\u89c4\u5219<\/strong><\/p>\n<p>\u5728 .eslintrc \u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0 &#8220;rules&#8221; \u5bf9\u8c61\u3002\u5728\u6b64\u5bf9\u8c61\u4e2d\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u5404\u79cd\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u8981\u542f\u7528\u5355\u5f15\u53f7\u89c4\u5219\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>{\n  \"rules\": {\n    \"quotes\": [\"error\", \"single\"]\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 4\uff1a\u8fd0\u884c ESLint<\/strong><\/p>\n<p>\u6309 Ctrl + Shift + P \u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002\u8f93\u5165\u201cESLint: Fix All Files\u201d\u547d\u4ee4\u3002\u8fd9\u5c06\u6839\u636e .eslintrc \u6587\u4ef6\u4e2d\u7684\u89c4\u5219\u5bf9\u9879\u76ee\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u8fd0\u884c ESLint \u5e76\u81ea\u52a8\u4fee\u590d\u95ee\u9898\u3002<\/p>\n<p><strong>\u6b65\u9aa4 5\uff1a\u4fdd\u5b58\u5e76\u63d0\u4ea4\u66f4\u6539<\/strong><\/p>\n<p>\u4fdd\u5b58 .eslintrc \u6587\u4ef6\u5e76\u5c06\u5176\u63d0\u4ea4\u5230\u7248\u672c\u63a7\u5236\u4e2d\u3002\u73b0\u5728\uff0c\u4f60\u7684\u9879\u76ee\u5c06\u4f7f\u7528\u6307\u5b9a\u7684\u4ee3\u7801\u683c\u5f0f\u89c4\u8303\u8fdb\u884c\u683c\u5f0f\u5316\u3002<\/p>\n<p><strong>\u63d0\u793a:<\/strong><\/p>\n<ul>\n<li>\u4f60\u53ef\u4ee5\u4f7f\u7528 ESLint \u5b98\u65b9\u6587\u6863\u67e5\u770b\u66f4\u591a\u53ef\u7528\u7684\u89c4\u5219\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u914d\u7f6e\u66f4\u9ad8\u7ea7\u7684\u89c4\u5219\uff0c\u53ef\u4ee5\u4f7f\u7528 Prettier \u63d2\u4ef6\u3002<\/li>\n<li>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u9700\u8981\u5728\u7528\u6237\u8bbe\u7f6e\u4e2d\u624b\u52a8\u914d\u7f6e ESLint \u624d\u80fd\u770b\u5230\u9519\u8bef\u548c\u8b66\u544a\u3002\u8f6c\u5230\u201c\u8bbe\u7f6e\u201d&gt;\u201c\u7528\u6237\u8bbe\u7f6e\u201d\uff0c\u7136\u540e\u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165\u201ceslint\u201d\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4ee3\u7801\u683c\u5f0f\u5316\u600e\u4e48\u6539\u89c4\u8303\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u5b89\u88c5 eslint \u63d2\u4ef6\uff0c\u521b\u5efa\u6216\u7f16\u8f91 .eslintrc \u6587\u4ef6\u6765\u914d\u7f6e\u89c4\u5219\uff0c\u8fd0\u884c eslint \u547d\u4ee4\u4fee\u590d\u4ee3\u7801\uff0c\u4fdd\u5b58\u5e76\u63d0\u4ea4\u66f4\u6539\uff0c\u5373\u53ef\u66f4\u6539 visual studio code \u4e2d\u7684\u4ee3\u7801\u683c\u5f0f\u89c4\u8303\u3002 \u5982\u4f55\u66f4\u6539 Visual Studio Code \u4e2d\u7684\u4ee3\u7801\u683c\u5f0f\u89c4\u8303 \u6b65\u9aa4 1\uff1a\u5b89\u88c5 ESLint \u63d2\u4ef6 \u5728 Visual Studio Code \u4e2d\uff0c\u8f6c\u5230\u6269\u5c55\u7a0b\u5e8f\u9762\u677f\u5e76\u641c\u7d22\u201cESLint\u201d\u3002\u5b89\u88c5 ESLint \u63d2\u4ef6\u3002 \u6b65\u9aa4 2\uff1a\u521b\u5efa\u6216\u7f16\u8f91 .eslintrc \u6587\u4ef6 \u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a .eslintrc \u7684 JSON \u6587\u4ef6\u3002\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u6b64\u6587\u4ef6\uff0c\u5219\u6253\u5f00\u5b83\u3002 \u6b65\u9aa4 3\uff1a\u914d\u7f6e\u89c4\u5219 \u5728 .eslintrc \u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0 &#8220;rules&#8221; \u5bf9\u8c61\u3002\u5728\u6b64\u5bf9\u8c61\u4e2d\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u5404\u79cd\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u8981\u542f\u7528\u5355\u5f15\u53f7\u89c4\u5219\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a { &#8220;rules&#8221;: { &#8220;quotes&#8221;: [&#8220;error&#8221;, &#8220;single&#8221;] } } \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 4\uff1a\u8fd0\u884c ESLint [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21329","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21329"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21329\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}