diff --git a/Makefile b/Makefile index db001a5350b1e4..66bca71097f9fa 100644 --- a/Makefile +++ b/Makefile @@ -1038,27 +1038,32 @@ lint-md-clean: lint-md-build: @if [ ! -d tools/remark-cli/node_modules ]; then \ echo "Markdown linter: installing remark-cli into tools/"; \ - cd tools/remark-cli && ../../$(NODE) ../../$(NPM) install; fi + cd tools/remark-cli && $(call available-node,$(run-npm-install)) fi @if [ ! -d tools/remark-preset-lint-node/node_modules ]; then \ echo "Markdown linter: installing remark-preset-lint-node into tools/"; \ - cd tools/remark-preset-lint-node && ../../$(NODE) ../../$(NPM) install; fi + cd tools/remark-preset-lint-node && $(call available-node,$(run-npm-install)) fi + .PHONY: lint-md ifneq ("","$(wildcard tools/remark-cli/node_modules/)") -LINT_MD_TARGETS = src lib benchmark tools/doc tools/icu -LINT_MD_ROOT_DOCS := $(wildcard *.md) -LINT_MD_FILES := $(shell find $(LINT_MD_TARGETS) -type f \ - -not -path '*node_modules*' -name '*.md') $(LINT_MD_ROOT_DOCS) -LINT_DOC_MD_FILES = $(shell ls doc/**/*.md) -tools/.docmdlintstamp: $(LINT_DOC_MD_FILES) +LINT_MD_DOC_FILES = $(shell ls doc/**/*.md) +run-lint-doc-md = tools/remark-cli/cli.js -q -f $(LINT_MD_DOC_FILES) +# Lint all changed markdown files under doc/ +tools/.docmdlintstamp: $(LINT_MD_DOC_FILES) @echo "Running Markdown linter on docs..." - @$(NODE) tools/remark-cli/cli.js -q -f $(LINT_DOC_MD_FILES) + @$(call available-node,$(run-lint-doc-md)) @touch $@ -tools/.miscmdlintstamp: $(LINT_MD_FILES) +LINT_MD_TARGETS = src lib benchmark tools/doc tools/icu +LINT_MD_ROOT_DOCS := $(wildcard *.md) +LINT_MD_MISC_FILES := $(shell find $(LINT_MD_TARGETS) -type f \ + -not -path '*node_modules*' -name '*.md') $(LINT_MD_ROOT_DOCS) +run-lint-misc-md = tools/remark-cli/cli.js -q -f $(LINT_MD_MISC_FILES) +# Lint other changed markdown files maintained by us +tools/.miscmdlintstamp: $(LINT_MD_MISC_FILES) @echo "Running Markdown linter on misc docs..." - @$(NODE) tools/remark-cli/cli.js -q -f $(LINT_MD_FILES) + @$(call available-node,$(run-lint-misc-md)) @touch $@ tools/.mdlintstamp: tools/.miscmdlintstamp tools/.docmdlintstamp @@ -1072,43 +1077,33 @@ lint-md: endif LINT_JS_TARGETS = benchmark doc lib test tools -LINT_JS_CMD = tools/node_modules/eslint/bin/eslint.js --cache \ - --rulesdir=tools/eslint-rules --ext=.js,.mjs,.md \ - $(LINT_JS_TARGETS) + +run-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \ + --rulesdir=tools/eslint-rules --ext=.js,.mjs,.md $(LINT_JS_TARGETS) +run-lint-js-fix = $(run-lint-js) --fix .PHONY: lint-js-fix lint-js-fix: - @if [ -x $(NODE) ]; then \ - $(NODE) $(LINT_JS_CMD) --fix; \ - else \ - node $(LINT_JS_CMD) --fix; \ - fi + @$(call available-node,$(run-lint-js-fix)) .PHONY: lint-js # Note that on the CI `lint-js-ci` is run instead. # Lints the JavaScript code with eslint. lint-js: @echo "Running JS linter..." - @if [ -x $(NODE) ]; then \ - $(NODE) $(LINT_JS_CMD); \ - else \ - node $(LINT_JS_CMD); \ - fi + @$(call available-node,$(run-lint-js)) jslint: lint-js @echo "Please use lint-js instead of jslint" +run-lint-js-ci = tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \ + $(LINT_JS_TARGETS) + .PHONY: lint-js-ci # On the CI the output is emitted in the TAP format. lint-js-ci: @echo "Running JS linter..." - @if [ -x $(NODE) ]; then \ - $(NODE) tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \ - $(LINT_JS_TARGETS); \ - else \ - node tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \ - $(LINT_JS_TARGETS); \ - fi + @$(call available-node,$(run-lint-js-ci)) jslint-ci: lint-js-ci @echo "Please use lint-js-ci instead of jslint-ci"