Skip to content

Commit

Permalink
Add custom replace rule to markdownlint configuration (mdn#17988)
Browse files Browse the repository at this point in the history
* Add replace rule to markdownlint task

* Update yarn.lock, commands, and add more rules

* Add the dependency

* bump dependancy version

* deleberate error for testing

* revert the test commit
  • Loading branch information
OnkarRuikar authored Sep 5, 2022
1 parent 6f2391b commit 48cdf3e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
41 changes: 40 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,44 @@
"style": "asterisk"
},
"MD051": false,
"MD052": false
"MD052": false,
"search-replace": {
"rules": [
{
"name": "curly-double-quotes",
"message": "Don't use curly double quotes",
"searchPattern": "/“|”/g",
"replace": "\"",
"skipCode": true
},
{
"name": "curly-single-quotes",
"message": "Don't use curly single quotes",
"searchPattern": "/‘|’/g",
"replace": "'",
"skipCode": true
},
{
"name": "m-dash",
"message": "Don't use '--'. Use m-dash — instead",
"search": " -- ",
"replace": "",
"skipCode": true
},
{
"name": "relative-link",
"message": "Internal links should start with '/'",
"search": "(en-US/docs",
"replace": "(/en-US/docs",
"skipCode": true
},
{
"name": "trailing-spaces",
"message": "Avoid trailing spaces",
"searchPattern": "/ +$/gm",
"replace": "",
"skipCode": false
}
]
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"fix:md": "npm run lint:md -- --fix",
"fix:yml": "prettier -w \"**/*.yml\"",
"lint:json": "prettier -c \"**/*.json\"",
"lint:md": "markdownlint \"**/*.md\" -i node_modules",
"lint:md": "markdownlint \"**/*.md\" -i node_modules -r markdownlint-rule-search-replace",
"lint:yml": "prettier -c \"**/*.yml\"",
"start": "yarn up-to-date-check && env-cmd --silent cross-env CONTENT_ROOT=files REACT_APP_DISABLE_AUTH=true BUILD_OUT_ROOT=build yari-server",
"up-to-date-check": "node scripts/up-to-date-check.js"
Expand All @@ -24,6 +24,7 @@
"cross-env": "7.0.3",
"env-cmd": "10.1.0",
"markdownlint-cli": "0.32.2",
"markdownlint-rule-search-replace": "1.0.5",
"prettier": "2.7.1"
}
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,13 @@ markdownlint-rule-helpers@~0.17.2:
resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.17.2.tgz#64d6e8c66e497e631b0e40cf1cef7ca622a0b654"
integrity sha512-XaeoW2NYSlWxMCZM2B3H7YTG6nlaLfkEZWMBhr4hSPlq9MuY2sy83+Xr89jXOqZMZYjvi5nBCGoFh7hHoPKZmA==

[email protected]:
version "1.0.5"
resolved "https://registry.yarnpkg.com/markdownlint-rule-search-replace/-/markdownlint-rule-search-replace-1.0.5.tgz#20cc1681e3c162dd43d19614e3d1515e75cf0299"
integrity sha512-PXpHZuZrqaPA0kpkPSsTPVndxtoM+wgG95V9vzL5sZl+SQUp8hJIHSqOnNJOwd85ykgjbnripZYf0IN40ADkdw==
dependencies:
markdownlint-rule-helpers "~0.17.2"

markdownlint@~0.26.2:
version "0.26.2"
resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.26.2.tgz#11d3d03e7f0dd3c2e239753ee8fd064a861d9237"
Expand Down

0 comments on commit 48cdf3e

Please sign in to comment.