Last active
September 8, 2025 15:56
-
-
Save vkuprin/4f2489965118160b1526466a2af4bd1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git ls-files -c "*.js" "*.jsx" "*.ts" "*.tsx" | xargs -I{} perl -i -0pe ' | |
| # First, handle specific JSX/TSX comment blocks with curly braces | |
| s|\{\/\*.*?\*\/\}||gs; | |
| # Then handle regular comments | |
| s|(?<!\:)//[^\n]*| |g; | |
| s|/\*.*?\*/| |gs; | |
| # Clean up extra whitespace | |
| s|[ \t]+\n|\n|g; | |
| ' {} |
Author
vkuprin
commented
Sep 8, 2025
Author
# Preview which files will be processed
echo "Files that will have comments removed:"
git diff --name-only main...HEAD | grep -E '\.(js|jsx|ts|tsx)$'
# Then run the actual command
git diff --name-only main...HEAD | grep -E '\.(js|jsx|ts|tsx)$' | xargs -I{} perl -i -0pe '
# First, handle specific JSX/TSX comment blocks with curly braces
s|\{\/\*.*?\*\/\}||gs;
# Then handle regular comments
s|(?<!\:)//[^\n]*| |g;
s|/\*.*?\*/| |gs;
# Clean up extra whitespace
s|[ \t]+\n|\n|g;
' {}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment