Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An unhandled exception occurred: Cannot read property 'start' of undefined on linting after migrating existing project #372

Closed
KeithGillette opened this issue Mar 13, 2021 · 8 comments · Fixed by #373

Comments

@KeithGillette
Copy link

Migrating an existing @angular@11.2.5 project from tslint@6.1.3 to angular-eslint@2.0.0 following the README.md instructions, I receive the following error with no reference to an offending rule or file:

An unhandled exception occurred: Cannot read property 'start' of undefined
See "/private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/ng-ZvGP5a/angular-errors.log" for further details.

generated .eslintrc.json:

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parserOptions": {
        "project": [
          "tsconfig.json",
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/ng-cli-compat",
        "plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "plugins": [
        "eslint-plugin-unicorn",
        "eslint-plugin-rxjs"
      ],
      "rules": {
        "@angular-eslint/component-max-inline-declarations": "error",
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "tt",
            "style": "kebab-case"
          }
        ],
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "tt",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/no-attribute-decorator": "error",
        "@angular-eslint/no-forward-ref": "error",
        "@angular-eslint/no-input-rename": "off",
        "@angular-eslint/no-lifecycle-call": "error",
        "@angular-eslint/no-pipe-impure": "error",
        "@angular-eslint/pipe-prefix": [
          "error",
          {
            "prefixes": [
              "tt"
            ]
          }
        ],
        "@angular-eslint/prefer-output-readonly": "error",
        "@angular-eslint/use-component-selector": "error",
        "@angular-eslint/use-injectable-provided-in": "error",
        "@typescript-eslint/array-type": [
          "error",
          {
            "default": "array"
          }
        ],
        "@typescript-eslint/consistent-type-definitions": "error",
        "@typescript-eslint/dot-notation": "off",
        "@typescript-eslint/explicit-member-accessibility": [
          "error",
          {
            "accessibility": "explicit",
            "overrides": {
              "accessors": "explicit"
            }
          }
        ],
        "@typescript-eslint/no-extraneous-class": "off",
        "@typescript-eslint/no-for-in-array": "error",
        "@typescript-eslint/no-inferrable-types": "off",
        "@typescript-eslint/no-shadow": [
          "error",
          {
            "hoist": "never"
          }
        ],
        "@typescript-eslint/no-this-alias": "error",
        "@typescript-eslint/no-unused-expressions": [
          "error",
          {
            "allowShortCircuit": true
          }
        ],
        "@typescript-eslint/quotes": [
          "error",
          "single",
          {
            "avoidEscape": true
          }
        ],
        "@typescript-eslint/require-await": "error",
        "@typescript-eslint/unbound-method": "error",
        "arrow-parens": [
          "error",
          "always"
        ],
        "brace-style": [
          "error",
          "1tbs"
        ],
        "id-blacklist": "off",
        "id-match": "off",
        "import/no-default-export": "error",
        "import/no-deprecated": "error",
        "import/no-extraneous-dependencies": "off",
        "max-len": [
          "error",
          {
            "code": 260
          }
        ],
        "no-duplicate-case": "error",
        "no-duplicate-imports": "error",
        "no-extra-bind": "error",
        "no-irregular-whitespace": "error",
        "no-new-func": "error",
        "no-redeclare": "error",
        "no-restricted-syntax": [
          "error",
          "ForInStatement"
        ],
        "no-return-await": "error",
        "no-sequences": "error",
        "no-template-curly-in-string": "error",
        "no-underscore-dangle": "off",
        "no-useless-constructor": "error",
        "prefer-template": "error",
        "rxjs/no-async-subscribe": "error",
        "rxjs/no-create": "error",
        "rxjs/no-ignored-replay-buffer": "error",
        "rxjs/no-index": "error",
        "rxjs/no-internal": "error",
        "rxjs/no-nested-subscribe": "error",
        "rxjs/no-sharereplay": [
          "error",
          {
            "allowConfig": true
          }
        ],
        "rxjs/no-subject-unsubscribe": "error",
        "rxjs/no-unbound-methods": "error",
        "rxjs/no-unsafe-subject-next": "error",
        "rxjs/no-unsafe-takeuntil": "error",
        "space-in-parens": [
          "off",
          "never"
        ],
        "unicorn/filename-case": "error"
      }
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {
        "@angular-eslint/template/conditional-complexity": "error",
        "@angular-eslint/template/cyclomatic-complexity": [
          "error",
          {
            "maxComplexity": 5
          }
        ]
      }
    }
  ]
}

The referenced angular-errors.log:

