Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ jobs:
- name: Run pre-commit
run: uv tool run --with pre-commit-uv pre-commit run --show-diff-on-failure --color=always --all-files

spellcheck:
name: Spellcheck
runs-on: ubuntu-24.04
needs:
- pre-commit
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Install cspell dependencies
run: npm ci --ignore-scripts --no-audit --no-fund
working-directory: cspell

- name: Run spellcheck
run: cspell/node_modules/.bin/cspell lint -c cspell/cspell.json --no-progress "docs/**/*" "README.md" "scripts/l10n/**/*" "mkdocs.yml"

code-ql:
name: CodeQL
needs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dist/
docs/auto_gen_files/
holidays/locale/pot/*.pot
MANIFEST
node_modules/
Pipfile
sbom.json
site/
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ help:
@echo " package build package distribution"
@echo " pre-commit run pre-commit against all files"
@echo " setup setup development environment"
@echo " spellcheck run spell check across the repository (docs, l10n)"
@echo " test run tests (in parallel)"
@echo " upgrade run dependency upgrade"

Expand All @@ -24,8 +25,16 @@ check:
make l10n
make pre-commit
make doc
make spellcheck
make test

sort-custom-dict:
python tools/sort_cspell_dict.py
Comment thread
coderabbitai[bot] marked this conversation as resolved.

spellcheck: sort-custom-dict
@command -v docker >/dev/null 2>&1 || { echo "ERROR: docker not found. Install Docker or skip spellcheck."; exit 127; }
$(MAKE) -f cspell/Makefile cspell-check

clean:
@for ext in mo pot pyc; do \
find . -type f -name "*.$$ext" -delete; \
Expand Down
24 changes: 24 additions & 0 deletions cspell/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:20-alpine

# Set working directory for node modules installation
WORKDIR /app

# Copy package.json and package-lock.json to install dependencies
COPY package.json package-lock.json ./

# Install cspell and dictionaries locally using npm ci with security flags
RUN npm ci --ignore-scripts --no-audit --no-fund && npm cache clean --force

# Set working directory for the application
WORKDIR /holidays

# Copy cspell configuration and custom dictionary
COPY cspell.json cspell/cspell.json
COPY custom-dict.txt cspell/custom-dict.txt

# Use non-root user for security
USER node

# Set entrypoint to local cspell binary
ENTRYPOINT ["/app/node_modules/.bin/cspell"]
CMD ["--help"]
20 changes: 20 additions & 0 deletions cspell/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: cspell-install cspell-check sort-custom-dict

cspell-install:
@which docker > /dev/null 2>&1 || (echo "ERROR: docker not found in PATH. Install Docker."; exit 1)
@DOCKER_BUILDKIT=1 docker build \
$(if $(FORCE),--no-cache,) \
-f cspell/Dockerfile \
cspell \
-t cspell

cspell-check: CMD=--no-progress -r /holidays
cspell-check: cspell-install

@docker run \
--mount type=bind,src="$(CURDIR)",dst=/holidays,readonly \
--rm \
cspell lint -c cspell/cspell.json $(CMD)

sort-custom-dict:
@python tools/sort_cspell_dict.py
108 changes: 108 additions & 0 deletions cspell/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"allowCompoundWords": false,
"caseSensitive": false,
"language": "en",
"minWordLength": 3,
"dictionaryDefinitions": [
{
"addWords": true,
"name": "custom-dict",
"path": "custom-dict.txt"
}
],
"dictionaries": [
"ar",
"bg-bg",
"bn",
"ca",
"companies",
"cs-cz",
"da-dk",
"de-at",
"de-ch",
"de-de",
"el",
"en_us",
"en-au",
"en-ca",
"en-common-misspellings",
"en-gb",
"eo",
"es-es",
"et-ee",
"eu",
"fa-ir",
"fi-fi",
"fr-fr",
"gd",
"gl-es",
"grc",
"he",
"hr-hr",
"hu-hu",
"hy",
"id-id",
"it-it",
"la",
"lt-lt",
"lv",
"makefile",
"markdown",
"mk",
"mn-mn",
"nb-no",
"nl-nl",
"pl-pl",
"pt-br",
"pt-pt",
"python",
"ro-ro",
"ru-ru",
"scientific-terms-gb",
"sk-sk",
"sl-si",
"sr-cyrl",
"sr-latn",
"sv",
"software-terms",
"tr-tr",
"uk-ua",
"vi-vn",
"custom-dict"
],
"enabled": true,
"files": [
"docs/**/*",
"README.md",
"scripts/l10n/**/*",
"mkdocs.yml"
],
"ignorePaths": [
"node_modules/**",
".git/**",
".venv/**",
"__pycache__/**",
"*.pyc",
"dist/**",
"build/**",
".mypy_cache/**",
".pytest_cache/**",
"docs/_build/**",
"snapshots/**",
"*.egg-info/**",
".tox/**",
"requirements/*.txt",
"cspell/dictionaries/**"
],
"ignoreRegExpList": [
"#\\w+",
"<@\\w+>",
"\\b[A-Z]{2,}\\b",
"\\b[A-Z][a-z]+\\s+[A-Z][a-z]+\\b",
"\\b\\d+\\b",
"\\b[A-Za-z]+_[A-Za-z]+\\b",
"\\bhttps?:\\/\\/[^\\s]+\\b"
],

