安装eslint,根目录下执行:
F:\my\temp> npm install eslint --save-dev
初始化eslint,会生成一个.eslintrc.js
配置文件,执行:
F:\my\temp> F:\my\temp\node_modules\.bin\eslint --init
运行,对某个文件进行静态检查:
F:\my\temp> F:\my\temp\node_modules\.bin\eslint youfile.js
也可以使用通配符对多个文件进行静态检查:
F:\my\temp> F:\my\temp\node_modules\.bin\eslint *.js
对于不想检查的文件,也可以在根目录下新建一个.eslintignore
文件列出:
test/**
build/**
*.spec.js
app/index.html
app/static/**
注意:如果安装过程出错,可以检查一下是否是node版本太低所致。