简体   繁体   English

parserOptions inside.eslintrc.js 中的 'project' 的作用是什么?

[英]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.

相关问题 env.es6=true 和 parserOptions.ecmaVersion=6 at.eslintrc.js 有什么区别? - What the difference between env.es6=true and parserOptions.ecmaVersion=6 at .eslintrc.js? 必须使用import加载ES Module.eslintrc.js - Must use import to load ES Module .eslintrc.js 在 .eslintrc.js 文件中使用导出默认值而不是 module.exports - Use export default in .eslintrc.js file instead of module.exports Webpack中的Node.js,角色是什么? - Node.js in Webpack, what is role? 已为@typescript-eslint/parser 设置解析错误“parserOptions.project” - Parsing error "parserOptions.project" has been set for @typescript-eslint/parser 如何修复 eslintrc 文件与您的项目配置不匹配? - How to fix eslintrc The file does not match your project config? Node.js中的V8引擎扮演什么角色? - What role plays the V8 engine in Node.js? 为什么 Angular 需要 Node Js? Angular Cli 的作用是什么? - Why Angular need Node Js? and what is role of Angular Cli? Socket.IO在Node.js中扮演什么角色 - What role does Socket.IO have with Node.js 如何在Azure云服务项目中将Node.js Web角色与.NET Web角色一起部署? - How to deploy a Node.js web role along with a .NET web role in azure cloud service project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM