-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathtest-lint.js
More file actions
executable file
·34 lines (26 loc) · 1.22 KB
/
test-lint.js
File metadata and controls
executable file
·34 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
// ---------------------------------------------------------------------------------------------------------------------
// This script is intended to contain all actions pertaining to code style checking, linting and normalization.
// ---------------------------------------------------------------------------------------------------------------------
const chalk = require('chalk'),
{ ESLint } = require('eslint'),
LINT_SOURCE_DIRS = [
'./test/**/*.js',
'./index.js',
'./lib/**/*.js',
'./npm/**/*.js'
];
module.exports = async function (exit) {
// banner line
console.info(chalk.yellow.bold('\nLinting files using eslint...'));
const eslint = new ESLint(),
results = await eslint.lintFiles(LINT_SOURCE_DIRS),
errorReport = ESLint.getErrorResults(results),
formatter = await eslint.loadFormatter();
// log the result to CLI
console.info(formatter.format(results));
(errorReport && !errorReport.length) && console.info(chalk.green('eslint ok!'));
exit(Number(errorReport && errorReport.length) || 0);
};
// ensure we run this script exports if this is a direct stdin.tty run
!module.parent && module.exports(process.exit);