@@ -974,6 +974,7 @@ bench-ci: bench
974974lint-md-clean :
975975 $(RM ) -r tools/remark-cli/node_modules
976976 $(RM ) -r tools/remark-preset-lint-node/node_modules
977+ $(RM ) tools/.* mdlintstamp
977978
978979lint-md-build :
979980 @if [ ! -d tools/remark-cli/node_modules ]; then \
@@ -983,10 +984,25 @@ lint-md-build:
983984 echo " Markdown linter: installing remark-preset-lint-node into tools/" ; \
984985 cd tools/remark-preset-lint-node && ../../$(NODE ) ../../$(NPM ) install; fi
985986
986- lint-md : lint-md-build
987- @echo " Running Markdown linter..."
988- $(NODE ) tools/remark-cli/cli.js -q -f \
989- ./* .md doc src lib benchmark tools/doc/ tools/icu/
987+ LINT_MD_TARGETS = src lib benchmark tools/doc tools/icu
988+ LINT_MD_ROOT_DOCS := $(wildcard * .md)
989+ LINT_MD_FILES := $(shell find $(LINT_MD_TARGETS ) -type f \
990+ -not -path '* node_modules* ' -name '* .md') $(LINT_MD_ROOT_DOCS )
991+ LINT_DOC_MD_FILES = $(shell ls doc/** /* .md)
992+
993+ tools/.docmdlintstamp : $(LINT_DOC_MD_FILES )
994+ @echo " Running Markdown linter on docs..."
995+ @$(NODE ) tools/remark-cli/cli.js -q -f $(LINT_DOC_MD_FILES )
996+ @touch $@
997+
998+ tools/.miscmdlintstamp : $(LINT_MD_FILES )
999+ @echo " Running Markdown linter on misc docs..."
1000+ @$(NODE ) tools/remark-cli/cli.js -q -f $(LINT_MD_FILES )
1001+ @touch $@
1002+
1003+ tools/.mdlintstamp : tools/.miscmdlintstamp tools/.docmdlintstamp
1004+
1005+ lint-md : | lint-md-build tools/.mdlintstamp
9901006
9911007LINT_JS_TARGETS = benchmark doc lib test tools
9921008LINT_JS_CMD = tools/eslint/bin/eslint.js --cache \
@@ -1048,10 +1064,13 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
10481064# and the actual filename is generated so it won't match header guards
10491065ADDON_DOC_LINT_FLAGS =-whitespace/ending_newline,-build/header_guard
10501066
1051- lint-cpp :
1067+ lint-cpp : tools/.cpplintstamp
1068+
1069+ tools/.cpplintstamp : $(LINT_CPP_FILES )
10521070 @echo " Running C++ linter..."
1053- @$(PYTHON ) tools/cpplint.py $( LINT_CPP_FILES )
1071+ @$(PYTHON ) tools/cpplint.py $?
10541072 @$(PYTHON ) tools/check-imports.py
1073+ @touch $@
10551074
10561075lint-addon-docs : test/addons/.docbuildstamp
10571076 @echo " Running C++ linter on addon docs..."
@@ -1087,6 +1106,10 @@ lint:
10871106lint-ci : lint
10881107endif
10891108
1109+ lint-clean :
1110+ $(RM ) tools/.* lintstamp
1111+ $(RM ) .eslintcache
1112+
10901113.PHONY : $(TARBALL ) -headers \
10911114 all \
10921115 bench \
@@ -1127,6 +1150,7 @@ endif
11271150 install-bin \
11281151 install-includes \
11291152 lint \
1153+ lint-clean \
11301154 lint-ci \
11311155 lint-cpp \
11321156 lint-js \
0 commit comments