-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathcheck_curly_quotes.sh
More file actions
executable file
·70 lines (62 loc) · 1.81 KB
/
check_curly_quotes.sh
File metadata and controls
executable file
·70 lines (62 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Check for curly/smart quotes in source files
#
# Detects:
# " (U+201C) - Left double quotation mark
# " (U+201D) - Right double quotation mark
# ' (U+2018) - Left single quotation mark
# ' (U+2019) - Right single quotation mark
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Default to src/ if no arguments provided
if [ $# -eq 0 ]; then
SEARCH_PATHS="src/"
else
SEARCH_PATHS="$@"
fi
# Pattern for curly quotes
CURLY_QUOTE_PATTERN='[""'']'
# Find files with curly quotes
# Exclude reference directories (auto-generated) and build artifacts
FOUND_FILES=$(grep -r -l -E "$CURLY_QUOTE_PATTERN" $SEARCH_PATHS \
--include="*.md" \
--include="*.mdx" \
--include="*.py" \
--include="*.js" \
--include="*.ts" \
--include="*.jsx" \
--include="*.tsx" \
--include="*.json" \
--include="*.yaml" \
--include="*.yml" \
--exclude-dir=reference \
--exclude-dir=build \
--exclude-dir=node_modules \
--exclude-dir=.git \
--exclude-dir=.venv \
--exclude-dir=__pycache__ \
2>/dev/null || true)
if [ -n "$FOUND_FILES" ]; then
echo -e "${RED}Error: Curly quotes found in the following files:${NC}"
echo ""
for file in $FOUND_FILES; do
echo -e "${RED}$file:${NC}"
# Show line numbers and content with curly quotes
grep -n -E "$CURLY_QUOTE_PATTERN" "$file" | head -10
echo ""
done
echo "Please replace curly quotes with straight quotes:"
echo ' " -> " (left double quote)'
echo ' " -> " (right double quote)'
echo " ' -> ' (left single quote)"
echo " ' -> ' (right single quote)"
echo ""
echo "Tip: You can use 'make fix-curly-quotes' to automatically fix these."
exit 1
else
echo -e "${GREEN}No curly quotes found.${NC}"
exit 0
fi