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

Allow per-rule ignores #109

Closed
queengooborg opened this issue Jul 15, 2023 · 3 comments
Closed

Allow per-rule ignores #109

queengooborg opened this issue Jul 15, 2023 · 3 comments

Comments

@queengooborg
Copy link

queengooborg commented Jul 15, 2023

When applying the formatting rules of mdn/content to mdn/translated-content, we ran into a slight issue regarding smart (curly) quotes with the Chinese locale. Apparently, it is grammatically accurate to use smart quotes in place of normal quotes, so the rule to search and replace smart quotes causes localization issues.

It would be great to see a filter option added, which is an object containing optional include and exclude properties, which are either a string or array of strings containing file globs for that rule to apply to or ignore. For example:

{
  "name": "curly-double-quotes",
  "message": "Don't use curly double quotes",
  "searchPattern": "/“|”/g",
  "replace": "\"",
  "searchScope": "text",
  "filter": {"exclude": "**/zh-cn/**"} // Ignore all Simplified Chinese files
},
{
  "name": "m-dash",
  "message": "Don't use '--'. Use m-dash — instead",
  "search": " -- ",
  "replace": "",
  "searchScope": "text",
  "filter": {"exclude": ["README.md", "**/es/**"]} // Ignore README.md in root, and all Spanish files
},
{
  "name": "em-dash",
  "message": "Don't use '--'. Use em-dash — instead",
  "search": " -- ",
  "replace": "",
  "searchScope": "text",
  "filter": {"include": "**/es/**"} // Only apply to Spanish files
},
@OnkarRuikar
Copy link
Owner

@queengooborg
Copy link
Author

I don't really consider this to be fixed, only mitigated. I'm going to work on implementing this functionality in a fork.

@OnkarRuikar
Copy link
Owner

I don't really consider this to be fixed, only mitigated. I'm going to work on implementing this functionality in a fork.

Adding third mechanism to filter files will complicate things. For example, which mechanism should take precedence and how will they interplay?

This could've been solved using separate command for each locale as well:

"lint:md" : "lint-zh-cn:md; lint-es:md; lint-ru:md ...",
"lint-zh-cn:md": "markdownlint-cli2 --config zh-cn.markdonwlint.config docs/zh-cn/*.md files/zh-cn/**/*.md"
"lint-es:md": "markdownlint-cli2 --config es.markdonwlint.config docs/es/*.md files/es/**/*.md"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants