配置共享设置

ESLint 支持将共享设置添加到配置文件中。当您将 settings 对象添加到配置对象时,它会提供给每个规则。按照惯例,插件将它们感兴趣的设置命名空间以避免与其他设置发生冲突。插件可以使用 settings 来指定应该在所有规则中共享的信息。如果您要添加自定义规则并希望它们能够访问相同的信息,这可能会很有用。这是一个例子:

ESLint supports adding shared settings into configuration files. When you add a settings object to a configuration object, it is supplied to every rule. By convention, plugins namespace the settings they are interested in to avoid collisions with others. Plugins can use settings to specify the information that should be shared across all of their rules. This may be useful if you are adding custom rules and want them to have access to the same information. Here's an example:

export default [
    {
        settings: {
            sharedData: "Hello"
        }
    }
];