build: separate lint task package READMEs and /docs .md files#11139
build: separate lint task package READMEs and /docs .md files#11139batpigandme wants to merge 11 commits intostdlib-js:developfrom
.md files#11139Conversation
Introduce a dedicated Remark configuration for Markdown files located outside of the package directory and update the pre-commit hook to run separate linting tasks for package and non-package files.
Assisted-by: Calude-Opus-4-6
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: missing_dependencies
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
|
/stdlib merge |
Introduce specialized remark configurations and Makefile targets to provide granular linting for different classes of Markdown files (package readmes, and docs).
Update the pre-commit hook to run separate tasks for package READMEs, documentation files, and general Markdown files.
Assisted-by: Claude-Opus-4-6
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg
status: na
- task: lint_markdown_docs
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg
status: na
- task: lint_markdown_docs
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
|
@kgryte Per our discussion yesterday, I've separated out package READMEs and docs (although docs rules apply to everything not in the package READMEs, it makes sense to have a separate config for future editing). I've updated the PR description above to reflect the changes. The find variables and list targets are now in
|
.md files
|
/stdlib merge |
kgryte
left a comment
There was a problem hiding this comment.
Check naming conventions as discussed during 1:1.
Rename `MARKDOWN_LINT_FLAGS_PKG_READMES` and `MARKDOWN_LINT_FLAGS_DOCS` to ensure naming consistency across the Markdown linting configuration.
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Rename `.remarkrc.pkg-readmes.js` to `.remarkrc.pkg_readmes.js` to
use consistent underscore separators matching the naming of the
recently added `make` targets.
Tighten file-matching in the pre-commit hook: narrow the pkg README
filter to `^lib/node_modules/@stdlib/.*/README\.md$` so non-README
Markdown in package dirs is not routed to the dedicated README task,
and mirror the same precision in the "other Markdown" exclusion.
Remove the redundant `.github/workflows` exclusion from the docs
filter, which can never match a `^docs/`-rooted path.
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: passed
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Update `REMARK_CONF_PKG_READMES` in `tools/make/lib/lint/markdown/` to match the renamed config file from 8a49ffd. Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com> --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Athan <kgryte@gmail.com>
There was a problem hiding this comment.
Just to clarify, this is intentional? Meaning, for other Markdown files, we want to use list of plugins used for docs?
That is possible, if we assume that the docs config is effectively a subset of all the plugins we want to apply.
There was a problem hiding this comment.
Yes. So this was a question I brought up in #11121 (comment).
My question is whether we want to apply the full set of plugins/default
REMARK_CONFto all markdown files EXCEPT those in/docs, or if we want to apply the full plugins set ONLY to those files matchinglib/node_modules/@stdlib/.
By default, remark uses all of the plugins in the plugins subfolder (which includes linters and processors). Because these plugins were designed to work with the very structured package READMEs, this includes things like linting for the expected HTML sections.
So, you're right, the /docs config is just applying a subset. Right now we're basically saying "if it's not a package README, don't expect the HTML sections to be there" (we went even stricter than my original proposal where everything in lib/node_modules/@stdlib would get the full processing).
I definitely think it's weird (and unintuitive) to have the /docs setup be, effectively, the default. But, we also don't expect those HTML sections in the root documentation.
We could do a rename, or we could not use /docs as the default.
We already have them in three buckets (package READMEs, docs, and other), so it's easy enough to do (it's just that "other" currently gets the same treatment as docs).
There was a problem hiding this comment.
Dug into the transformer plugins (equations, namespace-toc, related, pkg-urls, stdlib-urls). None of them actually load via .remarkrc.*— each recipe attaches them via --use flags. So, they only ever touch package READMEs (7,291 READMEs have <equation> tags; zero non-READMEs do; the other recipes scope explicitly to READMEs via find ... -name 'README.md' or list-pkgs-namespace-readmes).
So .remarkrc.js-as-docs-subset doesn't route through any transformer plugin. The design question is purely about lint ergonomics for non-README, non-/docs markdown.
kgryte
left a comment
There was a problem hiding this comment.
My guess is that since we are mucking with lint recipes, we'll also need to update various workflow files. E.g.,
And there may be more.
If we merge this as is, our CI will start behaving differently, so we should make sure that it behaves as intended.
Classify Markdown files into package README, `/docs`, and other
buckets so each is linted with the corresponding remark config,
matching the pre-commit hook partition.
Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
Swept
One judgment call: |
Previously, `plugins/index.js` defined the full plugin set and `plugins/docs.js` was a parallel bundle missing the two HTML-section lint rules. The general `.remarkrc.js` loaded `plugins/docs.js`, leaving the relationship between configs subtractive in spirit. Rework the bundle hierarchy to be additive: rename `plugins/index.js` to `plugins/base.js` and drop the two HTML-section pushes so it holds only the universal plugins. Add `plugins/pkg_readmes.js` which extends base with `remark-lint-expected-html-sections` and `remark-lint-html-section-structure`. Rewrite `plugins/docs.js` as a thin re-export of base, leaving a hook for future documentation-specific rules. Update `.remarkrc.js` to load base directly and `.remarkrc.pkg_readmes.js` to load the new pkg_readmes bundle. Ref: stdlib-js#11139 (comment) Assisted-by: Claude Opus 4.7 <noreply@anthropic.com> --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
|
I've done a refactor using the Overview: I've matched the idiom used in the (now) var plugins = [];
plugins.push( require( './frontmatter' ) );
plugins = plugins.concat( require( './lint' ) );
plugins.push( require( './eslint' ) );
...for pkg_readmes.js var plugins = [];
plugins = plugins.concat( require( './base' ) );
plugins.push( require( './lint-expected-html-sections' ) );
plugins.push( require( './lint-html-section-structure' ) );Yesterday, you'd mentioned using var plugins = require( './base' ).slice();
plugins.push( require( './lint-expected-html-sections' ) );
plugins.push( require( './lint-html-section-structure' ) );If you'd prefer that, just let me know. |
Dedicated Remark configuration for Markdown files in package directories and the docs directory and update the pre-commit hook to run separate linting tasks for package and non-package files.
Assisted-by: Calude-Opus-4-6
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves #11121
Description
This pull request:
This PR adds separate remark lint configurations for package READMEs,
/docsMarkdown files, and general Markdown files. Previously, all Markdown files were linted with the same remark config, which meant rules specific to package READMEs (likeremark-lint-expected-html-sectionsandremark-lint-html-section-structure) were applied to files where they don't belong (e.g., files in/docs).Remark configurations:
.remarkrc.js— default config for general Markdown files (no HTML section rules).remarkrc.pkg-readmes.js— package READMEs (includes HTML section rules).remarkrc.docs.js— documentation files (no HTML section rules, separate for future customization)New Make targets:
Linting:
make lint-markdown-package-readmes— lint all package READMEsmake lint-markdown-package-readme-files FILES='...'— lint a specified list of package READMEsmake lint-markdown-docs— lint all documentation Markdown filesmake lint-markdown-docs-files FILES='...'— lint a specified list of documentation filesmake lint-markdown/make lint-markdown-files— lint general Markdown (unchanged targets, now uses default config)Listing:
make list-markdown-pkg-readmes— list all package README files (now defined inls/markdown/pkg_readmes.mk)make list-markdown-docs— list all documentation Markdown files (now defined inls/markdown/docs.mk)All targets support filter patterns, e.g.:
Pre-commit hook now splits changed Markdown files into three categories and lints each with the appropriate config.
Related Issues
This pull request has the following related issues:
/docs#11121 etc/remark/.remarkrc.jsQuestions
I realize it's a bit weird that we're loading the plugins list for docs for the general remarkrc. We don't need to do the HTML section linting for non-package-README files, though. The reason for having three targets is because we might want to do separate processing for
/docsfiles in the future. Currently it's the same config as "everything else".https://github.com/stdlib-js/stdlib/pull/11139/changes#diff-e7ff32f40f118b3274e48d9933d7c636c4d7cb9788b6d6dcf25a370631567b91
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
Used for understanding the current remark build and for generating new make setup (all of which I read and reviewed).
@stdlib-js/reviewers