[error] TypeError: Cannot read property 'start' of undefined
    at Linter._verifyWithoutProcessors (/absolute/path/to/node_modules/eslint/lib/linter/linter.js:1191:54)
    at Linter._verifyWithConfigArray (/absolute/path/to/node_modules/eslint/lib/linter/linter.js:1273:21)
    at Linter.verify (/absolute/path/to/node_modules/eslint/lib/linter/linter.js:1228:25)
    at Linter.verifyAndFix (/absolute/path/to/node_modules/eslint/lib/linter/linter.js:1418:29)
    at verifyText (/absolute/path/to/node_modules/eslint/lib/cli-engine/cli-engine.js:239:48)
    at CLIEngine.executeOnFiles (/absolute/path/to/node_modules/eslint/lib/cli-engine/cli-engine.js:807:28)
    at ESLint.lintFiles (/absolute/path/to/node_modules/eslint/lib/eslint/eslint.js:530:23)
    at Object.lint (/absolute/path/to/node_modules/@angular-eslint/builder/dist/utils/eslint-utils.js:52:25)
    at async run (/absolute/path/to/node_modules/@angular-eslint/builder/dist/index.js:1:1322)

How can I further troubleshoot the error?

@JamesHenry
Copy link
Member

What is the output of:

npx ng version

@KeithGillette
Copy link
Author

Angular CLI: 11.2.3
Node: 12.21.0
OS: darwin x64

Angular: 11.2.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.3
@angular-devkit/build-angular   0.1102.3
@angular-devkit/core            11.2.3
@angular-devkit/schematics      11.2.3
@angular/cdk                    11.2.3
@angular/cli                    11.2.3
@schematics/angular             11.2.3
@schematics/update              0.1102.3
rxjs                            6.6.6
typescript                      4.1.5

@richpauly13
Copy link

I was having the same error. The issue is with "@angular-eslint/template/conditional-complexity": "error". If you comment out that line ng lint works as expected.

@KeithGillette
Copy link
Author

Thanks, @richpauly13! The @angular-eslint/template/conditional-complexity rule does indeed seem to be the source of the error. I see that the migration schematic created both a top-level .eslintrc.json and a project-level .eslint.json that extended that root level configuration, so I had to remove it from both. After doing so, the project in question completed linting successfully, though now I appear to have a lot of rule and/or or code cleanup…

@JamesHenry
Copy link
Member

@KeithGillette please can you share the root tslint and project tslint configs you had prior to converting?

@KeithGillette
Copy link
Author

We used only a root tslint.json for all projects:

