这篇文章基础讲的很好:link
补充:
使用自己上传的eslint:
- 自己定义一个eslint
目录如下
// my-config.js
module.exports = {
extends: 'eslint:recommended',
env: {
node: true,
es6: true
},
rules: {
'no-console': 'error',
'indent': [ 'error', 4 ],
'quotes': [ 'error', 'single' ]
}
};
// package.json
{
"name": "eslint-config-my0312lzw",
"version": "1.0.0",
"description": "",
"main": "my-config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "yourName",
"license": "MIT"
}
按照npm login、npm publish步骤,进行上传,这里不展开。
2. 上传之后,在需要的项目进行安装
npm install eslint-config-my0312lzw --save-dev
项目目录大概如下:
3. 在.eslintrc.js文件种使用已经上传过的包
module.exports = {
'extends': 'eslint-config-my0312lzw',
};