This package has been deprecated

    Author message:

    Deprecated.Use @xgfe/lint-plus instead

    lint-plus

    0.6.12 • Public • Published

    lint-plus

    lint-plus = xg-htmlhint+xg-csslint+eslint

    Install

    From NPM for use as a command line app:

    $ [sudo] npm install lint-plus -g
    

    From NPM for programmatic use:

    $ npm install lint-plus
    

    Usage

    Use in command line

    $ linter [check] dir/               # lint entire directory
    $ linter test.html src/ index.js    # lint files 
    $ linter -c configfile test.html    # custom config file
    $ linter path/to/file --fix/-f      # fix error code in js file
    

    Use in your application

    var linter = require('linter-plus');
    

    API Reference

    async func
    function done (success,json,errors,warnings,errorFile,totalFile){
      console.log('isSuccess: %s',success);
      var messages;
      for(var i in json){
        messages = json[i];
        console.log('file %s has problem.',i);
        messages.forEach(function (message) {
          console.log('lint type: %s',message.type);
          console.log('problem severity: %s',message.severity);//2-error,1-warn,0-info
          console.log('line: %s',message.line);
          console.log('col: %s',message.col);
          console.log('error message: %s',message.message);
          console.log('rule: %s',message.rule);
        });
      }
      console.log('Found %s error%s,%s warning%s in %s of %s file%s.',
        errors,
        errors > 1 ? 's' : '',
        warnings,
        warnings > 1 ? 's' : '',
        errorFile,
        totalFile, totalFile > 1 ? 's' : ''
      );
    }
    var options = {
      _:["test.html","test.js"],
      config:'path/to/my/config_file'
    };
    var stream = linter.check(options,done);
    stream.on('lint',function(filepath,messages){
      console.log('file path is %s',filepath);
      console.log('messages in this files are as below:');
      console.log(messages);
    });
    
    sync func
    var messages = linter.checkSync(["test.html","test.js"]);
    

    Config File Template

    default to read .lintrc file.

    {
      "html":false,     // set false means disallow js checker
      "css":{  // csshint config 
        "extends":["../path/to/other/css/config"]
        "suffix": "css",
        "ignore":["hehe.js","test/*.js"],   // files to be ignored,array or glob string
        "rules":{
          "a-line-of-decl": {"level": 1},
          "disallow-use-expression": {"level": 1},
          "vendor-prefixes-sort": {"level": 1}
        }
      },
      "js":{
        "extends":"eslint:recommended"   // extends config
      }
    }
    

    Note:config file can be js or json file.js files must be a node module,contents are as follows.

    module.exports = {
      html:false,
      "css":{},
      js:{
        extends:"eslint:recommended"
      }
    };
    

    Develop Guide

    开发文档

    Config File

    配置文件说明

    License

    MIT

    Thanks

    Install

    npm i lint-plus

    DownloadsWeekly Downloads

    6

    Version

    0.6.12

    License

    MIT

    Unpacked Size

    63.2 kB

    Total Files

    32

    Last publish

    Collaborators

    • yangjiyuan