e2

滴滴侠,fai抖

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.eslint简介

eslint是用来管理和检测js代码风格的工具,可以和编辑器搭配使用,如vscode的eslint插件

当有不符合配置文件内容的代码出现就会报错或者警告

2.安装eslint

npm init -y

npm install eslint --save-dev

./node_modules/.bin/eslint --init 初始化配置文件

此配置文件配置好之后,vscode编辑器自动识别

No ESLint configuration found的问题就解决了。

3.此时如果报错Failed to load plugin node: Cannot find module 'eslint-plugin-node'

替换.eslintrc.js中内容

 

 


module.exports = {

"env": {

"browser":true,

"es6":true,

"node":true

},

"extends":"eslint:recommended",

"parserOptions": {

"ecmaVersion":2015,

"sourceType":"module"

},

"rules": {

// 缩进

"indent": [

"error",

4 //我的是编辑器自动格式化,不是使用tabs,而是四个空格

],

"linebreak-style": [

"error",

"windows"

],

// 引号

"quotes": [

1,

"single"

],

// 分号结尾

"semi": [

"error",

"always"

],

"no-unused-vars": [2, {

// 允许声明未使用变量

"vars":"local",

// 参数不检查

"args":"none"

}],

// 最大空行100

"no-multiple-empty-lines": [0, {"max":100 }],

"no-mixed-spaces-and-tabs": [0],

//不能使用console

"no-console":'off',

//未定义变量不能使用

"no-undef":0,

//一行结束后面不要有空格

"no-trailing-spaces":1,

//强制驼峰法命名

"camelcase":2,

//对象字面量项尾不能有逗号

"comma-dangle": [2, "never"],

//this别名

"consistent-this": [2, "that"],

}

};


 

参考文档:

https://www.cnblogs.com/ye-hcj/p/7069505.html

https://blog.csdn.net/caomage/article/details/81094958

posted on 2022-05-03 19:26  纯黑Se丶  阅读(711)  评论(0编辑  收藏  举报