-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.js
31 lines (28 loc) · 897 Bytes
/
eslint.js
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
'use strict';
const path = require('path');
const command = path.parse(__filename).name;
module.exports = {
command,
describe: 'Check the codebase with ESLint.',
handler: async () => {
const { $, ProcessOutput } = await import('zx/core');
process.env.FORCE_COLOR = '3';
if (process.argv[2] === command) {
process.argv.splice(2, 1);
}
process.argv.push(...[['.'], ['--ext', '.js,.json,.md'], ['--ignore-pattern', '!.*.*']].flat());
try {
$.verbose = false;
await $`./node_modules/.bin/eslint ${process.argv.slice(2)}`;
} catch (err) {
if (err instanceof ProcessOutput) {
const { exitCode, stdout, stderr } = err;
const out = stdout?.toString() || stderr?.toString() || '';
console.error(out.replace('\n', '').trimEnd());
process.exit(exitCode || 1);
} else {
throw err;
}
}
}
};