0.2.1 • Published 8 years ago
eslint-config-finger v0.2.1
eslint-config-finger
Finger内部使用的,用于检测JavaScript代码
English Doc. : en
安装
# npm
npm install eslint-config-finger --save-dev
## OR
#yarn
yarn add eslint-config-finger --dev
基本使用
ES6
如果你使用了es6(es2015),es7的语法,没有使用任何框架(react, vue或angular2)
你只需要在你的eslint
配置文件中:
// .eslintrc
{
"extends": "finger"
}
React
如果你使用了react
框架。
你只需要在你的eslint
配置文件中:
// .eslintrc
{
"extends": "finger/react"
}
Vue
如果你使用了vue
框架。
你只需要在你的eslint
配置文件中:
// .eslintrc
{
"extends": "finger/vue"
}
通用
如果你就是一般的代码。
你只需要在你的eslint
配置文件中:
// .eslintrc
{
"extends": "finger/common"
}
高级使用
规则覆盖
如果你对项目中的一些配置不满意,可以任意修改:
// .eslintrc
{
"extends": "finger",
"rules": {
// your own rules configuration
}
}
特定环境
例如,你在项目中使用了mocha,当你写如下代码的时候:
describe("OwnClass", () => {
describe("#ownFunc", () => {
it('should return a boolean value', () => {
// some code
})
})
})
// error : You can not use `describe` before undefined.
// error : You can not use `it` before undefined.
这时候,你需要对eslint
配置文件进行修改:
{
"extends": "finger",
"env": ["mocha"]
}
这只是一个很常见的例子。
eslint
还有许多的环境参数,比如:jasmine
, jest
, commonjs
, prototypejs
等等。
最佳实践
在整个配置的设置上,我们并没有对代码的缩进大小
,缩进样式
和文件末尾是否加一空行
进行设置。
这些,我觉得并不属于eslint
的范畴,请使用EditorConfig进行配置。
常见问题
预待发现...