@digitoimistodude/code-quality-checks 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +58 -14
- package/package.json +1 -1
package/.husky/pre-commit
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Ref: DEV-177, DEV-373, DEV-623
|
|
3
3
|
|
|
4
4
|
# Version:
|
|
5
|
-
VERSION="2.1.
|
|
5
|
+
VERSION="2.1.3 (2026-01-09)"
|
|
6
6
|
|
|
7
7
|
# Load configuration
|
|
8
8
|
# First check for local project config, then fall back to package default
|
|
@@ -682,16 +682,19 @@ if [ -n "$scss_files" ]; then
|
|
|
682
682
|
# Find stylelint config and binary
|
|
683
683
|
stylelint_config=""
|
|
684
684
|
stylelint_bin=""
|
|
685
|
+
theme_dir_for_stylelint=""
|
|
685
686
|
if [ "$CONTEXT" = "dudestack" ]; then
|
|
686
687
|
# Find stylelint config and binary in theme directories
|
|
687
688
|
for theme_dir in content/themes/*/; do
|
|
688
689
|
if [ -f "${theme_dir}.stylelintrc" ]; then
|
|
689
|
-
stylelint_config="
|
|
690
|
-
stylelint_bin="
|
|
690
|
+
stylelint_config=".stylelintrc"
|
|
691
|
+
stylelint_bin="./node_modules/.bin/stylelint"
|
|
692
|
+
theme_dir_for_stylelint="$theme_dir"
|
|
691
693
|
break
|
|
692
694
|
elif [ -f "${theme_dir}.stylelintrc.json" ]; then
|
|
693
|
-
stylelint_config="
|
|
694
|
-
stylelint_bin="
|
|
695
|
+
stylelint_config=".stylelintrc.json"
|
|
696
|
+
stylelint_bin="./node_modules/.bin/stylelint"
|
|
697
|
+
theme_dir_for_stylelint="$theme_dir"
|
|
695
698
|
break
|
|
696
699
|
fi
|
|
697
700
|
done
|
|
@@ -717,18 +720,59 @@ if [ -n "$scss_files" ]; then
|
|
|
717
720
|
stylelint_cmd="npx stylelint"
|
|
718
721
|
fi
|
|
719
722
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
723
|
+
# For dudestack, run stylelint from theme directory with converted paths
|
|
724
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -n "$theme_dir_for_stylelint" ]; then
|
|
725
|
+
# Convert paths: content/themes/dude/file.scss -> file.scss
|
|
726
|
+
theme_prefix="${theme_dir_for_stylelint%/}"
|
|
727
|
+
relative_scss_files=""
|
|
724
728
|
for file in $scss_files; do
|
|
725
|
-
|
|
729
|
+
# Only include files from this theme
|
|
730
|
+
case "$file" in
|
|
731
|
+
${theme_prefix}/*)
|
|
732
|
+
relative_file="${file#${theme_prefix}/}"
|
|
733
|
+
relative_scss_files="$relative_scss_files $relative_file"
|
|
734
|
+
;;
|
|
735
|
+
esac
|
|
726
736
|
done
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
737
|
+
|
|
738
|
+
if [ -n "$relative_scss_files" ]; then
|
|
739
|
+
# Save current directory and cd to theme
|
|
740
|
+
original_dir=$(pwd)
|
|
741
|
+
cd "$theme_dir_for_stylelint" || exit 1
|
|
742
|
+
|
|
743
|
+
if ! $stylelint_cmd --config "$stylelint_config" $relative_scss_files 2>/dev/null; then
|
|
744
|
+
cd "$original_dir" || exit 1
|
|
745
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
746
|
+
echo " ${RED}Stylelint found errors in SCSS files${NC}"
|
|
747
|
+
echo " ${YELLOW}Please fix the following files:${NC}"
|
|
748
|
+
for file in $scss_files; do
|
|
749
|
+
echo " ${YELLOW}• $file${NC}"
|
|
750
|
+
done
|
|
751
|
+
echo " ${YELLOW}To see detailed errors, run from theme directory:${NC}"
|
|
752
|
+
echo " ${BLUE}cd $theme_dir_for_stylelint && $stylelint_cmd --config \"$stylelint_config\" $relative_scss_files${NC}"
|
|
753
|
+
exit 1
|
|
754
|
+
fi
|
|
755
|
+
cd "$original_dir" || exit 1
|
|
756
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
757
|
+
else
|
|
758
|
+
echo "${YELLOW}⚠️ SKIPPED${NC}"
|
|
759
|
+
echo " ${YELLOW}No SCSS files in theme directory${NC}"
|
|
760
|
+
fi
|
|
761
|
+
else
|
|
762
|
+
# Standalone: run from current directory
|
|
763
|
+
if ! $stylelint_cmd --config "$stylelint_config" $scss_files 2>/dev/null; then
|
|
764
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
765
|
+
echo " ${RED}Stylelint found errors in SCSS files${NC}"
|
|
766
|
+
echo " ${YELLOW}Please fix the following files:${NC}"
|
|
767
|
+
for file in $scss_files; do
|
|
768
|
+
echo " ${YELLOW}• $file${NC}"
|
|
769
|
+
done
|
|
770
|
+
echo " ${YELLOW}To see detailed errors:${NC}"
|
|
771
|
+
echo " ${BLUE}$stylelint_cmd --config \"$stylelint_config\" $scss_files${NC}"
|
|
772
|
+
exit 1
|
|
773
|
+
fi
|
|
774
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
730
775
|
fi
|
|
731
|
-
echo "${GREEN}${CHECK} OK${NC}"
|
|
732
776
|
else
|
|
733
777
|
echo "${YELLOW}⚠️ SKIPPED${NC}"
|
|
734
778
|
echo " ${YELLOW}No .stylelintrc config found${NC}"
|