@digitoimistodude/code-quality-checks 2.1.1 → 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.
Files changed (2) hide show
  1. package/.husky/pre-commit +65 -19
  2. 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.1 (2026-01-09)"
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
@@ -391,13 +391,15 @@ if [ "$CONTEXT" = "dudestack" ]; then
391
391
  # Check Theme Name line
392
392
  theme_name_line=$(grep "^Theme Name:" "${theme_dir}style.css" 2>/dev/null || echo "")
393
393
  if [ -n "$theme_name_line" ]; then
394
- # Check if theme name contains lowercase theme name
395
- if echo "$theme_name_line" | grep -qi "Theme Name:.*$theme_name"; then
394
+ # Extract the actual theme name value after "Theme Name:"
395
+ theme_name_value=$(echo "$theme_name_line" | sed 's/^Theme Name:[[:space:]]*//')
396
+
397
+ # Check if theme name starts with lowercase letter (should be capitalized)
398
+ if echo "$theme_name_value" | grep -q "^[a-z]"; then
396
399
  echo "${RED}${CROSS} FAILED${NC}"
397
- echo " ${RED}Theme Name contains lowercase theme name '$theme_name'${NC}"
400
+ echo " ${RED}Theme Name should start with a capital letter${NC}"
398
401
  echo " ${YELLOW}Found: $theme_name_line${NC}"
399
- echo " ${YELLOW}Should contain a clear theme name in sentence case${NC}"
400
- echo " ${YELLOW}Example: Theme Name: My Website Theme${NC}"
402
+ echo " ${YELLOW}Should be properly capitalized${NC}"
401
403
  echo " ${BLUE}nano ${theme_dir}style.css${NC}"
402
404
  exit 1
403
405
  fi
@@ -680,16 +682,19 @@ if [ -n "$scss_files" ]; then
680
682
  # Find stylelint config and binary
681
683
  stylelint_config=""
682
684
  stylelint_bin=""
685
+ theme_dir_for_stylelint=""
683
686
  if [ "$CONTEXT" = "dudestack" ]; then
684
687
  # Find stylelint config and binary in theme directories
685
688
  for theme_dir in content/themes/*/; do
686
689
  if [ -f "${theme_dir}.stylelintrc" ]; then
687
- stylelint_config="${theme_dir}.stylelintrc"
688
- stylelint_bin="${theme_dir}node_modules/.bin/stylelint"
690
+ stylelint_config=".stylelintrc"
691
+ stylelint_bin="./node_modules/.bin/stylelint"
692
+ theme_dir_for_stylelint="$theme_dir"
689
693
  break
690
694
  elif [ -f "${theme_dir}.stylelintrc.json" ]; then
691
- stylelint_config="${theme_dir}.stylelintrc.json"
692
- stylelint_bin="${theme_dir}node_modules/.bin/stylelint"
695
+ stylelint_config=".stylelintrc.json"
696
+ stylelint_bin="./node_modules/.bin/stylelint"
697
+ theme_dir_for_stylelint="$theme_dir"
693
698
  break
694
699
  fi
695
700
  done
@@ -715,18 +720,59 @@ if [ -n "$scss_files" ]; then
715
720
  stylelint_cmd="npx stylelint"
716
721
  fi
717
722
 
718
- if ! $stylelint_cmd --config "$stylelint_config" $scss_files 2>/dev/null; then
719
- echo "${RED}${CROSS} FAILED${NC}"
720
- echo " ${RED}Stylelint found errors in SCSS files${NC}"
721
- echo " ${YELLOW}Please fix the following files:${NC}"
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=""
722
728
  for file in $scss_files; do
723
- echo " ${YELLOW}• $file${NC}"
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
724
736
  done
725
- echo " ${YELLOW}To see detailed errors:${NC}"
726
- echo " ${BLUE}$stylelint_cmd --config \"$stylelint_config\" $scss_files${NC}"
727
- exit 1
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}"
728
775
  fi
729
- echo "${GREEN}${CHECK} OK${NC}"
730
776
  else
731
777
  echo "${YELLOW}⚠️ SKIPPED${NC}"
732
778
  echo " ${YELLOW}No .stylelintrc config found${NC}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitoimistodude/code-quality-checks",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Code quality definitions and Husky pre-commit hooks for Dude WordPress projects",
5
5
  "main": "index.js",
6
6
  "files": [