skip to Main Content

I have this directory that was part of the template, and I want to exclude it on linting. I already excluded it on tsconfig and eslint. runnig eslint it works fine, but when doing ng build it will include the directory on linting and will produce errors.

The subject directory is src/fuse.

I already added this to my config.

eslintignore

build/
dist/
www/
src/@fuse/

eslintrc

    "ignorePatterns": [
        "src/@fuse/**/*",
        "./src/@fuse/**/*",
        "src/@fuse",
        "./src/@fuse"
    ],

tsconfig

    "exclude": ["./src/@fuse", "src/@fuse"]

When doing ng build I will get this. It still apply the linting even it was excluded
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    While I'm fiddling with the config, and found out that angular.json using tsconfig.app.json and the tsconfig.app.json is extending the tsconfig.json, I proceed to edit the tsconfig.app.json to override some configs. This way it still gives me the full strictness while editing and loosen a bit when building.

    Here is a part of the angular.json

                    "build": {
                        "builder": "@angular-devkit/build-angular:browser",
                        "options": {
                            "outputPath": "dist/fuse",
                            "index": "src/index.html",
                            "main": "src/main.ts",
                            "polyfills": ["zone.js"],
                            "tsConfig": "tsconfig.app.json", // the tsconfig is here
                            "inlineStyleLanguage": "scss",
    
    

    While this is my tsconfig.json

    {
        "compileOnSave": false,
        "compilerOptions": {
            "allowSyntheticDefaultImports": true,
            "allowUnreachableCode": false,
            "allowUnusedLabels": false,
            "baseUrl": "./src",
            "declaration": false,
            "downlevelIteration": true,
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "forceConsistentCasingInFileNames": true,
            "importHelpers": true,
            "lib": ["ES2022", "dom"],
            "module": "ES2022",
            "moduleResolution": "node",
            "noFallthroughCasesInSwitch": true,
            "noImplicitAny": true,
            "noImplicitOverride": true,
            "noImplicitReturns": true,
            "noPropertyAccessFromIndexSignature": true,
            "noUncheckedIndexedAccess": true,
            "noUnusedLocals": true,
            "noUnusedParameters": true,
            "outDir": "./dist/out-tsc",
            "pretty": true,
            "removeComments": true,
            "strict": true,
            "sourceMap": true,
            "target": "ES2022",
            "useDefineForClassFields": false
        },
        "angularCompilerOptions": {
            "enableI18nLegacyMessageIdFormat": false,
            "strictInjectionParameters": true,
            "strictInputAccessModifiers": true,
            "strictTemplates": true
        }
    }
    

    And the tsconfig.app.json that used by angular.json and extnds by tsconfig.json

    {
        "extends": "./tsconfig.json",
        "compilerOptions": {
            // override config between this block
            "noImplicitReturns": false,
            "noPropertyAccessFromIndexSignature": false,
            "noUnusedLocals": false,
            "noUnusedParameters": false,
            "strictNullChecks": false,
            // override config between this block
            "outDir": "./out-tsc/app",
            "types": []
        },
        "files": ["src/main.ts"],
        "include": ["src/**/*.d.ts"]
    }
    
    

  2. I think they are not lint errors, lint errors show up only when you do ng lint, these are build errors due to the configuration of tsconfig.json.

    /* To learn more about this file see: https://angular.io/config/tsconfig. */
    {
      ...
      "compilerOptions": {
        ...
        "strict": false, 
        "noImplicitOverride": true,
        "noPropertyAccessFromIndexSignature": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "esModuleInterop": true,
        ...
      },
      ...
    }
    

    Try toggling these properties and check if it works. Else just fix these error, since its necessary for the build to run!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search