angular-architects / nx-ddd-plugin

Nx plugin for structuring a monorepo with domains and layers
313 stars 56 forks source link

[Bug] Updated .eslintrc.json is not valid #31

Closed HymanZHAN closed 2 years ago

HymanZHAN commented 3 years ago

TL;DR;

In nx project configured with eslint, the generated eslint config should be put inside the top-level overrides array instead of overwriting the whole .eslintrc.json file

More details:

{
  "root": true,
  "ignorePatterns": ["**/*"],
  "plugins": ["@nrwl/nx"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {
        "@nrwl/nx/enforce-module-boundaries": [
          "error",
          {
            "enforceBuildableLibDependency": true,
            "allow": [],
            "depConstraints": [
              {
                "sourceTag": "type:app",
                "onlyDependOnLibsWithTags": [
                  "type:api",
                  "type:feature",
                  "type:ui",
                  "type:domain-logic",
                  "type:util"
                ]
              },
              {
                "sourceTag": "type:api",
                "onlyDependOnLibsWithTags": [
                  "type:ui",
                  "type:domain-logic",
                  "type:util"
                ]
              },
              {
                "sourceTag": "type:feature",
                "onlyDependOnLibsWithTags": [
                  "type:ui",
                  "type:domain-logic",
                  "type:util"
                ]
              },
              {
                "sourceTag": "type:ui",
                "onlyDependOnLibsWithTags": ["type:domain-logic", "type:util"]
              },
              {
                "sourceTag": "type:domain-logic",
                "onlyDependOnLibsWithTags": ["type:util"]
              },
              {
                "sourceTag": "domain:shared",
                "onlyDependOnLibsWithTags": ["domain:shared"]
              },
              {
                "sourceTag": "domain:blog",
                "onlyDependOnLibsWithTags": ["domain:blog", "domain:shared"]
              }
            ]
          }
        ]
      }
    },
    {
      "files": ["*.ts", "*.tsx"],
      "extends": ["plugin:@nrwl/nx/typescript"],
      "parserOptions": { "project": "./tsconfig.*?.json" },
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "extends": ["plugin:@nrwl/nx/javascript"],
      "rules": {}
    }
  ]
}

Otherwise, nx lint will fail with error:

An unhandled exception occurred: ESLint configuration in apps/desci/.eslintrc.json » ../../.eslintrc.json is invalid:
        - Unexpected top-level property "files".

Referenced from: /home/xzhan/Development/Projects/desci_online/frontend/apps/desci/.eslintrc.json
See "/tmp/ng-taMiLt/angular-errors.log" for further details.
benpsnyder commented 3 years ago

Duplicate (sort of) of #41