|
1 | 1 | import * as process from 'node:process';
|
2 | 2 | import * as path from 'node:path';
|
3 |
| -import * as os from 'node:os'; |
4 | 3 | import * as fs from 'node:fs';
|
5 | 4 | import { execSync } from 'node:child_process';
|
6 | 5 |
|
7 | 6 | const PKG = JSON.parse(fs.readFileSync('./package.json').toString());
|
8 |
| -const IS_WINDOWS = os.platform() === 'win32'; |
9 | 7 | const MAYOR_VERSION = PKG.version.split('.')[0];
|
10 | 8 |
|
| 9 | +// Paths for ESLint to check. Converted to string for convenience. |
| 10 | +const ESLINT_PATHS = ['src', 'npm-scripts.mjs'].join(' '); |
| 11 | +// Paths for ESLint to ignore. Converted to string argument for convenience. |
| 12 | +const ESLINT_IGNORE_PATTERN_ARGS = [] |
| 13 | + .map(entry => `--ignore-pattern ${entry}`) |
| 14 | + .join(' '); |
| 15 | +// Paths for Prettier to check/write. Converted to string for convenience. |
| 16 | +// NOTE: Prettier ignores paths in .gitignore so we don't need to care about |
| 17 | +// node/src/fbs. |
| 18 | +const PRETTIER_PATHS = [ |
| 19 | + 'README.md', |
| 20 | + 'src', |
| 21 | + 'npm-scripts.mjs', |
| 22 | + 'package.json', |
| 23 | + 'tsconfig.json', |
| 24 | +].join(' '); |
| 25 | + |
11 | 26 | const task = process.argv[2];
|
12 | 27 | const args = process.argv.slice(3).join(' ');
|
13 | 28 |
|
@@ -148,19 +163,21 @@ function buildTypescript({ force = false } = { force: false }) {
|
148 | 163 | function lint() {
|
149 | 164 | logInfo('lint()');
|
150 | 165 |
|
151 |
| - executeCmd('prettier . --check'); |
152 |
| - |
153 | 166 | // Ensure there are no rules that are unnecessary or conflict with Prettier
|
154 | 167 | // rules.
|
155 | 168 | executeCmd('eslint-config-prettier .eslintrc.js');
|
156 | 169 |
|
157 |
| - executeCmd('eslint -c .eslintrc.js --max-warnings 0 .'); |
| 170 | + executeCmd( |
| 171 | + `eslint -c .eslintrc.js --ext=ts,js,mjs --max-warnings 0 ${ESLINT_IGNORE_PATTERN_ARGS} ${ESLINT_PATHS}` |
| 172 | + ); |
| 173 | + |
| 174 | + executeCmd(`prettier --check ${PRETTIER_PATHS}`); |
158 | 175 | }
|
159 | 176 |
|
160 | 177 | function format() {
|
161 | 178 | logInfo('format()');
|
162 | 179 |
|
163 |
| - executeCmd('prettier . --write'); |
| 180 | + executeCmd(`prettier --write ${PRETTIER_PATHS}`); |
164 | 181 | }
|
165 | 182 |
|
166 | 183 | function test() {
|
|
0 commit comments