mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
build: stop pre-compiling lint-md
PR-URL: https://github.com/nodejs/node/pull/55266 Reviewed-By: Claudio Wunder <cwunder@gnome.org> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
413975a580
commit
5ce3d1078d
13
.github/dependabot.yml
vendored
13
.github/dependabot.yml
vendored
@ -22,3 +22,16 @@ updates:
|
|||||||
applies-to: version-updates
|
applies-to: version-updates
|
||||||
patterns:
|
patterns:
|
||||||
- '*'
|
- '*'
|
||||||
|
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: /tools/lint-md
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
||||||
|
commit-message:
|
||||||
|
prefix: tools
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
groups:
|
||||||
|
lint-md:
|
||||||
|
applies-to: version-updates
|
||||||
|
patterns:
|
||||||
|
- '*'
|
||||||
|
19
.github/workflows/tools.yml
vendored
19
.github/workflows/tools.yml
vendored
@ -28,7 +28,6 @@ on:
|
|||||||
- histogram
|
- histogram
|
||||||
- icu
|
- icu
|
||||||
# - libuv
|
# - libuv
|
||||||
- lint-md-dependencies
|
|
||||||
- llhttp
|
- llhttp
|
||||||
- minimatch
|
- minimatch
|
||||||
- nbytes
|
- nbytes
|
||||||
@ -187,24 +186,6 @@ jobs:
|
|||||||
# cat temp-output
|
# cat temp-output
|
||||||
# tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
|
# tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
|
||||||
# rm temp-output
|
# rm temp-output
|
||||||
- id: lint-md-dependencies
|
|
||||||
subsystem: tools
|
|
||||||
label: tools
|
|
||||||
run: |
|
|
||||||
cd tools/lint-md
|
|
||||||
npm ci
|
|
||||||
NEW_VERSION=$(npm outdated --parseable | cut -d: -f4 | xargs)
|
|
||||||
if [ "$NEW_VERSION" != "" ]; then
|
|
||||||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
|
||||||
rm -rf package-lock.json node_modules
|
|
||||||
# Include $NEW_VERSION to explicitly update the package.json
|
|
||||||
# entry for the dependency and also so that semver-major updates
|
|
||||||
# are not skipped.
|
|
||||||
npm install --ignore-scripts $NEW_VERSION
|
|
||||||
npm install --ignore-scripts
|
|
||||||
cd ../..
|
|
||||||
make lint-md-rollup
|
|
||||||
fi
|
|
||||||
- id: llhttp
|
- id: llhttp
|
||||||
subsystem: deps
|
subsystem: deps
|
||||||
label: dependencies
|
label: dependencies
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -114,6 +114,7 @@ tools/*/*.i.tmp
|
|||||||
/tools/doc/node_modules
|
/tools/doc/node_modules
|
||||||
/tools/clang-format/node_modules
|
/tools/clang-format/node_modules
|
||||||
/tools/eslint/node_modules
|
/tools/eslint/node_modules
|
||||||
|
/tools/lint-md/node_modules
|
||||||
|
|
||||||
# === Rules for test artifacts ===
|
# === Rules for test artifacts ===
|
||||||
/*.tap
|
/*.tap
|
||||||
|
25
Makefile
25
Makefile
@ -1335,21 +1335,6 @@ bench-addons-clean:
|
|||||||
$(RM) -r benchmark/napi/*/build
|
$(RM) -r benchmark/napi/*/build
|
||||||
$(RM) benchmark/napi/.buildstamp
|
$(RM) benchmark/napi/.buildstamp
|
||||||
|
|
||||||
.PHONY: lint-md-rollup
|
|
||||||
lint-md-rollup:
|
|
||||||
$(RM) tools/.*mdlintstamp
|
|
||||||
cd tools/lint-md && npm ci && npm run build
|
|
||||||
|
|
||||||
.PHONY: lint-md-clean
|
|
||||||
.NOTPARALLEL: lint-md-clean
|
|
||||||
lint-md-clean:
|
|
||||||
$(RM) -r tools/lint-md/node_modules
|
|
||||||
$(RM) tools/.*mdlintstamp
|
|
||||||
|
|
||||||
.PHONY: lint-md-build
|
|
||||||
lint-md-build:
|
|
||||||
$(warning Deprecated no-op target 'lint-md-build')
|
|
||||||
|
|
||||||
ifeq ("$(wildcard tools/.mdlintstamp)","")
|
ifeq ("$(wildcard tools/.mdlintstamp)","")
|
||||||
LINT_MD_NEWER =
|
LINT_MD_NEWER =
|
||||||
else
|
else
|
||||||
@ -1361,8 +1346,13 @@ LINT_MD_FILES = $(shell $(FIND) $(LINT_MD_TARGETS) -type f \
|
|||||||
! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \
|
! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \
|
||||||
$(LINT_MD_NEWER))
|
$(LINT_MD_NEWER))
|
||||||
run-lint-md = tools/lint-md/lint-md.mjs $(LINT_MD_FILES)
|
run-lint-md = tools/lint-md/lint-md.mjs $(LINT_MD_FILES)
|
||||||
|
|
||||||
|
# Check for a specific file, as (empty) directories are persisted in git.
|
||||||
|
tools/lint-md/node_modules/remark-parse/package.json:
|
||||||
|
-cd tools/lint-md && $(call available-node,$(run-npm-ci))
|
||||||
|
|
||||||
# Lint all changed markdown files maintained by us
|
# Lint all changed markdown files maintained by us
|
||||||
tools/.mdlintstamp: $(LINT_MD_FILES)
|
tools/.mdlintstamp: tools/lint-md/node_modules/remark-parse/package.json $(LINT_MD_FILES)
|
||||||
$(info Running Markdown linter...)
|
$(info Running Markdown linter...)
|
||||||
@$(call available-node,$(run-lint-md))
|
@$(call available-node,$(run-lint-md))
|
||||||
@touch $@
|
@touch $@
|
||||||
@ -1372,7 +1362,7 @@ lint-md: lint-js-doc | tools/.mdlintstamp ## Lint the markdown documents maintai
|
|||||||
|
|
||||||
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
|
run-format-md = tools/lint-md/lint-md.mjs --format $(LINT_MD_FILES)
|
||||||
.PHONY: format-md
|
.PHONY: format-md
|
||||||
format-md: ## Format the markdown documents maintained by us in the codebase.
|
format-md: tools/lint-md/node_modules/remark-parse/package.json ## Format the markdown documents maintained by us in the codebase.
|
||||||
@$(call available-node,$(run-format-md))
|
@$(call available-node,$(run-format-md))
|
||||||
|
|
||||||
|
|
||||||
@ -1601,6 +1591,7 @@ lint-clean: ## Remove linting artifacts.
|
|||||||
$(RM) tools/.*lintstamp
|
$(RM) tools/.*lintstamp
|
||||||
$(RM) .eslintcache
|
$(RM) .eslintcache
|
||||||
$(RM) -r tools/eslint/node_modules
|
$(RM) -r tools/eslint/node_modules
|
||||||
|
$(RM) -r tools/lint-md/node_modules
|
||||||
$(RM) tools/pip/site_packages
|
$(RM) tools/pip/site_packages
|
||||||
|
|
||||||
HAS_DOCKER ?= $(shell command -v docker > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
|
HAS_DOCKER ?= $(shell command -v docker > /dev/null 2>&1; [ $$? -eq 0 ] && echo 1 || echo 0)
|
||||||
|
@ -54,7 +54,6 @@ export default [
|
|||||||
'test/message/esm_display_syntax_error.mjs',
|
'test/message/esm_display_syntax_error.mjs',
|
||||||
'tools/github_reporter/**',
|
'tools/github_reporter/**',
|
||||||
'tools/icu/**',
|
'tools/icu/**',
|
||||||
'tools/lint-md/lint-md.mjs',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
// #endregion
|
// #endregion
|
||||||
|
1
tools/lint-md/.gitignore
vendored
1
tools/lint-md/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
node_modules
|
|
File diff suppressed because one or more lines are too long
@ -1,53 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
import { unified } from 'unified';
|
|
||||||
import remarkParse from 'remark-parse';
|
|
||||||
import remarkStringify from 'remark-stringify';
|
|
||||||
import presetLintNode from 'remark-preset-lint-node';
|
|
||||||
import { read } from 'to-vfile';
|
|
||||||
import { reporter } from 'vfile-reporter';
|
|
||||||
|
|
||||||
const paths = process.argv.slice(2);
|
|
||||||
|
|
||||||
if (!paths.length) {
|
|
||||||
console.error('Usage: lint-md.mjs <path> [<path> ...]');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let format = false;
|
|
||||||
|
|
||||||
if (paths[0] === '--format') {
|
|
||||||
paths.shift();
|
|
||||||
format = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const linter = unified()
|
|
||||||
.use(remarkParse)
|
|
||||||
.use(presetLintNode)
|
|
||||||
.use(remarkStringify);
|
|
||||||
|
|
||||||
paths.forEach(async (path) => {
|
|
||||||
const file = await read(path);
|
|
||||||
// We need to calculate `fileContents` before running `linter.process(files)`
|
|
||||||
// because `linter.process(files)` mutates `file` and returns it as `result`.
|
|
||||||
// So we won't be able to use `file` after that to see if its contents have
|
|
||||||
// changed as they will have been altered to the changed version.
|
|
||||||
const fileContents = file.toString();
|
|
||||||
const result = await linter.process(file);
|
|
||||||
const isDifferent = fileContents !== result.toString();
|
|
||||||
if (format) {
|
|
||||||
if (isDifferent) {
|
|
||||||
fs.writeFileSync(path, result.toString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isDifferent) {
|
|
||||||
process.exitCode = 1;
|
|
||||||
const cmd = process.platform === 'win32' ? 'vcbuild' : 'make';
|
|
||||||
console.error(`${path} is not formatted. Please run '${cmd} format-md'.`);
|
|
||||||
}
|
|
||||||
if (result.messages.length) {
|
|
||||||
process.exitCode = 1;
|
|
||||||
console.error(reporter(result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
778
tools/lint-md/package-lock.json
generated
778
tools/lint-md/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,9 +2,6 @@
|
|||||||
"name": "lint-md",
|
"name": "lint-md",
|
||||||
"description": "markdown linting",
|
"description": "markdown linting",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {
|
|
||||||
"build": "rollup -f es -p '@rollup/plugin-node-resolve={exportConditions: [\"node\"]}' -p @rollup/plugin-commonjs -p rollup-plugin-cleanup lint-md.src.mjs --file lint-md.mjs"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"remark-parse": "^11.0.0",
|
"remark-parse": "^11.0.0",
|
||||||
"remark-preset-lint-node": "^5.1.2",
|
"remark-preset-lint-node": "^5.1.2",
|
||||||
@ -12,11 +9,5 @@
|
|||||||
"to-vfile": "^8.0.0",
|
"to-vfile": "^8.0.0",
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.5",
|
||||||
"vfile-reporter": "^8.1.1"
|
"vfile-reporter": "^8.1.1"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@rollup/plugin-commonjs": "^28.0.1",
|
|
||||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
||||||
"rollup": "^4.24.0",
|
|
||||||
"rollup-plugin-cleanup": "^3.2.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
vcbuild.bat
21
vcbuild.bat
@ -122,7 +122,6 @@ if /i "%1"=="lint-js-build" set lint_js_build=1&goto arg-ok
|
|||||||
if /i "%1"=="lint-js-fix" set lint_js_fix=1&goto arg-ok
|
if /i "%1"=="lint-js-fix" set lint_js_fix=1&goto arg-ok
|
||||||
if /i "%1"=="jslint" set lint_js=1&echo Please use lint-js instead of jslint&goto arg-ok
|
if /i "%1"=="jslint" set lint_js=1&echo Please use lint-js instead of jslint&goto arg-ok
|
||||||
if /i "%1"=="lint-md" set lint_md=1&goto arg-ok
|
if /i "%1"=="lint-md" set lint_md=1&goto arg-ok
|
||||||
if /i "%1"=="lint-md-build" set lint_md_build=1&goto arg-ok
|
|
||||||
if /i "%1"=="lint" set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
|
if /i "%1"=="lint" set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
|
||||||
if /i "%1"=="lint-ci" set lint_cpp=1&set lint_js_ci=1&goto arg-ok
|
if /i "%1"=="lint-ci" set lint_cpp=1&set lint_js_ci=1&goto arg-ok
|
||||||
if /i "%1"=="format-md" set format_md=1&goto arg-ok
|
if /i "%1"=="format-md" set format_md=1&goto arg-ok
|
||||||
@ -750,24 +749,21 @@ echo running lint-js
|
|||||||
goto lint-js-fix
|
goto lint-js-fix
|
||||||
|
|
||||||
:lint-js-fix
|
:lint-js-fix
|
||||||
if not defined lint_js_fix goto lint-md-build
|
if not defined lint_js_fix goto lint-md
|
||||||
if not exist tools\eslint\node_modules\eslint goto no-lint
|
if not exist tools\eslint\node_modules\eslint goto no-lint
|
||||||
echo running lint-js-fix
|
echo running lint-js-fix
|
||||||
%node_exe% tools\eslint\node_modules\eslint\bin\eslint.js --cache --max-warnings=0 --report-unused-disable-directives --rule "@stylistic/js/linebreak-style: 0" eslint.config.mjs benchmark doc lib test tools --fix
|
%node_exe% tools\eslint\node_modules\eslint\bin\eslint.js --cache --max-warnings=0 --report-unused-disable-directives --rule "@stylistic/js/linebreak-style: 0" eslint.config.mjs benchmark doc lib test tools --fix
|
||||||
goto lint-md-build
|
goto lint-md-build
|
||||||
|
|
||||||
:no-lint
|
|
||||||
echo Linting is not available through the source tarball.
|
|
||||||
echo Use the git repo instead: $ git clone https://github.com/nodejs/node.git
|
|
||||||
goto lint-md-build
|
|
||||||
|
|
||||||
:lint-md-build
|
:lint-md-build
|
||||||
if not defined lint_md_build goto lint-md
|
if not defined lint_md if not defined format_md goto lint-md
|
||||||
echo "Deprecated no-op target 'lint_md_build'"
|
cd tools\lint-md
|
||||||
goto lint-md
|
%npm_exe% ci
|
||||||
|
cd ..\..
|
||||||
|
|
||||||
:lint-md
|
:lint-md
|
||||||
if not defined lint_md goto format-md
|
if not defined lint_md goto format-md
|
||||||
|
if not exist tools\lint-md\node_modules goto no-lint
|
||||||
echo Running Markdown linter on docs...
|
echo Running Markdown linter on docs...
|
||||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||||
set lint_md_files=
|
set lint_md_files=
|
||||||
@ -782,6 +778,7 @@ goto format-md
|
|||||||
|
|
||||||
:format-md
|
:format-md
|
||||||
if not defined format_md goto exit
|
if not defined format_md goto exit
|
||||||
|
if not exist tools\lint-md\node_modules goto no-lint
|
||||||
echo Running Markdown formatter on docs...
|
echo Running Markdown formatter on docs...
|
||||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||||
set lint_md_files=
|
set lint_md_files=
|
||||||
@ -792,6 +789,10 @@ for /D %%D IN (doc\*) do (
|
|||||||
)
|
)
|
||||||
%node_exe% tools\lint-md\lint-md.mjs --format %lint_md_files%
|
%node_exe% tools\lint-md\lint-md.mjs --format %lint_md_files%
|
||||||
ENDLOCAL
|
ENDLOCAL
|
||||||
|
|
||||||
|
:no-lint
|
||||||
|
echo Linting is not available through the source tarball.
|
||||||
|
echo Use the git repo instead: $ git clone https://github.com/nodejs/node.git
|
||||||
goto exit
|
goto exit
|
||||||
|
|
||||||
:create-msvs-files-failed
|
:create-msvs-files-failed
|
||||||
|
Loading…
Reference in New Issue
Block a user