Skip to content

ffe-team/eslint-config-finger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, vueangular2)

你只需要在你的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等等。

具体请参见Specifying Environments

最佳实践

在整个配置的设置上,我们并没有对代码的缩进大小缩进样式文件末尾是否加一空行进行设置。

这些,我觉得并不属于eslint的范畴,请使用EditorConfig进行配置。

常见问题

预待发现...