Standard JS 参考手册
常见问题 | FAQ
Is there a Node.js API?
有Node.js API吗?
是!
standard.lintText(text, [opts], callback)
提供所提供的来源text。opts可以提供一个对象:
{ cwd: '', // current working directory (default: process.cwd()) filename: '', // path of the file containing the text being linted (optional, though some eslint plugins require it) fix: false, // automatically fix problems globals: [], // custom global variables to declare plugins: [], // custom eslint plugins envs: [], // custom eslint environment parser: '' // custom js parser (e.g. babel-eslint)}
package.json如果找到当前工作目录,则可以加载其他选项。
该callback会与被调用Error和results对象。
该results对象将包含以下属性:
var results = { results: [ { filePath: '', messages: [ { ruleId: '', message: '', line: 0, column: 0 } ], errorCount: 0, warningCount: 0, output: '' // fixed source code (only present with {fix: true} option) } ], errorCount: 0, warningCount: 0}
results = standard.lintTextSync(text, [opts])
同步版本standard.lintText()。如果发生错误,则抛出异常。否则,results返回一个对象。
standard.lintFiles(files, [opts], callback)
提供所提供的全球files。opts可以提供一个对象:
var opts = { ignore: [], // file globs to ignore (has sane defaults) cwd: '', // current working directory (default: process.cwd()) fix: false, // automatically fix problems globals: [], // global variables to declare plugins: [], // eslint plugins envs: [], // eslint environment parser: '' // js parser (e.g. babel-eslint)}
在callback将与一个被调用Error和results对象(与上述相同)。
加载中,请稍侯......