forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (51 loc) · 1.71 KB
/
kebab-case.yml
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
name: Enforce kebab-case
on: [push, pull_request]
jobs:
check-filenames:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Check For Non Kebab-Cased File Names
run: |
non_compliant_files=()
ignoreList=(
"^\.\/\..*\/" # Ignore hidden flies
"^\.\/[^\/]*$" # Ignore files in root project directory
"^\.\/node_modules"
"^\.\/\.git"
"^\.\/dist"
"^\.\/build"
"^\.\/vendor"
"^\.\/test"
"^\.\/\.next"
"^\.\/tests"
"\.sql$"
"\.md$"
"\.d\.ts$"
"\.gitignore$" # Ignore .gitignore files
"\.test\.ts$" # Ignore .test.ts files
)
while read -r file; do
basefile=$(basename "$file")
ignoreFile=false
for pattern in "${ignoreList[@]}"; do
if echo "$file" | grep -q -E "$pattern"; then
ignoreFile=true
break
fi
done
if $ignoreFile; then
continue
elif ! echo "$basefile" | grep -q -E "^([a-z0-9]+-)*[a-z0-9]+(\.[a-zA-Z0-9]+)?$|^([a-z0-9]+_)*[a-z0-9]+(\.[a-zA-Z0-9]+)?$"; then
non_compliant_files+=("$file")
echo "::warning file=$file::This file is not in kebab-case or snake_case"
fi
done < <(find . -type f)
if [ ${#non_compliant_files[@]} -ne 0 ]; then
echo "The following files are not in kebab-case or snake_case:"
for file in "${non_compliant_files[@]}"; do
echo " - $file"
done
exit 1
fi