0.2.0 • Published 8 years ago
check-syntax v0.2.0
check-syntax
Checks the syntax of an entry point and it's (application-level) dependencies as per the currently installed Node version.
About
The node -c command allows us to check the syntax of a single file.
The check-syntax module allows us to check the syntax of all the files
in a dependency tree (excluding any dependencies in the node_modules folder).
CLI
Install
npm install -g check-syntaxUse
check-syntax <entry-point>API
Install
npm install check-syntaxUse
var checkSyntax = require('check-syntax')
var someEntryPoint = 'my/js/file.js'
console.log(checkSyntax(someEntryPoint)) // outputs an array of objects, {loc, code, msg}Reporter
To use the CLI reporter programatically:
var report = require('check-syntax/report')
var someEntryPoint = 'my/js/file.js'
report(someEntryPoint) // same as output as check-syntax command, will exit immediately If a pass callback is supplied, the process won't exit but
instead will call the callback with the first arg set to either true
or false based on whether the syntax check was successful.
report(someEntryPoint, (pass) => {
if (pass) console.log('hooray')
else console.log('boo')
})License
MIT