Skip to content
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 custom replace rule to markdownlint configuration #17988

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,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