HTMLHint icon indicating copy to clipboard operation
HTMLHint copied to clipboard

Use cosmiconfig for configuration loading

Open thasmo opened this issue 8 years ago • 13 comments

Would be awesome if HTMLHint used cosmiconfig for loading the configuration.

thasmo avatar Apr 23 '16 08:04 thasmo

Can you show the feature of cosmiconfig?

yaniswang avatar May 01 '16 03:05 yaniswang

Their docs are very easy to grasp, but basically it does this:

Find and load a configuration object from
- a package.json property (anywhere down the file tree)
- a JSON or YAML "rc file" (anywhere down the file tree)
- a .config.js CommonJS module (anywhere down the file tree)
- a CLI --config argument

It supports rc files with optional file-type extension, e.g. .sasslintrc.yml or .sasslintrc.json and, as mentioned, it can also read configuration from the package.json file - an option which gains more and more interest lately.

And:

Additionally, all of these search locations are configurable: you can customize filenames or turn off any location.

thasmo avatar May 06 '16 09:05 thasmo

I don't see it is very necessary to use cosmiconfig.

yaniswang avatar May 06 '16 12:05 yaniswang

It's more a suggestion to greatly improve dev/user experience imo, no necessity in the first place.

thasmo avatar May 06 '16 12:05 thasmo

👍 on that, rather than spreading my configurations on 1000 files I prefer to have everything in a single place: package.json, this way I have JS dependencies, eslint and styleling rules, The only thing missing right now is htmlhint 😞

gforcada avatar Mar 21 '17 14:03 gforcada

Indeed. cosmiconfig supports using your preferred method.

thasmo avatar Mar 21 '17 16:03 thasmo

+1.

1. Summary

It would be nice, if HTMLHint will support YAML configuration files. htmllintrc.yaml for example.

2. Argumentation

JSON — is not a good idea for user-editing files. Main reason — user can't write comments, why he uses those or other options. Another arguments:

Also, look at related issue.

Thanks.

Kristinita avatar Mar 03 '19 15:03 Kristinita

To add my two cents, I prefer .js config files supported by cosmiconfig so that I can break configuration into separate CommonJS module files as needed, as well as document them with comments. I've seen far too many config files with settings that have no explanation as to their purpose or reason for why a particular value was chosen for that setting.

ryansully avatar Jun 19 '19 23:06 ryansully

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 14 '20 01:05 stale[bot]

The problem still exists.

Thanks.

Kristinita avatar May 14 '20 05:05 Kristinita

I will work on this after https://github.com/htmlhint/HTMLHint/issues/279

Shinigami92 avatar May 17 '20 09:05 Shinigami92

我坚持我的看法。 在我看来,让 HTMLHint 原生支持 .js 后缀的配置文件是理所当然的事情。

ghost avatar Dec 13 '21 04:12 ghost

If this is implemented, then autocomplete could be used (like in ESLint) in configfile with *.js, *.ts, *.mjs or *.cjs extensions.

.eslintrc.cjs image

gian1200 avatar Jul 03 '23 17:07 gian1200