chore: fix some bug

chore: update lock
This commit is contained in:
tecvan-fe
2025-09-25 14:22:11 +08:00
parent 3e498d032a
commit 997979df54
3 changed files with 1100 additions and 104 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ import { exists } from '../utils/file';
*/
export const WHITESPACE_RULE: Rule = {
name: 'whitespace-only',
description: 'Detects files that have only whitespace changes (spaces, tabs, newlines)',
description: 'Detects files that have only whitespace changes (spaces, tabs, newlines, blank lines)',
filePatterns: FILE_PATTERNS.ALL_FILES
} as const;
@ -55,7 +55,7 @@ export const analyzeWhitespaceRule = async (filePath: string, config: Config): P
return createResult(
filePath,
true,
'File has only whitespace changes (spaces, tabs, newlines)'
'File has only whitespace changes (spaces, tabs, newlines, blank lines)'
);
} else {
return createResult(

View File

@ -118,7 +118,7 @@ export const isNewFile = (filePath: string, options: GitOptions): boolean => {
};
/**
* Check if a file has only whitespace changes
* Check if a file has only whitespace changes (including blank lines)
*/
export const hasOnlyWhitespaceChanges = (filePath: string, options: GitOptions): boolean => {
try {
@ -132,7 +132,10 @@ export const hasOnlyWhitespaceChanges = (filePath: string, options: GitOptions):
? filePath.substring(projectRoot.length + 1)
: filePath;
const output = execSync(`git diff -w ${options.ref || 'HEAD'} -- "${relativePath}"`, {
// Use -w to ignore whitespace changes and -b to ignore blank line changes
// --ignore-space-at-eol ignores changes in whitespace at EOL
// --ignore-blank-lines ignores changes whose lines are all blank
const output = execSync(`git diff -w -b --ignore-space-at-eol --ignore-blank-lines ${options.ref || 'HEAD'} -- "${relativePath}"`, {
cwd: options.cwd,
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'ignore']