{
	"extends": "rxjs-tslint-rules",
	"rulesDirectory": [
		"node_modules/codelyzer"
	],
	"rules": {
		"align": [
			true,
			"statements"
		],
		"array-type": [
			true,
			"array"
		],
		"arrow-parens": true,
		"ban-comma-operator": true,
		"callable-types": true,
		"class-name": true,
		"comment-format": [
			true,
			"check-space"
		],
		"curly": true,
		"deprecation": true,
		"eofline": true,
		"file-name-casing": [
			true,
			"kebab-case"
		],
		"forin": true,
		"import-blacklist": [
			true,
			"lodash",
			"primeng/primeng"
		],
		"import-spacing": true,
		"indent": [
			true,
			"tabs"
		],
		"interface-name": [
			true,
			"always-prefix"
		],
		"interface-over-type-literal": true,
		"invalid-void": true,
		"jsdoc-format": true,
		"label-position": true,
		"max-line-length": [
			true,
			260
		],
		"member-access": [
			true,
			"check-accessor"
		],
		"no-angle-bracket-type-assertion": true,
		"no-arg": true,
		"no-async-without-await": true,
		"no-bitwise": true,
		"no-console": true,
		"no-construct": true,
		"no-debugger": true,
		"no-duplicate-imports": true,
		"no-duplicate-variable": true,
		"no-duplicate-switch-case": true,
		"no-duplicate-super": true,
		"no-dynamic-delete": true,
		"no-eval": true,
		"no-for-in": true,
		"no-for-in-array": true,
		"no-inferred-empty-object-type": true,
		"no-inferrable-types": false,
		"no-internal-module": true,
		"no-irregular-whitespace": true,
		"no-implicit-dependencies": false,
		"no-invalid-template-strings": true,
		"no-misused-new": true,
		"no-object-literal-type-assertion": true,
		"no-promise-as-boolean": true,
		"no-redundant-jsdoc": true,
		"no-unnecessary-class": [
			"allow-empty-class",
			"allow-constructor-only"
		],
		"no-return-await": true,
		"no-shadowed-variable": [
			true,
			{
				"temporalDeadZone": false
			}
		],
		"no-string-literal": false,
		"no-string-throw": true,
		"no-switch-case-fall-through": true,
		"no-tautology-expression": true,
		"no-this-assignment": true,
		"no-trailing-whitespace": true,
		"no-unbound-method": [
			true,
			"ignore-static"
		],
		"no-unnecessary-callback-wrapper": true,
		"no-unsafe-finally": true,
		"no-unused-expression": [
			true,
			"allow-fast-null-checks"
		],
		"no-var-keyword": true,
		"number-literal-format": true,
		"object-literal-sort-keys": false,
		"one-line": [
			true,
			"check-open-brace",
			"check-catch",
			"check-else",
			"check-whitespace"
		],
		"prefer-conditional-expression": true,
		"prefer-const": true,
		"prefer-switch": true,
		"prefer-template": true,
		"prefer-while": true,
		"quotemark": [
			true,
			"single",
			"avoid-escape"
		],
		"radix": true,
		"rxjs-no-async-subscribe": true,
		"rxjs-no-compat": true,
		"rxjs-no-create": true,
		"rxjs-no-exposed-subjects": true,
		"rxjs-no-finnish": true,
		"rxjs-no-ignored-replay-buffer": true,
		"rxjs-no-index": true,
		"rxjs-no-internal": true,
		"rxjs-no-nested-subscribe": true,
		"rxjs-no-sharereplay": {
			"options": [
				{
					"allowConfig": true
				}
			],
			"severity": "error"
		},
		"rxjs-no-subject-unsubscribe": true,
		"rxjs-no-unbound-methods": true,
		"rxjs-no-unsafe-catch": true,
		"rxjs-no-unsafe-first": true,
		"rxjs-no-unsafe-subject-next": true,
		"rxjs-no-unsafe-switchmap": true,
		"rxjs-no-unsafe-takeuntil": true,
		"semicolon": [
			true,
			"always"
		],
		"space-within-parens": false,
		"static-this": true,
		"strict-string-expressions": true,
		"switch-final-break": [
			true,
			"always"
		],
		"triple-equals": [
			true,
			"allow-null-check"
		],
		"typedef": [
			true,
			"call-signature",
			"parameter",
			"arrow-parameter",
			"property-declaration",
			"object-destructuring",
			"array-destructuring"
		],
		"typedef-whitespace": [
			true,
			{
				"call-signature": "nospace",
				"index-signature": "nospace",
				"parameter": "nospace",
				"property-declaration": "nospace",
				"variable-declaration": "nospace"
			}
		],
		"type-literal-delimiter": true,
		"unnecessary-bind": true,
		"unnecessary-constructor": true,
		"unified-signatures": true,
		"variable-name": false,
		"whitespace": [
			true,
			"check-branch",
			"check-decl",
			"check-operator",
			"check-module",
			"check-separator",
			"check-rest-spread",
			"check-type",
			"check-typecast",
			"check-type-operator",
			"check-preblock"
		],
		// Codelyzer rules for Angular: http://codelyzer.com/rules/
		"directive-selector": [
			true,
			"attribute",
			"tt",
			"camelCase"
		],
		"component-selector": [
			true,
			"element",
			"tt",
			"kebab-case"
		],
		"component-class-suffix": true,
		"component-max-inline-declarations": true,
		"directive-class-suffix": true,
		"function-constructor": true,
		"no-attribute-decorator": true,
		"no-conflicting-lifecycle": true,
		"no-default-export": true,
		"no-forward-ref": true,
		"no-input-rename": false,
		"no-lifecycle-call": true,
		"no-host-metadata-property": true,
		"no-inputs-metadata-property": true,
		"no-output-native": true,
		"no-output-on-prefix": true,
		"no-output-rename": true,
		"no-unused-css": true,
		"no-outputs-metadata-property": true,
		"no-pipe-impure": true,
		"prefer-output-readonly": true,
		"pipe-prefix": [
			true,
			"tt"
		],
		"template-banana-in-box": true,
		"template-cyclomatic-complexity": [
			true,
			5
		],
		"template-conditional-complexity": [
			true,
			4
		],
		"use-component-selector": true,
		"use-injectable-provided-in": true,
		"use-lifecycle-interface": true,
		"use-pipe-decorator": true,
		"use-pipe-transform-interface": true
	}
}

@richpauly13
Copy link

richpauly13 commented Mar 13, 2021

@JamesHenry it isn't a migration script issue. I have had @angular-eslint since it was a pre-release. The error started after upgrading 1.2.0 to 2.0.0.

@JamesHenry
Copy link
Member

Thanks for the report on this, it is resolved in 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants