Skip to content

Conversation

@Tecvan-fe
Copy link
Collaborator

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Add documentation if the current PR requires user awareness at the usage level.

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

Tecvan-fe and others added 2 commits September 25, 2025 14:25
…programming design

Implement a comprehensive tool to automatically detect and revert files with only
cosmetic changes (whitespace or comments) in Git repositories.

Features:
- Functional programming architecture with pure functions
- Rule-based analysis system (whitespace and AST comment detection)
- Commander.js CLI with comprehensive options
- ESM module system throughout
- Proper handling of new/added files
- TypeScript with strict typing
- Comprehensive documentation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
chore: update lock
Copilot AI review requested due to automatic review settings September 25, 2025 06:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a comprehensive "revert-useless-changes" tool designed with functional programming principles to automatically detect and revert files with only cosmetic changes (whitespace or comments) in Git repositories.

  • Implements a rule-based analysis system with two built-in rules: whitespace-only changes and comment-only changes using AST comparison
  • Provides both CLI and programmatic API with TypeScript support and comprehensive error handling
  • Features extensible architecture allowing easy addition of new analysis rules and output formats

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
revert-useless-changes/utils/git.ts Core Git operations for file analysis and reversion
revert-useless-changes/utils/file.ts File system utilities for reading, pattern matching, and path operations
revert-useless-changes/types.ts Complete type definitions for configuration, analysis results, and rule interfaces
revert-useless-changes/rules/whitespace-rule.ts Rule implementation for detecting whitespace-only changes using Git diff
revert-useless-changes/rules/ast-comment-rule.ts Rule implementation for detecting comment-only changes via AST parsing
revert-useless-changes/rules/index.ts Rule registry and pattern matching system
revert-useless-changes/reporter.ts Console and JSON output formatting with progress logging
revert-useless-changes/orchestrator.ts Main workflow coordination and file analysis orchestration
revert-useless-changes/index.ts Public API exports and programmatic interface
revert-useless-changes/config.ts Configuration constants and default values
revert-useless-changes/cli.ts Command-line interface implementation using Commander.js
revert-useless-changes/README.md Comprehensive documentation of architecture and usage
revert-useless-changes.js Entry point script using Sucrase for TypeScript compilation
package.json Updated dependencies and build scripts for the new tool
.gitignore Build output directory exclusions
Files not reviewed (1)
  • common/autoinstallers/rush-commands/pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

loc: true,
range: true,
comment: true,
ecmaVersion: 'latest' as any,
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'as any' defeats TypeScript's type safety. Consider using a specific ECMAScript version number like 2022 or checking the @typescript-eslint/parser documentation for valid ecmaVersion values.

Suggested change
ecmaVersion: 'latest' as any,
ecmaVersion: 2022,

Copilot uses AI. Check for mistakes.
});
allMatches.push(...matches);
} catch (error) {
console.warn(`Warning: Failed to match pattern ${pattern}:`, error);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct console.warn usage bypasses the centralized logging system. Consider using a logger parameter or the reporter module's logWarning function for consistent error handling.

Copilot uses AI. Check for mistakes.

// More complex pattern matching could be implemented here
// For now, we'll use simple string matching
return filePath.includes(pattern.replace(/\*\*/g, '').replace(/\*/g, ''));
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern matching implementation is incorrect. Removing all wildcards and using string.includes() will produce false matches. For example, pattern '*.txt' would match 'file.txt.backup' incorrectly.

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +57
// More complex pattern matching could be implemented here
return false;
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The matchesPattern function is incomplete - it only handles '**/*' and simple extension patterns but returns false for all other cases. This could cause rules to not apply to files they should match.

Copilot uses AI. Check for mistakes.
@Tecvan-fe Tecvan-fe changed the title feat(rush-commands): add revert-useless-changes tool with functional programming design feat: add revert-useless-changes tool with functional programming design Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants