|
1 | | -import { DEFAULT_LINTED_FILE_REGEX } from '../constants/regex'; |
2 | | -import { eslintCheckStagedFiles } from '../utils/eslint/eslintCheckStagedFiles/eslintCheckStagedFiles'; |
| 1 | +import { DEFAULT_LINTED_FILE_REGEX } from "../constants/regex"; |
| 2 | +import { eslintCheckStagedFiles } from "../utils/eslint/eslintCheckStagedFiles/eslintCheckStagedFiles"; |
3 | 3 |
|
4 | | -export const checkStaged = async (options: { rootDir?: string; pattern?: string[] }) => { |
5 | | - try { |
6 | | - const rootDir = options.rootDir || './'; |
7 | | - const filesRegex = options.pattern |
8 | | - ? options.pattern.map((pattern) => new RegExp(pattern)) |
9 | | - : [DEFAULT_LINTED_FILE_REGEX]; |
| 4 | +export const checkStaged = async (options: { |
| 5 | + rootDir?: string; |
| 6 | + pattern?: string[]; |
| 7 | +}) => { |
| 8 | + try { |
| 9 | + const rootDir = options.rootDir || "./"; |
| 10 | + const filesRegex = options.pattern |
| 11 | + ? options.pattern.map((pattern) => new RegExp(pattern)) |
| 12 | + : [DEFAULT_LINTED_FILE_REGEX]; |
10 | 13 |
|
11 | | - console.log('Checking staged files for eslint-disable comments...'); |
| 14 | + console.log("Checking staged files for eslint-disable comments..."); |
12 | 15 |
|
13 | | - await eslintCheckStagedFiles({ |
14 | | - rootDir, |
15 | | - filesRegex, |
16 | | - onFileProcessed: (filePath) => { |
17 | | - console.log(`✓ Checked: ${filePath}`); |
18 | | - } |
19 | | - }); |
| 16 | + await eslintCheckStagedFiles({ |
| 17 | + rootDir, |
| 18 | + filesRegex, |
| 19 | + onFileProcessed: (filePath) => { |
| 20 | + console.log(`✓ Checked: ${filePath}`); |
| 21 | + }, |
| 22 | + }); |
20 | 23 |
|
21 | | - console.log('✅ All staged files are clean - no eslint-disable comments found.'); |
22 | | - } catch (error) { |
23 | | - console.error('❌ Eslint-disable comments found in staged files:'); |
24 | | - console.error(error instanceof Error ? error.message : String(error)); |
25 | | - process.exit(1); |
26 | | - } |
| 24 | + console.log( |
| 25 | + "✅ All staged files are clean - no eslint-disable comments found.", |
| 26 | + ); |
| 27 | + } catch (error) { |
| 28 | + console.error("❌ Eslint-disable comments found in staged files:"); |
| 29 | + console.error(error instanceof Error ? error.message : String(error)); |
| 30 | + process.exit(1); |
| 31 | + } |
27 | 32 | }; |
0 commit comments