skip to navigation
skip to content

gocept.jslint 1.0

Python-unittest integration for jslint.

Downloads ↓

Latest Version: 1.1

This package integrates Douglas Crockford's JSLint tool (https://jslint.com) with Python's unittest module.

It provides a special JSLint-TestCase class that collects JavaScript files (in a configurable manner) and dynamically generates a test method for each file that calls jslint on that file.

To use it, create a test class like this:

class MyJSLintTest(gocept.jslint.TestCase):

    include = ('my.package.browser:js',
               'my.package.browser:js/lib')
    options = (gocept.jslint.TestCase.options +
               ('--predef=jQuery',))

include is a list of "resource paths" of the form packagename:path (passed to pkg_resources).

options is a list of arguments that are passed to JSLint (see its documentation for details). The default value is:

options = (
    '--browser',
    '--continue',
    '--newcap',
    '--nomen',
    '--sloppy',
    '--sub',
    '--unparam',
    '--vars',
    '--white',
    )

exclude can be a list of filenames (without path) that will not be collected.

All files ending in .js contained in each of these paths will be collected, and the test class will grow a method named test_jslint_filename.js.

You can ignore JSLint error by setting ignore on the test class (a list of substrings that are matched against each JSLint output line):

ignore = (
"Use a named parameter", )

Requirements

gocept.jslint requires Python 2.6 or later, but is not sure to run under Python 3.

gocept.jslint uses node.js to run jslint (powered by the jslint-reporter wrapper for the original JSLint script), so you need to have node.js (version 0.3 or later) installed and the node binary available on your $PATH.

You can customize the name of the node.js binary by setting node_js_command on the TestCase.

gocept.jslint also provides a command-line script to run jslint, for convenience. There you can customize the name of the node binary by setting the environment variable NODE_JS_COMMAND.

CHANGES

1.0 (2011-08-25)

  • Add support for linting JS files contained in zipped eggs (#9453).
  • Add an entry point for running jslint from the command line (#9449).
  • Skip tests if node.js is not available. Skipping tests only works properly in Python >= 2.7, though. (#9458)

0.2 (2011-08-24)

  • Implement custom error ignores (#9456).

0.1 (2011-08-10)

  • first release.
 
File Type Py Version Uploaded on Size # downloads
gocept.jslint-1.0.tar.gz (md5) Source 2011-08-25 52KB 309