angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

ng lint --typeCheck: Program must be type checked before linting #10266

Closed feco93 closed 6 years ago

feco93 commented 6 years ago

Versions

Angular CLI: 1.7.4
Node: 9.2.0
OS: win32 x64
Angular: 5.1.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.3
@angular/cli: 1.7.4
@angular/material: 5.0.3
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack-bundle-analyzer: 2.9.1
webpack: 3.11.0

Repro steps

run this command: ng lint --typeCheck

Observed behavior

Program must be type checked before linting
Error: Program must be type checked before linting
    at Linter.getSourceFile (C:\Projects\Web.BI\DyntellBI\node_modules\tslint\lib\linter.js:200:23)
    at Linter.lint (C:\Projects\Web.BI\DyntellBI\node_modules\tslint\lib\linter.js:72:31)
    at lintConfigs.map (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\tasks\lint.js:70:24)
    at Array.map (<anonymous>)
    at Class.run (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\tasks\lint.js:39:14)
    at Class.run (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\commands\lint.js:46:25)
    at resolve (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\ember-cli\lib\models\command.js:261:20)
    at new Promise (<anonymous>)
    at Class.validateAndRun (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\ember-cli\lib\models\command.js:240:12)
    at Promise.resolve.then.then (C:\Projects\Web.BI\DyntellBI\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:140:24)

Desired behavior

Run ng lint in normal way.

Mention any other details that might be useful (optional)

tslint.json:

{
    "rulesDirectory": [
        "node_modules/codelyzer"
    ],
    "extends": [
        "rxjs-tslint-rules"
    ],
    "rules": {
        "rxjs-add": {
            "options": [
                {
                    "allowElsewhere": false,
                    "allowUnused": false,
                    "file": "./src/app/rxjs-imports.ts"
                }
            ],
            "severity": "error"
        },
        "arrow-return-shorthand": true,
        "callable-types": true,
        "class-name": true,
        "comment-format": [
            true,
            "check-space"
        ],
        "curly": true,
        "eofline": true,
        "forin": true,
        "import-blacklist": [
            true,
            "rxjs"
        ],
        "import-spacing": true,
        "indent": [
            true,
            "spaces"
        ],
        "interface-over-type-literal": true,
        "label-position": true,
        "max-line-length": [
            true,
            163
        ],
        "member-access": false,
        "member-ordering": [
            true,
            {
                "order": [
                    "static-field",
                    "instance-field",
                    "constructor",
                    "instance-method"
                ]
            }
        ],
        "no-arg": true,
        "no-bitwise": false,
        "no-console": [
            true,
            "debug",
            "info",
            "time",
            "timeEnd",
            "trace"
        ],
        "no-construct": true,
        "no-debugger": true,
        "no-duplicate-super": true,
        "no-empty": false,
        "no-empty-interface": true,
        "no-eval": true,
        "no-inferrable-types": [
            true,
            "ignore-params"
        ],
        "no-misused-new": true,
        "no-non-null-assertion": true,
        "no-shadowed-variable": true,
        "no-string-literal": false,
        "no-string-throw": true,
        "no-switch-case-fall-through": true,
        "no-trailing-whitespace": true,
        "no-unnecessary-initializer": true,
        "no-unused-expression": true,
        "no-use-before-declare": true,
        "no-var-keyword": true,
        "object-literal-sort-keys": false,
        "one-line": [
            true,
            "check-open-brace",
            "check-catch",
            "check-else",
            "check-whitespace"
        ],
        "prefer-const": true,
        "quotemark": [
            true,
            "single"
        ],
        "radix": true,
        "semicolon": true,
        "triple-equals": [
            true,
            "allow-null-check"
        ],
        "typedef-whitespace": [
            true,
            {
                "call-signature": "nospace",
                "index-signature": "nospace",
                "parameter": "nospace",
                "property-declaration": "nospace",
                "variable-declaration": "nospace"
            }
        ],
        "typeof-compare": true,
        "unified-signatures": true,
        "variable-name": false,
        "whitespace": [
            true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-separator",
            "check-type"
        ],
        "directive-selector": [
            "element",
            "app",
            "camelCase"
        ],
        "component-selector": [
            true,
            "element",
            "app",
            "kebab-case"
        ],
        "angular-whitespace": [
            true,
            "check-semicolon"
        ],
        "use-input-property-decorator": true,
        "use-output-property-decorator": true,
        "use-host-property-decorator": true,
        "no-attribute-parameter-decorator": true,
        "no-output-rename": true,
        "use-life-cycle-interface": true,
        "use-pipe-transform-interface": true
    }
}
Splaktar commented 6 years ago

Have you tried ng lint --type-check?

feco93 commented 6 years ago

Unfortunately, it doesn't solve the problem.

But after updating tslint (5.10.0 version) depedency it works without this parameter.

The previous (problematic) tslint version: "5.3.2".

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.