Skip to content

build: separate lint task package READMEs and /docs .md files#11139

Open
batpigandme wants to merge 11 commits intostdlib-js:developfrom
batpigandme:docs-remarkconfig
Open

build: separate lint task package READMEs and /docs .md files#11139
batpigandme wants to merge 11 commits intostdlib-js:developfrom
batpigandme:docs-remarkconfig

Conversation

@batpigandme
Copy link
Copy Markdown
Member

@batpigandme batpigandme commented Mar 25, 2026

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:

  • 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 ---

Resolves #11121

Description

What is the purpose of this pull request?

This pull request:

This PR adds separate remark lint configurations for package READMEs, /docs Markdown files, and general Markdown files. Previously, all Markdown files were linted with the same remark config, which meant rules specific to package READMEs (like remark-lint-expected-html-sections and remark-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 READMEs
  • make lint-markdown-package-readme-files FILES='...' — lint a specified list of package READMEs
  • make lint-markdown-docs — lint all documentation Markdown files
  • make lint-markdown-docs-files FILES='...' — lint a specified list of documentation files
  • make 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 in ls/markdown/pkg_readmes.mk)
  • make list-markdown-docs — list all documentation Markdown files (now defined in ls/markdown/docs.mk)

All targets support filter patterns, e.g.:

make lint-markdown-package-readmes MARKDOWN_PKG_READMES_FILTER=".*/math/base/special/abs/.*"
make list-markdown-docs MARKDOWN_DOCS_FILTER=".*/contributing/.*"

Pre-commit hook now splits changed Markdown files into three categories and lints each with the appropriate config.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

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 /docs files in the future. Currently it's the same config as "everything else".

https://github.com/stdlib-js/stdlib/pull/11139/changes#diff-e7ff32f40f118b3274e48d9933d7c636c4d7cb9788b6d6dcf25a370631567b91

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

Used for understanding the current remark build and for generating new make setup (all of which I read and reviewed).


@stdlib-js/reviewers

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
---
@batpigandme
Copy link
Copy Markdown
Member Author

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Mar 25, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Mar 25, 2026
@github-actions github-actions Bot mentioned this pull request Mar 25, 2026
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
---
@batpigandme
Copy link
Copy Markdown
Member Author

@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 tools/make/lib/ls/markdown/:

  • pkg_readmes.mkFIND_MARKDOWN_PKG_READMES_CMD, MARKDOWN_PKG_READMES_FILES, list-markdown-pkg-readmes
  • docs.mkFIND_MARKDOWN_DOCS_CMD, MARKDOWN_DOCS_FILES, list-markdown-docs
  • files.mk — existing FIND_MARKDOWN_CMD, MARKDOWN_FILES, list-markdown-files

@batpigandme batpigandme changed the title build: separate lint task for non-package Markdown files build: separate lint task package READMEs and /docs files Mar 26, 2026
@batpigandme batpigandme changed the title build: separate lint task package READMEs and /docs files build: separate lint task package READMEs and /docs .md files Mar 26, 2026
@batpigandme
Copy link
Copy Markdown
Member Author

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Mar 26, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Mar 26, 2026
@batpigandme batpigandme marked this pull request as ready for review March 27, 2026 12:23
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Mar 27, 2026
@batpigandme batpigandme requested a review from kgryte March 27, 2026 12:24
Comment thread etc/remark/.remarkrc.pkg_readmes.js
Comment thread tools/git/hooks/pre-commit Outdated
Comment thread tools/git/hooks/pre-commit Outdated
Comment thread tools/git/hooks/pre-commit Outdated
Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check naming conventions as discussed during 1:1.

@kgryte kgryte added the Tools Issue or pull request related to project tooling. label Apr 8, 2026
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
---
Comment thread tools/make/lib/ls/markdown/pkg_readmes.mk Outdated
Comment thread tools/make/lib/ls/markdown/pkg_readmes.mk Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte kgryte requested a review from a team April 19, 2026 09:52
Comment thread etc/remark/.remarkrc.js
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

@batpigandme batpigandme Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_CONF to all markdown files EXCEPT those in /docs, or if we want to apply the full plugins set ONLY to those files matching lib/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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 19, 2026
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
---
@batpigandme
Copy link
Copy Markdown
Member Author

My guess is that since we are mucking with lint recipes, we'll also need to update various workflow files...
And there may be more.

Swept .github/workflows/:

  • lint_changed_files.yml:147 and lint_random_files.yml:255 - used three-bucket partition (pkg READMEs / /docs / other) mirroring the pre-commit hook's classification from 8a49ffd, so local and CI route files through the same configs.
  • markdown_pkg_urls.yml:125 - markdown-pkg-urls is URL rewriting, not lint. Unaffected.
  • scripts/common/task_runner:225 - # make lint-markdown is commented out. Flagging but left alone.

One judgment call: lint_changed_files.yml kept its existing \.github/workflows/.*\.md$ exclusion (moved to the "other" bucket to match the hook); lint_random_files.yml didn't have the exclusion, and I didn't add it. LMK if you'd rather I unify them.

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
---
@batpigandme
Copy link
Copy Markdown
Member Author

batpigandme commented Apr 23, 2026

I've done a refactor using the base convention we (@kgryte and I) discussed in our 1:1.

Overview:

etc/remark/
  .remarkrc.js              → plugins/base.js         (68 plugins)
  .remarkrc.docs.js         → plugins/docs.js         (= base, 68)
  .remarkrc.pkg_readmes.js  → plugins/pkg_readmes.js  (base + 2 HTML, 70)
  plugins/
    base.js          ← NEW (the 5 universal blocks)
    docs.js          ← rewritten as thin wrapper: `require('./base')`
    pkg_readmes.js   ← NEW (base + HTML-section lints)
    index.js         ← DELETED
    [subdirs unchanged]

I've matched the idiom used in the (now) base.js (formerly index.js).

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 slice(), which would be:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Apply a subset of remark rules/plugins to files in /docs

3 participants