简体   繁体   English

对 ESLINT 和 Stylelint 等配置文件使用 JS 扩展有什么好处吗?

[英]Is there any benefit to use JS extension for config files like ESLINT and Stylelint?

I was wondering is there any downside or positive side when creating eslint or stylelint etc files to add the JS prefix to it.我想知道在创建 eslint 或 stylelint 等文件以向其添加 JS 前缀时是否有任何不利或积极的一面。

I have noticed you can do it in multiple ways:我注意到你可以通过多种方式做到这一点:

a stylelint property in package.json
a .stylelintrc file
a stylelint.config.js file exporting a JS object


.eslintrc
.eslintrc.js

Is there any speed benefit or is one better then the other or is it just personal preference?是否有任何速度优势,或者哪个比另一个更好,或者只是个人喜好? is one faster or not?是不是更快?

Adding an extension makes it easier for editors, like VS Code, to select the correct language for syntax highlighting, autocompletion etc.添加扩展使编辑器(如 VS Code)更容易为语法突出显示、自动完成等选择正确的语言。

  • a .stylelintrc file can contain JSON, YAML or JavaScript. .stylelintrc文件可以包含 JSON、YAML 或 JavaScript。
  • a .eslintrc file can contain JSON or YAML. .eslintrc文件可以包含 JSON 或 YAML。

This ambiguity isn't good, and the reason that extensionless .eslintrc files are now deprecated in ESLint.这种歧义是不好的,这也是.eslintrc中现在不推荐使用无扩展名的.eslintrc文件的原因。

The difference between .stylelintrc.js and stylelint.config.js is purely preference, as is .stylelintrc.json and using a stylelint property in package.json . .stylelintrc.jsstylelint.config.js之间的区别纯粹是偏好,就像.stylelintrc.json和在package.json使用stylelint属性一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM