eslint初始化配置

1、安装:npm install eslint --save-dev

2、./node_modules/.bin/eslint --init命令初始化eslint;

3、(1)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 // 检查语法错误,发现问题代码,校验代码风格

              选第三个,检查语法错误,发现问题代码,校验代码风格

      (2)What type of modules dos your project use?

JavaScript modules (import/export) // ESM:允许使用import/export
CommonJS (require/exports) // CommonJS:允许使用require/exports
> None of these // 没有用到任何模块化

选第一个,import/export

      (3)Which framework does you project use?

               React

               Vue.js

               > None of these

               选vue

      (4)Does your project use TypeScript? No / Yes

               输入yes

      (5)Where does you code run? // 多选

(*) Browser // 浏览器环境

(*) Node // node环境

选浏览器

      (6)How would you like to define a style for your project?

> Use a popular style guide // 使用一个市面上的主流风格
Answer questions about your style // 通过回答问题,形成一个风格
Inspect your JavaScript file(s) // 根据JS代码文件,推断代码风格

选第一个,市面主流风格

      (7)Which style guide do you want to follow?

Airbnb: https://github.com/airbnb/javascript
> Standard: https://github.com/standard/standard
Google: https://github.com/google/eslint-config-google

选第二个,开源

原文地址:https://www.cnblogs.com/luchangzhu/p/15232513.html