Skip to content

doc, tools: use eslint-plugin-markdown

Checklist
Affected core subsystem(s)

doc, tools

Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032

Commit 1: an initial step to eliminate parsing errors. Fixing strategies:

  • Mixed conflicting contexts: split into separate code blocks.
  • Object literals erroneously parsed as code blocks:
  • Terminal / REPL interaction logs in repl.md: add <!-- eslint-disable --> to disable linting + preserve syntax highlighting. (see https://github.com/nodejs/node/pull/12563#issuecomment-296071614)
  • Non-js outputs: wrap in ``` ``` instead of ```js ```.
  • Truncated constructions: complete the code.
  • Uncommented ellipses; comment out.
  • Syntax errors: fix.
  • Line numbers in front of the code: move to the line ends and comment out.

Commit 2: conform most of the problematic code to the rules.

Code is checked with this doc/.eslintrc.yaml (see https://gist.github.com/not-an-aardvark/f3cb021e854414128d197dde8d0f62b2)

plugins: [markdown]

rules:
  strict: 0
  no-restricted-properties: 0
  no-undef: 0
  no-unused-vars: 0

Commit 3: add eslint-plugin-markdown stuff

  • npm install eslint-plugin-markdown.
  • Add doc/.eslintrc.yaml; add plugins: [markdown] to the main .eslintrc.yaml.
  • Add <!-- eslint-disable rule --> or <!-- eslint-disable --> for the rest problematic code.
  • .js files in doc folder added to .eslintignore.
  • Update Makefile and vcbuild.bat.

Commit 4: make doc linting a bit more specific (as we do for tests code)

  • Add no-var: 2 and prefer-const: 2 in doc/.eslintrc.yaml.
  • Fix some fragments in docs accordingly.

Merge request reports

Loading