Markdown linting helpers for Electron org repos
yarn global add @electron/lint-roller
lint-roller-markdown-links --root docs/ "docs/**/*.md"A base config for markdownlint is provided for consistent linting rules
across repos. To use the base config, extend it in .markdownlint.json:
{
"extends": "@electron/lint-roller/configs/markdownlint.json"
}lint-roller-markdown-links is a command to further lint links to find
broken relative links, including URL fragments.
lint-roller-markdown-oxlint is a command to lint JS code blocks in Markdown
with oxlint, using the project's own oxlint installation and config
(--config <path> to use a different one). A handful of rules which don't
make sense for isolated code snippets (no-undef, no-unused-vars, etc.) are
always disabled. TypeScript code blocks are also linted if --typescript is
passed, and --fix writes any autofixes back to the Markdown files. Linting
can be disabled for specific code blocks by adding @nolint to the info
string. Code blocks are linted from a temporary directory, so path-based
overrides in the config do not apply to them. oxlint must be installed
alongside this package.
lint-roller-markdown-oxfmt is a command to check the formatting of JS/TS
(and json5) code blocks in Markdown with oxfmt, using the project's own
oxfmt installation and config as found from the working directory
(--config <path> to use a different one). --fix writes the formatted code
back to the Markdown files. Formatting can be disabled for specific code
blocks by adding @noformat to the info string (this is independent of
@nolint, so use both to skip a block entirely). Code blocks are formatted from a temporary
directory, so path-based overrides in the config do not apply to them.
oxfmt must be installed alongside this package.
A code block which is just a bare object literal is not valid JavaScript, so
give those json5 as their language instead of js - they are then left
alone by the linter and type checker, but still formatted.
lint-roller-markdown-ts-check is a command to type check JS/TS code blocks
in Markdown with tsc. Type checking can be disabled for specific code blocks
by adding @ts-nocheck to the info string, specific lines can be ignored by
adding @ts-expect-error=[<line1>,<line2>] to the info string, and additional
globals can be defined with @ts-type={name:type}. The Window object can
be extended with more types using @ts-window-type={name:type}. When type
checking TypeScript blocks in the same Markdown file, global augmentation
(via declare global) can be shared between code blocks by putting
@ts-noisolate on the code block doing the global augmentation.
MIT