-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add linting of source in markdown files #19518
Conversation
Adds eslint-plugin-markdown https://github.com/eslint/eslint-plugin-markdown This allows for linting of code blocks marked js, javascript, or jsx if a code block is not marked it is skipped.
Nice, and FYI, I’m working on the coding standards docs in https://github.com/WordPress/wpcs-docs repo (No pull request yet, working on it locally) and will be creating a new package here |
Further, I’ll look at what stylelint options are available to support listing CSS & SCSS in markdown files too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for opening it.
I think this PR addresses #12426, well at least the part for linting markdown.
It might end up with having two ESLint configs for |
Co-Authored-By: Grzegorz (Greg) Ziółkowski <grzegorz@gziolo.pl>
- Creates a new eslintrc-md.js config for use for markdown docs - The lint-md command uses this config unless another is specified - The config allows for undef and unused vars due to docs contain snippets of code that may be incomplete
Description
Adds eslint-plugin-markdown and the new command
lint-md
This allows for linting of code blocks that are marked js, javascript, or jsx, if a code block is not marked as such it should be skipped.At the moment this uses the same base eslint rules, however we probably will want to adjust these rules for documentation. Most code blocks in documentation are snippets and incomplete chunks of code, so a fair amount of the current errors are due to
no-unused-vars
andno-undef
rules. For example, a chunk of code might show how to set something, but not necessarily using what is set.The first run through all docs:
How has this been tested?
npm install
to install new packagesTo run across all documentation:
3a. Run
npm lint-md
To run across a single file:
3b. $(npm bin)/wp-scripts lint-md docs/designers-developers/key-concepts.md
Types of changes
lint-md
to wp-scriptsNext Steps
We probably want to test out and adjust the rules to make sense for documentation.
Once we get it to a decent config, we can run it against the docs and fix up code that needs fixing and then include in the CI builds.