vhf / remark-lint-alphabetize-lists

remark-lint-alphabetize-lists
7 stars 5 forks source link

IDEA: Configure collator language depending on info provided by visited file #19

Open davorpa opened 3 years ago

davorpa commented 3 years ago

Defeat

Having a merelly { language: "your lang" } as config object is a bit simple when remark is applied in a multilanguage project.

https://github.com/vhf/remark-lint-alphabetize-lists/blob/ee5f968040acf941c9c4d61fefb2bb1e3b1e8a7b/lib/alphabetical-list-items.js#L17

If some rules about naming files are ensured (eg. by path [folder]/en-US/some-markdown-file.md or by file [folder]/some-markdown-file.en-US.md), something very common in software development, it will be easier use this plugin with zero config.

Proposal

Add a new config parameters to enhace it.

Draft:

Use remark-frontmatter plugin could be the best option to extract this info if some microblogging static generators like Jekyll, Hugo, ... are used in the project. So... another param??

An example of language-resolver can be found at fpb-lint-cli: https://github.com/vhf/free-programming-books-lint/blob/b72812e3cf51e0dce322a30d465f50ee618f3d0c/lib/lint.js#L59-L70