Detalhes do pacote

jslint

reid409.9kBSD-3-Clause0.12.1

The JavaScript Code Quality Tool

lint, jslint, code-quality, static-analysis

readme (leia-me)

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.

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.12.1 (2019-01-28)

Update to es6 latest (2018-11-28)

Node doesn't like the 'export default' syntax, so I hacked it to use 'var'.

Update dependencies

  • mocha => 5.2.0
  • glob => 7.1.3
  • nopt => 4.0.1
  • marked-man => 0.2.1

0.12.0 (2018-02-03)

Update to es6 latest (2018-01-27)

0.10.3 (2016-08-03)

Bug Fixes

  • lib/jslint-es6: update jslint-es6 to latest upstream, 2016-07-13 (7ec74b6)
  • package.json: add license, update deps (55baa7b)

0.10.2 (2016-07-30)

Bug Fixes

  • package.json: add license, update deps (55baa7b)

Before 2016-07-30

Version 0.9.0 contains the new BETA version of jslint for EcmaScript 6, which is a ground-up rewrite by Douglas Crockford. The latest alias still points to the last es5 version of jslint; you can also use --edition=es5 to get the (old) es5 version. To get the es6 version you must use --edition=es6.

2015-07-29 Sam Mikes smikes@cubane.com

    * lib/jslint-es6.js: latest jslint from upstream
    * lib/nodelint.js, test/regression.js: correctly report edition for post-es6 jslints, 
    thanks to @bryanjhv for the bug report and fix

2015-02-19 Sam Mikes smikes@cubane.com

* lib/main.js, test/main.js: new option --no-filter to allow linting paths containing 'node_modules'

2014-12-16 Sam Mikes smikes@cubane.com

* lib/collector.js: new programmatic interface for collecting lint
* lib/main.js, lib/nodelint.js: add callback to `runMain`, publicize

2014-10-22 Sam Mikes smikes@cubane.com

* test/regression.js: add file for misc github issues tests
* package.json: avoid using prepublish

2014-09-10 Marshall Thompson marshall.w.thompson.iv@gmail.com

* update jslint-latest to upstream edition 2014-07-08

2104-04-13 Sam Mikes smikes@cubane.com

* lib/linter.js: Fix issue #88 - support user-specified config file, support
 jslint.conf and .jslint.conf in addition to jslintrc, .jslintrc 

2014-01-30 Sam Mikes smikes@cubane.com

* lib/linter.js: Fix Issue #80 - crash on empty jslintrc
Underlying issue was test-then-read rather than just attempting to
read and parse config, catching exceptions.

2014-01-27 Sam Mikes smikes@cubane.com

* Version 0.2.8 - update jslint-latest to upstream edition 2014-01-26

2013-12-18 Sam Mikes smikes@cubane.com

* Version 0.2.6 - move code from src/jslint.js to lib/main.js
Update list of options in jslint.md
Remove incorrect options from jslintrc.example (https://github.com/reid/node-jslint/issues/76)
Document & enable use of --todo flag (https://github.com/reid/node-jslint/issues/76)

Version 0.7.0 creates a new programmatic interface which is used by https://github.com/hapijs/lab

Version 0.5.1 fixes a regression which crashes jslint when more than maxerr errors are in a single file. Thanks to Vasil Velichkov (@velichkov) for pointing this out.

Version 0.5.0 reorganizes the loading interface, making it easier for other projects to use node-jslint to load a specific jslint edition.

Version 0.4.0 exposes a stream interface to jslint.

Version 0.3.4 supports globbing with and * expressions.

Versions 0.2+ provide multiple editions of jslint to address backwards and forwards compatibility.