-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcspell.mk
More file actions
107 lines (88 loc) · 4 KB
/
cspell.mk
File metadata and controls
107 lines (88 loc) · 4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
SHELL := /bin/bash -euo pipefail
define CSPELL_HELP
REQUIREMENTS:
- cspell : `cspell` command must be available.
- npm : `npm` command must be available for `cspell-install`.
TARGETS:
- cspell-help : show help message.
- cspell-install : install cspell using `npm -g`.
- cspell : run cspell command with given args.
- cspell-run : run spell check.
VARIABLES [default value]:
- CSPELL_CMD : cspell binary path. [cspell]
- CSPELL_VERSION : cspell version to install. [latest]
- CSPELL_TARGET : target of spell check. [./]
- CSPELL_OPTION : cspell lint command line option. [--quiet --words-only --unique]
REFERENCES:
- https://cspell.org/
- https://cspell.org/docs/getting-started
- https://cspell.org/docs/installation/
- https://github.com/streetsidesoftware/cspell
IDE INTEGRATIONS:
- VSCode : https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker
- JetBrains : https://plugins.jetbrains.com/plugin/20676-cspell-check
PROJECT STRUCTURE:
/ |-- Project
├─ _scripts/ |-- Git submodule
│ └─ makefiles/ |
│ └─ cspell.mk |
├─ .cspell.yaml |-- Config file
├─ .project-words.txt |-- Allowed words list (must be configured)
└─ Makefile |-- include _scripts/makefiles/cspell.mk
endef
.PHONY: cspell-help
cspell-help:
$(info $(CSPELL_HELP))
@echo ""
#├─────────────────────────────────────────────────────────────────────────────┤
CSPELL_CMD ?= cspell
CSPELL_VERSION ?= latest
CSPELL_TARGET ?= ./
CSPELL_OPTION ?= --quiet --words-only --unique
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: cspell-install-usage
cspell-install-usage:
# Usage : make cspell-install ARGS=""
# Exec : npm install -g "cspell@$$(CSPELL_VERSION)"
# npm install -g "@cspell/dict-golang@latest"
# Desc : Install cspell using `npm -g`.
# Examples:
# - make cspell-install
# - make cspell-install ARGS=""
# - make cspell-install CSPELL_VERSION="next"
.PHONY: cspell-install
cspell-install:
ifeq ("cspell-install","$(MAKECMDGOALS)")
npm install -g "cspell@$(CSPELL_VERSION)"
npm install -g "@cspell/dict-golang@latest"
else
ifeq (,$(shell which $(CSPELL_CMD) 2>/dev/null))
npm install -g "cspell@$(CSPELL_VERSION)"
npm install -g "@cspell/dict-golang@latest"
endif
endif
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: cspell-usage
cspell-usage:
# Usage : make cspell ARGS=""
# Exec : $$(CSPELL_CMD) $$(ARGS)
# Desc : Run cspell with given arguments.
# Examples:
# - make cspell ARGS="--version"
# - make cspell ARGS="--help"
.PHONY: cspell
cspell: cspell-install
$(CSPELL_CMD) $(ARGS)
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: cspell-run-usage
cspell-run-usage:
# Usage : make cspell-run ARGS=""
# Exec : $$(CSPELL_CMD) lint $$(ARGS) $$(CSPELL_OPTION) $$(CSPELL_TARGET)
# Desc : Run spell check.
# Examples:
# - make cspell
# - make cspell ARGS=""
.PHONY: cspell-run
cspell-run: cspell-install
$(CSPELL_CMD) lint $(ARGS) $(CSPELL_OPTION) $(CSPELL_TARGET)
#├─────────────────────────────────────────────────────────────────────────────┤