[英]What is the role of the 'project' in parserOptions inside .eslintrc.js?
first of all, I'm very weak talk to English.首先,我的英语很弱。 sorry:(
对不起:(
I use ESLint in VSCode, and studying Nest.js.我在 VSCode 中使用 ESLint,并研究了 Nest.js。 I can't understand 'project' option in parserOptions inside '.eslintrc.js'
我无法理解“.eslintrc.js”中的 parserOptions 中的“项目”选项
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json', // This is what I'm curious about.
tsconfigRootDir: __dirname,
sourceType: 'module',
},
Why different 'parser' and 'parserOptions.project'??为什么不同的“解析器”和“parserOptions.project”?
By specifying the parser
option, you're telling the compiler to use the package which it should use to parse your typescript code.通过指定
parser
选项,您告诉编译器使用 package 来解析您的 typescript 代码。 Whenever you're compiling your code (or the VSCode is doing the compilation), if you've specified some parserOptions
it will look into those options while building the AST out of the typescript source code.每当您编译代码(或 VSCode 正在进行编译)时,如果您指定了一些
parserOptions
,它将在从 typescript 源代码构建 AST 时查看这些选项。
The project
option inside the parserOptions
tells the parser to find and use the tsconfig.json
in your project. parserOptions
中的project
选项告诉解析器在您的项目中查找和使用tsconfig.json
。 Quoting the doc:引用文档:
This setting is required if you want to use rules which require type information.
如果您想使用需要类型信息的规则,则需要此设置。
Specifying tsconfig.json
and enabling/disabling various options that it provides, you can do a lot of things during typescript compilation.指定
tsconfig.json
并启用/禁用它提供的各种选项,您可以在 typescript 编译期间做很多事情。 More about tsoconfig.jsonhere .有关 tsoconfig.json 的更多信息,请点击此处。
More reading references.更多阅读参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.