Quickly check syntax errors with acorn ( syntax-error ) - if this fails your code is definitely not going to work, probably.
Default ECMAScript version is 6 ( 2015 ) - change it with -e <number>
argument variable
passlint **/*.js && echo 'no javascript errors was found'
passlint **/*.css && echo 'no css errors was found'
passlint **/*.js **/*.css
components/mics.js:245:7: SyntaxError: Unexpected token (245:7)
js/admin-controller.js:2:1: SyntaxError: Unexpected token (2:1)
public/bundle.css:40:20: error: Expected RBRACE at line 40, col 20.
var passlint = require( 'passlint' )
var defaultEcmaVersion = 6 // 2015
var filename = 'test/output.js'
var text = require( 'fs' ).readFileSync( filename, 'utf8' )
var errline = passlint( text, defaultEcmaVersion )
if ( errline ) console.error( filename + errline )
test/output.js:484:40: SyntaxError: Unexpected token (484:40)
stage/bundle-error.css:182:10: error: Expected COLON at line 182, col 10.
var passlint = require( 'passlint' )
var filename = 'stage/bundle-error.css'
var text = require( 'fs' ).readFileSync( filename, 'utf8' )
var errline = passlint( text, 'css' )
if ( errline ) console.error( filename + errline )
stage/bundle-error.css:182:10: error: Expected COLON at line 182, col 10.
$ passlint --help
Usage: passlint [optinos]
Arguments:
--ecma-version, -e <number> specify ecma version to check against
defaults to 6 ( 2015 )
example: `passlint -e 6 src/**`
--version, -V print version and exit
--help, -h help ( this text )
locally ( project specific, for use with npm scripts )
npm install passlint
globally
npm install -g passlint
To quickly capture absolutely essential errors. Some projects have messy or no linting rules at all. Even with linting setup not everything gets fixed or gets forgotten.
passlint is the dirty final gate that needs to be passed for your code to run regardless of style rules.
You can use node's -c
flag for similar functionality.
Note the variablity between node versions, passlint tests against ES 2015 by default
and also formats the output more concisely.
node -c **/*.js
npm test