简体   繁体   English

Eslint - 配置规则位置

[英]Eslint - configured rules location

I am trying to locate where the default eslint rules are for an out of the box configured Nx workspace.我正在尝试为开箱即用的 Nx 工作区找到默认 eslint 规则的位置。

I see some plugins being used in the eslintrc file at the root of my project:我看到项目根目录的 eslintrc 文件中使用了一些插件:

{
  "root": true,
  "ignorePatterns": ["**/*"],
  "plugins": ["@nrwl/nx"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {
        "@nrwl/nx/enforce-module-boundaries": [
          "error",
          {
            "enforceBuildableLibDependency": true,
            "allow": [],
            "depConstraints": [
              {
                "sourceTag": "*",
                "onlyDependOnLibsWithTags": ["*"]
              }
            ]
          }
        ]
      }
    },
    {
      "files": ["*.ts", "*.tsx"],
      "extends": ["plugin:@nrwl/nx/typescript"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "extends": ["plugin:@nrwl/nx/javascript"],
      "rules": {}
    }
  ]
}

Can someone tell me where I should be able to see the full list of rules enabled please?有人可以告诉我在哪里可以看到启用的完整规则列表吗?

The rules come from the npm package @nrwl/eslint-plugin-nx .规则来自 npm package @nrwl/eslint-plugin-nx This is the name of the package included in the list of plugins without "eslint-plugin-", which is prepended automatically by ESLint when resolving the plugin location.这是包含在没有“eslint-plugin-”的plugins列表中的 package 的名称,它在解析插件位置时由 ESLint 自动添加。

Following the link to the monorepo https://github.com/nrwl/nx , and digging into the "packages" folder we discover the source of eslint-plugin-nx .按照 monorepo https://github.com/nrwl/nx的链接,并深入“packages”文件夹,我们会发现eslint-plugin-nx的来源。 Now, looking into package.json we see that the main module points to "./src/index.js" , which is autogenerated by Typescript from "./src/index.ts" .现在,查看package.json我们看到main模块指向"./src/index.js" "./src/index.ts"它是由 Typescript. This.ts file imports definitions from modules in the subfolders "config" and "rules" and maps them to exports. This.ts 文件从子文件夹“config”和“rules”中的模块导入定义并将它们映射到导出。 So the sources for the locations contained in your.eslinrc file are like this:因此,您的 .eslinrc 文件中包含的位置的来源如下:

ESLint works by merging the rule definitions in the extends sections ( .js , .ts ) and then applying the rules definitions ( .js , .ts ) of the configurations, and finally the rule @nrwl/nx/enforce-module-boundaries as defined in your.eslintrc file (Note also the overrides for .tsx ). ESLint 通过合并extends部分( .js.ts )中的规则定义,然后应用配置的rules定义( .js.ts ),最后将规则@nrwl/nx/enforce-module-boundaries为在 your.eslintrc 文件中定义(还要注意.tsxoverrides )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM