NX workspace: configure template of .eslintrc.json when generating new lib

Viewed 781

I switched my NX workspace from TSLint to ESLint and most parts are working fine. When I create a new lib I get an .eslintrc.json file within the lib folder with a very minimal configuration like this:

// .eslintrc.json file in generated lib

{ "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "rules": {} }

I don't want to have this minimal file and need to set up some more details and rules in this generated file, so my question is where this "template" configuration is coming from and where I can adjust this file to have more details in it after generation?

For my NX workspace I generate new libs via the command:

nx g @nrwl/angular:lib <libname>

My .eslintrc.json file in the root folder of the project looks like this:

// .eslintrc.json in project root

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "project": [
            "tsconfig.base.json"
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/recommended",
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "cgm",
            "style": "kebab-case"
          }
        ],
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "cgm",
            "style": "camelCase"
          }
        ],
        "@typescript-eslint/consistent-type-definitions": "error",
        "@typescript-eslint/dot-notation": "off",
        "@typescript-eslint/explicit-member-accessibility": [
          "off",
          {
            "accessibility": "explicit"
          }
        ],
        "id-blacklist": "off",
        "id-match": "off",
        "no-underscore-dangle": "off",
        "lines-between-class-members": ["error", "always"],
        "object-curly-newline": "off",
        "max-len": ["error", { "code": 140 }],
        "import/prefer-default-export": "off",
        "linebreak-style": ["error", "windows"],
        "indent": ["error", 4],
        "no-console": "error"
      }
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {}
    }
  ]
}

My schematics part of the workspace.json file looks like this:

    "schematics": {
    "@nrwl/angular": {
        "application": {
            "linter": "eslint"
        },
        "library": {
            "linter": "eslint"
        },
        "storybook-configuration": {
            "linter": "eslint"
        },
        "style": "scss"
    },
    "@nrwl/angular:application": {
        "unitTestRunner": "jest",
        "e2eTestRunner": "cypress"
    },
    "@nrwl/angular:library": {
        "unitTestRunner": "jest",
        "style": "scss"
    },
    "@nrwl/angular:component": {
        "style": "scss"
    }
},
0 Answers
Related