项目作者: guoweiTang

项目描述 :
a base eslint plugin for fis3
高级语言: JavaScript
项目地址: git://github.com/guoweiTang/fis3-lint-rich-eslint.git
创建时间: 2017-12-11T09:49:54Z
项目社区:https://github.com/guoweiTang/fis3-lint-rich-eslint

开源协议:MIT License

下载


fis3-lint-rich-eslint

The fis3-lint-rich-eslint library exported as a fis3 plugin.

npm
node
npm

Installation

  1. $ npm install fis3-lint-rich-eslint [--save-dev]

Usages

  1. fis.match('*.js', {
  2. lint: fis.plugin('rich-eslint'[, options])
  3. })
  4. /**
  5. * The tool exposes an object containing the exception information through the 'fis.set("ESLINT_RESULT",obj)' method.
  6. * Get it through 'fis.get("ESLINT_RESULT")' method,
  7. * and it has two attributes that are 'errCount' and 'totalCount', as follows:
  8. */
  9. fis.match('::package', {
  10. prepackager: function(content, file, settings) {
  11. let eslintErrCount = fis.get('ESLINT_RESULT.errCount');
  12. // Exit the program when there is a eslint error.
  13. if (eslintErrCount) {
  14. process.exit()
  15. }
  16. return content;
  17. }
  18. })

See the options what is same as eslint CLIEngine for more details.

Default configs

  1. {
  2. 'fix': false,
  3. 'allowOutfixed': false,
  4. 'envs': envs,
  5. 'globals': [
  6. '__inline',
  7. '__uri',
  8. '__RESOURCE_MAP__',
  9. 'fis'
  10. ],
  11. 'ignoreFiles': [
  12. 'bower_components/**',
  13. 'node_modules/**',
  14. 'lint-fixed/**',
  15. 'js-conf.js'
  16. ],
  17. 'useEslintrc': false,
  18. 'rules': rules
  19. }

Globals and ignoreFiles are non-overlay, but envs is overlay.

Envs

The value refer to configuration of eslint-config-lagou.

allowOutfixed: Boolean | [Boolean, options]

Output the restored file to the directory ‘/lint-fixed/**’, the premise is that the value of fix is true.

options

  • 'root': true Get root permissions, it will modify the source file,this operation does’t promise correctness, so be careful!!!
  • 'dirname': '/lint-fixed' Specify the root directory of the repaired file output

    ignoreFiles: [String]

    Glob patterns for paths to ignore.
    Be careful the property named ignorePattern is discarded.

Rules

As mentioned above, the following is introduce of rules:

Eslint-config-lagou

Editing rules from within your js

You can use annotation to add configuration for the specilfied file, like the following:

  1. /* eslint-env node, mocha */
  2. //dosomething...
  1. /* global var1, var2 */
  2. //dosomething...
  1. /* eslint eqeqeq: 'off', curly: 'error' */
  2. //dosomething...
  1. /* eslint-disable */
  2. alert('foo');
  3. /* eslint-enable */