# 安裝ESlint ###### tags: `LineBot` 1. **安裝<a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint">ESLint-VScode套件</a>** 用於安裝eslint 2. **安裝enlint 指令:"npm i -D eslint"** -D為開發者工具,套件只限於此資料夾專案用的到。 會記錄在 package.json *筆記"終端機 node.js"有說明* 3. **按`f1` 輸入 ESlint** 選擇 create ESlint configuration (建立ESlint設定) ![](https://i.imgur.com/v0LOSTt.png) 注意:安裝的時候必須選擇要安裝的資料夾 問題: ``` How would you like to use ESLint? ... To check syntax only (檢查語法) To check syntax and find problems (檢查語法+找到問題) > To check syntax, find problems, and enforce code style(檢查語法找到問題並強制程式碼風格規範) ``` ``` ? What type of modules does your project use? ... 專案用哪一種語法? > JavaScript modules (import/export) CommonJS (require/exports) None of these ``` ``` ? Which framework does your project use? ... 有沒有使用任何框架? React Vue.js > None of these ``` ``` ? Does your project use TypeScript?專案是否有使用TypeScript » No / Yes ``` ``` ? Where does your code run? ... (Press <space> to select, <a> to toggle all, <i> to invert selection)程式碼是在哪裡跑? Browser 瀏覽器 √ Node node.js ``` ``` ? How would you like to define a style for your project? ... 怎麼定義專案的程式碼風格? > Use a popular style guide 用已經別人定義好的規範 Answer questions about your style 自己定義(後面會有問題) ``` ``` 選擇語法規範 Airbnb: https://github.com/airbnb/javascript > Standard: https://github.com/standard/standard Google: https://github.com/google/eslint-config-google XO: https://github.com/xojs/eslint-config-xo ``` ``` ? What format do you want your config file to be in? ... ESlint要用什麼語法格式? JavaScript YAML > JSON ``` ``` eslint-config-standard@latest eslint@^8.0.1 eslint-plugin-import@^2.25.2 eslint-plugin-n@^15.0.0 eslint-plugin-promise@^6.0.0 安裝需要的東西 ? Would you like to install them now? No / »Yes ``` ``` Which package manager do you want to use? 你要用哪一種套件管理工具 · npm ``` 安裝完會新增一個"eslintrc.json"檔案 ![](https://i.imgur.com/SMvqacq.png) ![](https://i.imgur.com/xI80bjC.png)