TSLint.json配置文件(https://github.com/palantir/tslint)支持extends和如下所示的rulesDirectory数组
{
"extends": [
"tslint-microsoft-contrib",
"tslint-config-security"
],
"rulesDirectory": [
"node_modules/tslint-eslint-rules/dist/rules",
"node_modules/tslint-microsoft-contrib",
"node_modules/tslint-config-security"
]
}
对于对该工具不熟悉的新用户来说,这些文档似乎对解释有点开放。
如果有人能澄清extends和rulesDirectory在VS代码编辑器和一般tslint中的使用行为,我将不胜感激。
extends 是否提供默认配置(如果由包提供)?rulesDirectory不同吗?- Does `rulesDirectory` only provide rules for you to specifically opt-in(and is required if specifying rules in the root tslint.json)?
- Should I still specify the `tslint` packages in both `extends` _**and**_ `rulesDirectory`?
extends从另一个tslint配置文件中提供默认设置,我是否能够指定rulesDirectory并添加一个规则来覆盖特定的标志?担心,因为只有一些规则出现在IntelliSense自动完成中,而且我希望有几个行为更清晰。
发布于 2018-07-09 06:21:48
extends和rulesDirectory在TSLint中有什么区别?
他们很不一样。
extends允许您应用现有的tslint配置,然后扩展它。rulesDirectory只允许您为自定义规则添加目录。发布于 2018-07-08 22:51:53
extends?: string | string[]:内置配置预置的名称(请参阅下面的内置预置),或此配置扩展的其他配置文件的路径或路径数组。此值使用节点模块解析语义进行处理。例如,"tslint-config"的值将告诉TSLint尝试将名为“tslint”的模块的主文件作为配置文件加载。还可以指定节点模块内的特定文件,例如。"tslint-config/path/to/submodule"。也支持JSON文件或JS模块的相对路径,例如"./tslint-config"。rulesDirectory?: string | string[]:指向自定义规则目录的路径或路径数组。如果将index.js放置在规则目录中,则使用节点模块解析语义来处理这些值。如果模块不能被解析,我们回退使用相对路径或绝对路径。如果您想避免模块解析,可以直接使用相对路径或绝对路径(例如,使用./)。此rules块中指定的任何规则都将覆盖正在扩展的任何基本配置中配置的规则。
https://stackoverflow.com/questions/51236513
复制相似问题