插件和eslint扩展之间有什么区别? [英] What's the difference between plugins and extends in eslint?

查看:418
本文介绍了插件和eslint扩展之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白我们为什么要使用插件和扩展程序。它们之间有什么区别,我需要一个吗?

I don't understand why we have plugins and extends. What is the difference between them and do I need one or the other?

推荐答案

extends使用配置文件,当您将其添加到extends选项时,该文件将应用一组规则。另一方面,插件为您提供了一组规则,您可以根据需要单独应用这些规则。仅拥有插件不会强制执行任何规则。您必须选择所需的规则。
一个插件可以为您提供零个,一个或多个配置文件。如果插件提供了配置文件,那么您可以在插件部分添加插件后,将其加载到扩展部分中。

extends uses a config file which applies set of rules when you add that to the extends options. A plugin on the other hand provides you with a set of rules that you can individually apply depending on your need. Just having a plugin does not enforce any rule. You have to choose which rules you need. A plugin may provide you with zero, one, or more configuration files. If the plugin provides configuration file, then you can load that in your extends section after adding the plugin in the plugins section.

从本质上讲,插件为您提供了一些已编码的规则,并且您可以选择哪些是相关的。它还可以提供配置文件,以应用作者认为在逻辑上分组/相关的规则,但是提供配置文件对于插件来说不是强制性的。另一方面,扩展提供了基于配置文件规范的批量应用规则的功能。

So essentially, plugins given you some rules that have been coded and you can choose which ones are relevant. It may also provide config files to apply rules that the authors think are logically grouped/relevant but providing a config file is not mandatory for a plugin. extends, on the other hand, provides you the ability to apply rules in bulk based on config file specifications.

"plugins": [
  "react"
],
"extends": [
  "eslint:recommended",
  "plugin:react/recommended"
]


示例配置- eslint-config-google


Example Config - eslint-config-google:

"extends": [
  "google"
]

祝你好运...

这篇关于插件和eslint扩展之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