Skip to content

Commit

Permalink
Override markdownlint-cli2 config for zh-cn (#14246)
Browse files Browse the repository at this point in the history
* Override markdownlint-cli2 config for zh-cn

* Add zh-tw style angled quotes

* use same globs as the content repo

* Address review comments

* Update deprecated use

* Apply suggestions from code review

Co-authored-by: A1lo <[email protected]>

---------

Co-authored-by: A1lo <[email protected]>
  • Loading branch information
OnkarRuikar and yin1999 committed Aug 12, 2023
1 parent a56e5a7 commit 49d6818
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 2 deletions.
73 changes: 73 additions & 0 deletions files/zh-cn/.markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"config": {
"extends": "../../.markdownlint-cli2.jsonc",
"search-replace": {
"rules": [
{
"name": "nbsp",
"message": "Don't use no-break spaces",
"searchPattern": "/ /g",
"replace": " ",
"searchScope": "all"
},
// XXX Many instances still found in translated content
// {
// "name": "m-dash",
// "message": "Don't use '--'. Use m-dash — instead",
// "search": " -- ",
// "replace": "——",
// "searchScope": "text"
// },
// {
// "name": "relative-link",
// "message": "Internal links should start with '/'",
// "searchPattern": "/([\\(\"])(en-US|zh-CN)\\/docs/gi",
// "replace": "$1/$2/docs",
// "searchScope": "text"
// },
{
"name": "relative-link-path",
"message": "Don't use relative paths",
"search": "](..",
"searchScope": "text"
},
{
"name": "trailing-spaces",
"message": "Avoid trailing spaces",
"searchPattern": "/ +$/gm",
"replace": "",
"searchScope": "all"
},
{
"name": "double-spaces",
"message": "Avoid double spaces",
"searchPattern": "/([^\\s>]) ([^\\s|])/g",
"replace": "$1 $2",
"searchScope": "text"
},
{
"name": "stuck-definition",
"message": "Character is stuck to definition description marker",
"searchPattern": "/- :(\\w)/g",
"replace": "- : $1",
"searchScope": "text"
},
{
"name": "fqdn-moz-links",
"message": "Don't use developer.mozilla.org for links, except for blog posts",
"searchPattern": "/\\]\\(https:\\/\\/developer.mozilla.org\\/(?!en-US\\/blog\\/)/g",
"replace": "](/",
"searchScope": "text"
}
// XXX Many instances still found in translated content
// {
// "name": "localhost-links",
// "message": "Don't use localhost for links",
// "searchPattern": "/\\]\\(https?:\\/\\/localhost:\\d+\\//g",
// "replace": "](/",
// "searchScope": "text"
// }
]
}
}
}
88 changes: 88 additions & 0 deletions files/zh-tw/.markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"config": {
"extends": "../../.markdownlint-cli2.jsonc",
"search-replace": {
"rules": [
// XXX Many instances still found in translated content
// {
// "name": "curly-double-quotes",
// "message": "Don't use curly double quotes",
// "searchPattern": "/“(.*?)”/gm",
// "replace": "「$1」",
// "searchScope": "text"
// },
// {
// "name": "double-quotes",
// "message": "Don't use double quotes",
// "searchPattern": "/‘(.*?)’/g",
// "replace": "『$1』",
// "searchScope": "text"
// },
{
"name": "nbsp",
"message": "Don't use no-break spaces",
"searchPattern": "/ /g",
"replace": " ",
"searchScope": "all"
},
// XXX Many instances still found in translated content
// {
// "name": "m-dash",
// "message": "Don't use '--'. Use m-dash — instead",
// "search": " -- ",
// "replace": "——",
// "searchScope": "text"
// },
// {
// "name": "relative-link",
// "message": "Internal links should start with '/'",
// "searchPattern": "/([\\(\"])(en-US|zh-TW)\\/docs/gi",
// "replace": "$1/$2/docs",
// "searchScope": "text"
//},
{
"name": "relative-link-path",
"message": "Don't use relative paths",
"search": "](..",
"searchScope": "text"
},
{
"name": "trailing-spaces",
"message": "Avoid trailing spaces",
"searchPattern": "/ +$/gm",
"replace": "",
"searchScope": "all"
},
{
"name": "double-spaces",
"message": "Avoid double spaces",
"searchPattern": "/([^\\s>]) ([^\\s|])/g",
"replace": "$1 $2",
"searchScope": "text"
},
{
"name": "stuck-definition",
"message": "Character is stuck to definition description marker",
"searchPattern": "/- :(\\w)/g",
"replace": "- : $1",
"searchScope": "text"
},
{
"name": "fqdn-moz-links",
"message": "Don't use developer.mozilla.org for links, except for blog posts",
"searchPattern": "/\\]\\(https:\\/\\/developer.mozilla.org\\/(?!en-US\\/blog\\/)/g",
"replace": "](/",
"searchScope": "text"
}
// XXX Many instances still found in translated content
// {
// "name": "localhost-links",
// "message": "Don't use localhost for links",
// "searchPattern": "/\\]\\(https?:\\/\\/localhost:\\d+\\//g",
// "replace": "](/",
// "searchScope": "text"
// }
]
}
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
},
"type": "module",
"scripts": {
"fix:json": "prettier -w \"**/*.json\"",
"fix:json": "prettier -w \"**/*.json(c)?\"",
"fix:md": "markdownlint-cli2 --fix \"**/*.md\" && prettier -w \"**/*.md\"",
"fix:yml": "prettier -w \"**/*.yml\"",
"lint:json": "prettier -c \"**/*.json\"",
"lint:json": "prettier -c \"**/*.json(c)?\"",
"lint:md": "markdownlint-cli2 \"**/*.md\" && prettier -c \"**/*.md\"",
"lint:yml": "prettier -c \"**/*.yml\"",
"prepare": "husky install"
Expand Down

0 comments on commit 49d6818

Please sign in to comment.