使用JavaScript Standard Style 风格管理web代码规范
1.先安装eslint-config-standard
2.选择eslint --init初始化的时候必须选择第三项才有会保存自动修正代码效果
3.可根据自身条件安装相应的插件
eg: 建议使用yarn 安装依赖
λ eslint --init
√ How would you like to use ESLint? · style
√ What type of modules does your project use? · none
√ Which framework does your project use? · vue
√ Does your project use TypeScript? · `No` / Yes
√ Where does your code run? · `browser`
√ How would you like to define a style for your project? · `guide`
√ Which style guide do you want to follow? · `standard`
√ What format do you want your config file to be in? · `JavaScript`
Checking peerDependencies of eslint-config-standard@latest
√ The style guide "standard" requires eslint@^7.12.1. You are currently using eslint@5.16.0.
Do you want to upgrade? · No / `Yes`
The config that you've selected requires the following dependencies:
# 依赖
eslint-plugin-vue@latest eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 || ^5.0.0
√ Would you like to install them now with npm? · `No` / Yes
使用
JavaScript Standard Style
风格管理web代码规范 1.先安装eslint-config-standard
2.选择eslint --init
初始化的时候必须选择第三
项才有会保存自动修正代码效果 3.可根据自身条件安装相应的插件eg: 建议使用yarn 安装依赖
再配合eslint 自动格式化就完美了. !!! 如果不生效, 请注意依赖是否全部安装完成, 可以跑下项目, 看有没校验.
修复旧代码
eslint --fix src
src 为修复文件目录, 更多命令去官网查看资源