• Stars
    star
    491
  • Rank 89,636 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 15 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The JavaScript Code Quality Tool โ€” for Node.js.

node-jslint

Easily use JSLint from the command line.

  jslint bin/jslint.js

What's New

Added latest jslint, 2018-01-27.

Version 0.12.0 contains the latest jslint-es6

See CHANGELOG.md for detailed change history

Use the command-line client

Install (both local and global are supported)

npm i jslint

Use the default jslint

jslint lib/color.js

Always use the latest jslint

jslint --edition=latest lib/color.js

Use a specific edition

For example, edition 2013-02-03 which shipped with node-jslint 0.1.9:

jslint --edition=2013-02-03 lib/color.js

Use node-jslint programmatically

Streams interface

As of node-jslint 0.4.0, a streams interface is exposed. You can use it in client code like this:

Install as a dependency:

$ npm install --save jslint

Pull it into your code with require:

var LintStream = require('jslint').LintStream;

Create and configure the stream linter:

var options = {
    "edition": "latest",
    "length": 100
},
    l = new LintStream(options);

Send files to the linter:

var fileName, fileContents;
l.write({file: fileName, body: fileContents});

Receive lint from the linter:

l.on('data', function (chunk, encoding, callback) {
    // chunk is an object

    // chunk.file is whatever you supplied to write (see above)
    assert.deepEqual(chunk.file, fileName);

    // chunk.linted is an object holding the result from running JSLint
    // chunk.linted.ok is the boolean return code from JSLINT()
    // chunk.linted.errors is the array of errors, etc.
    // see JSLINT for the complete contents of the object

    callback();
});

You can only pass options to the LintStream when creating it. The edition option can be used to select different editions of JSLint.

The LintStream is in object mode (objectMode: true). It expects an object with two properties: file and body. The file property can be used to pass metadata along with the file. The body property contains the file to be linted; it can be either a string or a Buffer.

The LintStream emits 'data' events containing an object with two properties. The file property is copied from the file property that is passed in. The linted property contains the results of running JSLINT.

Simple interface

The simple interface provides an edition-aware loader. This can be used as a frontend to node-jslint's collection of editions of the JSLINT code.

var node_jslint = require('jslint'),
    JSLINT = node_jslint.load(edition);

This exposes the same loading interface used in node-jslint, so it supports the special edition names default and latest as well as date-based edition names such as 2013-08-26

As of version 0.5.0, the load function also accepts filenames. To be recognized as a filename, the argument to load must contain a path-separator character (/ or \) or end with the extension .js.

Usage examples

Multiple files

jslint lib/color.js lib/reporter.js

All JSLint options supported

jslint --white --vars --regexp lib/color.js

Defaults to true, but you can specify false

jslint --bitwise false lib/color.js

Pass arrays

jslint --predef $ --predef Backbone lib/color.js

JSLint your entire project

jslint '**/*.js'

Using JSLint with a config file

Start with the included jslint.conf.example file, name it jslint.conf and customize your options per project or copy it to $HOME/.jslint.conf to apply your setting globally

License

See LICENSE file.

More Repositories

1

upstage

A library for building web presentations.
JavaScript
36
star
2

xnu-speedstep-air

xnu-speedstep-air is a Lion kernel extension to keep my MacBook Air from overheating.
C++
27
star
3

pact

Vows macros for easy Node.js HTTP server testing.
JavaScript
13
star
4

dotfiles

Configuration files for reid's shell
Vim Script
12
star
5

rampant

Easy Node.js profiling on Mac OS X using Google Chrome Canary's frontend.
Shell
12
star
6

mock-utf8-stream

Mock readable and writable streams for UTF-8 text.
JavaScript
7
star
7

yui-scrolltabview

An extension of YUI TabView that uses a scroll animation to transition between tab content.
7
star
8

onyx

Static file server for Node.js.
JavaScript
6
star
9

decks

My presentations in Markdown. HTML awesome in gh-pages.
JavaScript
6
star
10

antiscroll

Remove scrollbars (not scrollback) from the Mac OS X Terminal.
Objective-C
6
star
11

ungadget

Transform a OpenSocial Gadget Specification's HTML into inline HTML.
PHP
4
star
12

stickerface

A silly Node.js experiment with Express, YUI 3 and OAuth
JavaScript
4
star
13

radarscope

MyBlogLog API library for lifestreaming applications.
PHP
4
star
14

yap-examples

Includes working code you can run on your own YAP playset!
3
star
15

hollywood

Make applications from plugins.
JavaScript
3
star
16

upstage-yuiconf2011

Easy HTML slideshows at YUIConf 2011!
3
star
17

shopper

Visual eBay search.
3
star
18

reid.github.com

2
star
19

yui3-seed

Just the seed, ma'am.
2
star
20

sparky-selleck

Selleck theme adapted from Spark Docs
CSS
2
star
21

dinoboard

YUI based TV widgets
2
star
22

upcoming-attendees

Web service for information about Upcoming.org event attendees
PHP
2
star
23

weekend-bp

Sample Blueprint application
2
star
24

intate

Homemade goodness for your friends.
JavaScript
2
star
25

timebox

Countup timer for the Arduino with a Sure 0832. Great for conferences.
Java
2
star
26

flickrshout

A gadget for posting recent Flickr photos as social activity using OpenSocial.
JavaScript
2
star
27

yui-inspector

Inspect YUI.use on pages you visit in Google Chrome.
JavaScript
1
star
28

findluk.com

Website about Luke Arduini's disappearance
1
star