简体   繁体   中英

Eslint - configured rules location

I am trying to locate where the default eslint rules are for an out of the box configured Nx workspace.

I see some plugins being used in the eslintrc file at the root of my project:

{
  "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 . 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.

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 . 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" . This.ts file imports definitions from modules in the subfolders "config" and "rules" and maps them to exports. So the sources for the locations contained in your.eslinrc file are like this:

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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