Git Product home page Git Product logo

fis3-lint-eslint's Introduction

fis3-lint-eslint

npm version npm

基于 eslint 的 fis3 javascript linter。插件使用遵循 fis3 规则。


使用

安装

全局安装:

	npm install -g fis3-lint-eslint

安装到当前目录:

	npm install fis3-lint-eslint

配置

example:

// fis-conf.js

var eslintConf = {
	ignoreFiles: ['js/lib/**.js', 'js-conf.js'],
	envs: ['browser', 'node'],
	globals: ['$'],
	rules: {
		"semi": [1],
        "no-undef": [2]
        "no-use-before-define": [1],
        "no-unused-vars": [1],
        "no-eval": [1]
	}
};

fis.match('js/*.js', {
	lint: fis.plugin('eslint', eslintConf)
});

eslintConf 是对 eslint 的配置,参见 Configuring ESLint 。其属性类型参见 CLIEngine

eslintConf.ignoreFiles: 一个数组,配置应该忽略掉的文件。数组成员为目标文件的匹配规则,遵循 glob 语法。

默认配置

	{
	  "envs": ["browser", "node"],
	  "useEslintrc": false,
	  "ignoreFiles": ["fis-conf.js"],
	  "globals": [
	    "__inline",
	    "__uri",
	    "__RESOURCE_MAP__",
	    "fis"
	  ],
	  "rules": {
	      "no-undef": [2],
	      "no-use-before-define": [1],
	      "no-unused-vars": [1],
	      "no-eval": [1],
	      "use-isnan": [2],
	      "valid-typeof": [2],
	      "no-unreachable": [1],
	      "no-dupe-args": [1],
	      "no-dupe-keys": [1]
	  }
	}

当自定义配置的属性与默认配置属性相同时,除了 rulesglobals 会叠加外,其他属性值均被覆盖。

默认配置规则(rules)说明:

  • [no-undef] 变量不通过 var 进行声明或引用未定义变量。
  • [no-eval] 不使用 eval()。
  • [no-use-befor-define] 避免在变量定义之前使用变量。
  • [no-unused-vars] 变量声明但未使用。
  • [use-isnan] 判断一个数是否是NaN的时候不允许使用foo === NaN这样的操作,而是使用isNaN函数进行判断。
  • [valid-typeof] typeof的结果必须和一个有效的字符串进行比较,如typeof foo === 'strnig'即是不合法的字符串。
  • [no-unreachable] 不允许在return、throw、continue、break等中断语句之后出现代码。
  • [no-dupe-args] 方法的参数中不允许有重复值。
  • [no-dupe-keys] 定义对象时不允许有重复的键。

规则错误级别说明:

0 :关闭当前规则

1 :warning

2 :error

更多规则请参见 eslint rules

fis3-lint-eslint's People

Contributors

w3cmark avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.