"useGitignore": true
}
7 changes: 7 additions & 0 deletions cspell/custom-dict.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Project-specific terms
Día
Nāgā
Río
mofile
ārā
วันสงกรานต์
49 changes: 49 additions & 0 deletions cspell/make.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@echo off
setlocal enabledelayedexpansion

set TARGET=%1

if "%TARGET%"=="cspell-check" goto cspell-check
if "%TARGET%"=="cspell-install" goto cspell-install
if "%TARGET%"=="cspell-run" goto cspell-run
if "%TARGET%"=="sort-custom-dict" goto sort-custom-dict

echo Usage: make.cmd ^<target^>
echo cspell-check run cspell check
echo cspell-install install cspell docker image
echo cspell-run run cspell (placeholder)
echo sort-custom-dict sort and uniquify custom-dict.txt
goto end

:cspell-install
where docker >nul 2>nul
if %errorlevel% neq 0 (
echo ERROR: docker not found in PATH. Install Docker Desktop or add docker.exe to PATH.
goto end
)
set "build_args="
if defined FORCE set "build_args=--no-cache"
set "DOCKER_BUILDKIT=true" && docker build %build_args% -f cspell/Dockerfile -t cspell cspell
if %errorlevel% neq 0 (
echo ERROR: Docker build failed.
goto end
)
goto end

:cspell-run
rem Placeholder for cspell-run
goto end
Comment on lines +33 to +35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Remove unused cspell-run placeholder.

This does nothing and adds confusion. The Unix Makefile doesn't have a separate cspell-run target either - the docker run is inline in cspell-check.

Remove placeholder and its references
-:cspell-run
-rem Placeholder for cspell-run
-goto end
-

And in dispatch:

-if "%TARGET%"=="cspell-run" goto cspell-run

And in help:

-echo     cspell-run        run cspell (placeholder)

And in cspell-check:

-call :cspell-run
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cspell/make.cmd` around lines 33 - 35, Remove the no-op cspell-run
placeholder label and its goto in the make.cmd file and delete any references to
cspell-run elsewhere (dispatch, help text, and cspell-check) so there is no
empty target left; specifically remove the ":cspell-run" label block and any
"goto cspell-run" or mentions of "cspell-run" and ensure cspell-check continues
to invoke the Docker run inline as in the Unix Makefile.


:sort-custom-dict
python tools/sort_cspell_dict.py
goto end

:cspell-check
set CMD=--no-progress -r /holidays
call :cspell-install
if %errorlevel% neq 0 goto end
call :cspell-run
docker run --mount type=bind,src="%CD%",dst=/holidays,readonly --rm cspell lint -c cspell/cspell.json %CMD%
goto end

:end
Loading
Loading