-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add markdownlint script to lint docs markup
Adds a new script `lint-md-docs` that runs markdownlint to lint markdown files for proper syntax. A default `.markdownlint.json` config is included, it will require some testing to tune. Fixes #12426
- Loading branch information
Showing
6 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
bin | ||
build | ||
node_modules | ||
phpunit | ||
playground | ||
storybook | ||
test | ||
vendor | ||
wordpress |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"default": true, | ||
"MD003": { "style": "atx" }, | ||
"MD007": { "indent": 4 }, | ||
"MD013": { "line_length": 9999 }, | ||
"no-hard-tabs": false, | ||
"whitespace": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ | |
"jest-puppeteer": "^4.3.0", | ||
"js-yaml": "^3.13.1", | ||
"lodash": "^4.17.15", | ||
"markdownlint": "^0.18.0", | ||
"markdownlint-cli": "^0.21.0", | ||
"minimist": "^1.2.0", | ||
"npm-package-json-lint": "^4.0.3", | ||
"prettier": "npm:[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const { sync: spawn } = require( 'cross-spawn' ); | ||
const { sync: resolveBin } = require( 'resolve-bin' ); | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
const { | ||
fromConfigRoot, | ||
getArgsFromCLI, | ||
hasArgInCLI, | ||
hasFileArgInCLI, | ||
hasProjectFile, | ||
} = require( '../utils' ); | ||
|
||
const args = getArgsFromCLI(); | ||
|
||
const defaultFilesArgs = hasFileArgInCLI() ? [] : [ '**/*.md' ]; | ||
|
||
// See: https://eslint.org/docs/user-guide/configuring#using-configuration-files-1. | ||
const hasLintConfig = hasArgInCLI( '-c' ) || hasArgInCLI( '--config' ); | ||
|
||
// When a configuration is not provided by the project, use from the default | ||
// provided with the scripts module. Instruct ESLint to avoid discovering via | ||
// the `--no-eslintrc` flag, as otherwise it will still merge with inherited. | ||
const defaultConfigArgs = ! hasLintConfig ? | ||
[ '--config', fromConfigRoot( '.markdownlint.json' ) ] : | ||
[]; | ||
|
||
// See: https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories. | ||
const hasIgnoredFiles = hasArgInCLI( '--ignore' ) || | ||
hasProjectFile( '.markdownlintignore' ); | ||
|
||
const defaultIgnoreArgs = ! hasIgnoredFiles ? | ||
[ '--ignore', 'build', '--ignore', 'node_modules' ] : | ||
[]; | ||
|
||
const result = spawn( | ||
resolveBin( 'markdownlint-cli', { executable: 'markdownlint' } ), | ||
[ ...defaultConfigArgs, ...defaultIgnoreArgs, ...args, ...defaultFilesArgs ], | ||
{ stdio: 'inherit' } | ||
); | ||
|
||
process.exit( result.status ); |