|
1 | | -import colors from "colors/safe"; |
| 1 | +import * as colors from "colors/safe"; |
| 2 | +import { type Options as LinterOptions, createInstance } from "addons-linter"; |
2 | 3 | import { execSync } from "child_process"; |
3 | | -import linter from "addons-linter"; |
4 | 4 |
|
5 | | -const main = async () => { |
6 | | - const linterConfigFirefox: linter.Options = { |
| 5 | +const ERROR_EXIT_CODE = 1; |
| 6 | + |
| 7 | +// eslint-disable-next-line max-statements |
| 8 | +const main = async (): Promise<void> => { |
| 9 | + const linterConfigFirefox: LinterOptions = { |
7 | 10 | config: { |
| 11 | + // eslint-disable-next-line id-length |
8 | 12 | _: ["./dist/firefox/"], |
9 | 13 | logLevel: process.env.VERBOSE ? "debug" : "fatal", |
10 | | - shouldScanFile: (fileName, isDir) => { |
11 | | - return true; |
12 | | - } |
| 14 | + shouldScanFile: () => true |
13 | 15 | } |
14 | 16 | }; |
15 | 17 |
|
16 | | - const linterConfigChrome: linter.Options = { |
| 18 | + const linterConfigChrome: LinterOptions = { |
17 | 19 | config: { |
18 | 20 | ...linterConfigFirefox.config, |
| 21 | + // eslint-disable-next-line id-length |
19 | 22 | _: ["./dist/chrome/"], |
20 | 23 | enableBackgroundServiceWorker: true |
21 | 24 | } |
22 | 25 | }; |
23 | 26 |
|
24 | | - const lintForFirefox = linter.createInstance(linterConfigFirefox); |
25 | | - const lintForChrome = linter.createInstance(linterConfigChrome); |
| 27 | + const lintForFirefox = createInstance(linterConfigFirefox); |
| 28 | + const lintForChrome = createInstance(linterConfigChrome); |
26 | 29 |
|
| 30 | + // eslint-disable-next-line no-console |
27 | 31 | console.log("Building..."); |
28 | 32 | execSync("npm run build"); |
29 | 33 |
|
| 34 | + // eslint-disable-next-line no-console |
30 | 35 | console.log("Linting for Firefox..."); |
31 | 36 | const firefoxResult = await lintForFirefox.run(); |
32 | 37 | if (firefoxResult.errors.length) { |
| 38 | + // eslint-disable-next-line no-console |
33 | 39 | console.error(colors.red("Errors found when linting for Firefox.")); |
34 | | - process.exit(1); |
| 40 | + process.exit(ERROR_EXIT_CODE); |
35 | 41 | } |
36 | 42 |
|
| 43 | + // eslint-disable-next-line no-console |
37 | 44 | console.log("Linting for Chrome..."); |
38 | 45 | const chromeResult = await lintForChrome.run(); |
39 | 46 | if (chromeResult.errors.length) { |
| 47 | + // eslint-disable-next-line no-console |
40 | 48 | console.error(colors.red("Errors found when linting for Chrome.")); |
41 | | - process.exit(1); |
| 49 | + process.exit(ERROR_EXIT_CODE); |
42 | 50 | } |
43 | 51 |
|
| 52 | + // eslint-disable-next-line no-console |
44 | 53 | console.log("Done."); |
45 | 54 | }; |
46 | 55 |
|
47 | 56 | try { |
48 | 57 | void main(); |
49 | 58 | } catch (error) { |
50 | | - // @ts-expect-error |
| 59 | + // @ts-expect-error error is not an instance of Error |
| 60 | + // eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access |
51 | 61 | console.error(colors.red(error.stdout.toString())); |
52 | | - process.exit(1); |
| 62 | + process.exit(ERROR_EXIT_CODE); |
53 | 63 | } |
0 commit comments