Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
[deprecared] Code quality tools collection in one nodejs module
Python JavaScript
tree: da3d8eb7d4

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
conf
deps
lib
test
.gitignore
.gitmodules
Makefile
index.js
package.json
readme.md

readme.md

Linter - code quality tool for javascript.

Linter doesn't implement validators - it utilizes free available quality tools. Javascript lang is too flexible and it becomes very hard to work in larger teams, especially if some of members are newbie on javascript. Linter is highly configurable, so if you don't want to use some rules, you can create your own conf file. You can easily add more quality tools.

Features

  • all rules can be defined in one configuration ".json" file
  • you can create many conf. files, because you might have different rules for different environments f.e. server and client.
  • it uses all available linter, if you have one more - you can add it
  • unified errors reporting format

TODO

  • implement generic filter, to enable linter wrappers to ignore some options, which are not customizable by original linter
  • probably one generic way to turn off any option in any file using comments (jslint like)
  • add html linter, e.g. https://github.com/kangax/html-minifier
  • add css linter
  • somehow have javascript lint's options in the config file (currently you'd have to specify your own configuration file in javascript lint's own style.).

Currently used tools

Error message descriptions

Installation

npm install linter

Usage

command line - print help and read about usage

$ linter -h 

api

var linter = require('linter');

linter.run({
    files: "/path/to/file" // can be an array or directory
    config: "conf/server.json" // can be an object, path to a conf.json or config name e.g. "server"
    confRoot: "/path/to/linter/predef/configs", per default is linter "conf" dir
    recursive: false, // read dir recursively, default to false
    format: false, // set to true if you want to get a string as errors argument, formatted for console output
    // callback functions, which is called on complete and errors array is passed
    // see ./bin/cli.js
    callback: function(errors) {
        console.log(errors);
    },
});

Config file

  • You can create a config file which contains all rules for every validator.
  • See ./conf/server.json for examples
  • *.json configs can have comments in it

Unified error format

Errors array passed to callback contains objects in this format:

{
    linter: "validator name",
    file: "file name",
    message: "error message",
    line: "line number"
}

How to add more linters

  • put the linter into ./deps/linter-name
  • write a wrapper for it and put it into ./lib/linter/linter-name.js
  • wrapper should implement one function

    module.exports = function(file, options, callback){
    
    };
    
  • wrapper should talk with validator and on complete call the callback and pass errors array in unified error format

  • see ./lib/linter/jslint.js for an example
  • option for new validator in json should have name

    {
        "validator-name": {  
            "some-option": true 
        }  
    }
    

License

  • node-linter - MIT
  • jslint - read ./deps/JSLint/fulljslint.js
  • closure-linter and closure-compiler - Apache License, Version 2.0
  • javascript lint - ?
Something went wrong with that request. Please try again.