Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Error thrown in 'align' rule #4949

Closed
ocket8888 opened this issue Sep 29, 2020 · 1 comment
Closed

Error thrown in 'align' rule #4949

ocket8888 opened this issue Sep 29, 2020 · 1 comment

Comments

@ocket8888
Copy link

Bug Report

  • TSLint version: 5.17
  • TypeScript version: 3.2
  • Running TSLint via: VSCode

Reproduction using TSLint Playground

Wasn't able to reproduce error - different version in use? See for yourself

TypeScript code being linted

function doSomething(arg: boolean): Array<string> | [0] {
	if (arg) {
		return [0];
	}
	return ["test"];
}
with tslint.json configuration:
{
	"rules": {
		"no-any": true,
		"no-empty-interface": true,
		"no-unnecessary-type-assertion": true,
		"prefer-for-of": true,
		"promise-function-async": true,
		"await-promise": true,
		"curly": true,
		"function-constructor": true,
		"no-arg": true,
		"no-debugger": true,
		"no-duplicate-super": true,
		"no-duplicate-switch-case": true,
		"no-duplicate-variable": true,
		"no-dynamic-delete": true,
		"no-eval": true,
		"no-floating-promises": false,
		"no-inferred-empty-object-type": true,
		"no-invalid-template-strings": true,
		"no-invalid-this": true,
		"no-misused-new": true,
		"no-null-undefined-union": true,
		"no-promise-as-boolean": true,
		"no-return-await": true,
		"no-shadowed-variable": true,
		"no-sparse-arrays": true,
		"no-string-literal": true,
		"no-string-throw": true,
		"no-tautology-expression": true,
		"no-this-assignment": true,
		"no-unbound-method": true,
		"no-unnecessary-class": true,
		"no-unsafe-finally": true,
		"no-unused-expression": true,
		"no-unused-variable": true,
		"no-use-before-declare": true,
		"no-var-keyword": true,
		"prefer-object-spread": true,
		"radix": true,
		"static-this": true,
		"triple-equals": true,
		"unnecessary-constructor": true,
		"use-default-type-parameter": true,
		"use-isnan": true,
		"invalid-void": true,
		"no-require-imports": true,
		"prefer-const": true,
		"prefer-readonly": true,
		"arrow-return-shorthand": true,
		"callable-types": true,
		"class-name": true,
		"completed-docs": [
			true,
			{
				"classes": {
					"visibilities": ["exported"]
				}
			},
			{
				"enums": {
					"visibilities": ["exported"]
				}
			},
			"enum-members",
			{
				"functions": {
					"visibilities": ["exported"],
					"overloads": true
				}
			},
			{
				"interfaces": {
					"visibilities": ["exported"]
				}
			},
			{
				"namespaces": {
					"visibilities": ["exported"]
				}
			},
			{
				"types": {
					"visibilities": ["exported"]
				}
			},
			{
				"variables": {
					"visibilities": ["exported"]
				}
			},
			{
				"methods": {
					"privacies": ["public"],
					"overloads": true
				}
			},
			{
				"properties": {
					"privacies": ["public"]
				}
			}
		],
		"interface-over-type-literal": true,
		"no-angle-bracket-type-assertion": true,
		"no-boolean-literal-compare": true,
		"no-unnecessary-callback-wrapper": true,
		"no-unnecessary-initializer": true,
		"no-unnecessary-qualifier": true,
		"one-variable-per-declaration": true,
		"prefer-template": true,
		"prefer-while": true,
		"type-literal-delimiter": [true, {"singleLine": "always"}],
		"unnecessary-else": true,
		"unnecessary-bind": true,
		"eofline": true,
		"align": [
			true,
			"elements",
			"arguments",
			"parameters",
			"members",
			"statements"
		],
		"import-spacing": true,
		"indent": [
			true,
			"tabs"
		],
		"variable-name": {
			"options": [
				"ban-keywords",
				"check-format",
				"require-const-for-all-caps"
			]
		},
		"jsdoc-format": [true, "check-multiline-start"],
		"linebreak-style": [true, "LF"],
		"new-parens": true,
		"no-trailing-whitespace": true,
		"number-literal-format": true,
		"semicolon": true,
		"whitespace": [
			true,
			"check-decl",
			"check-module",
			"check-separator",
			"check-rest-spread",
			"check-type",
			"check-typecast",
			"check-type-operator"
		],
		"typedef": [
			true,
			"call-signature",
			"parameter",
			"property-declaration",
			"member-variable",
			"object-destructuring",
			"array-destructuring"
		],
		"array-type": false,
		"arrow-parens": false,
		"deprecation": {
			"severity": "warning"
		},
		"component-class-suffix": true,
		"contextual-lifecycle": true,
		"directive-class-suffix": true,
		"directive-selector": [
			true,
			"attribute",
			"",
			"camelCase"
		],
		"component-selector": [
			true,
			"element",
			"",
			"kebab-case"
		],
		"import-blacklist": [
			true,
			"rxjs/Rx"
		],
		"interface-name": false,
		"max-classes-per-file": false,
		"max-line-length": [
			true,
			140
		],
		"member-access": true,
		"member-ordering": [
			true,
			{
				"order": [
					"static-field",
					"instance-field",
					"static-method",
					"instance-method"
				]
			}
		],
		"no-consecutive-blank-lines": false,
		"no-console": [
			true,
			"debug",
			"info",
			"time",
			"timeEnd",
			"trace"
		],
		"no-empty": true,
		"no-inferrable-types": [
			true,
			"ignore-params"
		],
		"no-non-null-assertion": true,
		"no-redundant-jsdoc": true,
		"no-switch-case-fall-through": true,
		"no-var-requires": false,
		"object-literal-key-quotes": [
			true,
			"as-needed"
		],
		"object-literal-sort-keys": true,
		"ordered-imports": false,
		"quotemark": [
			true,
			"double"
		],
		"trailing-comma": false,
		"no-conflicting-lifecycle": true,
		"no-host-metadata-property": true,
		"no-input-rename": true,
		"no-inputs-metadata-property": true,
		"no-output-native": true,
		"no-output-on-prefix": true,
		"no-output-rename": true,
		"no-outputs-metadata-property": true,
		"template-banana-in-box": true,
		"template-no-negated-async": true,
		"use-lifecycle-interface": true,
		"use-pipe-transform-interface": true
	},
	"rulesDirectory": [
		"codelyzer"
	]
}

Actual behavior

Rule throws an error:

The 'align' rule threw an error in '/path/to/my/project/src/server/test.ts':
TypeError: Cannot read property 'length' of undefined
    at AlignWalker.checkAlignment (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:149:19)
    at cb (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:118:35)
    at visitNodes (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:26836:30)
    at Object.forEachChild (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:26975:24)
    at cb (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:144:23)
    at visitNode (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:26827:24)
    at Object.forEachChild (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:26955:21)
    at cb (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:144:23)
    at visitNodes (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:26836:30)
    at Object.forEachChild (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:27074:24)
    at cb (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:144:23)
    at AlignWalker.walk (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:146:16)
    at Rule.AbstractRule.applyWithWalker (/path/to/my/project/node_modules/tslint/lib/language/rule/abstractRule.js:31:16)
    at Rule.apply (/path/to/my/project/node_modules/tslint/lib/rules/alignRule.js:34:21)
    at Linter.applyRule (/path/to/my/project/node_modules/tslint/lib/linter.js:214:29)
    at /path/to/my/project/node_modules/tslint/lib/linter.js:155:85
    at Object.flatMap (/path/to/my/project/node_modules/tslint/lib/utils.js:160:29)
    at Linter.getAllFailures (/path/to/my/project/node_modules/tslint/lib/linter.js:155:32)
    at Linter.lint (/path/to/my/project/node_modules/tslint/lib/linter.js:110:33)
    at TsLintRunner.doRun (/home/ocket8888/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3/node_modules/typescript-tslint-plugin/out/runner/index.js:227:24)
    at TsLintRunner.runTsLint (/home/ocket8888/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3/node_modules/typescript-tslint-plugin/out/runner/index.js:80:21)
    at TSLintPlugin.getSemanticDiagnostics (/home/ocket8888/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3/node_modules/typescript-tslint-plugin/out/plugin.js:108:38)
    at Proxy.intercept.getSemanticDiagnostics (/home/ocket8888/.vscode/extensions/ms-vscode.vscode-typescript-tslint-plugin-1.2.3/node_modules/typescript-tslint-plugin/out/plugin.js:73:25)
    at IOSession.Session.semanticCheck (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:153659:52)
    at /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:153715:31
    at MultistepOperation.executeAction (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:152692:25)
    at /usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:152673:100
    at IOSession.Session.executeWithRequestId (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:154944:28)
    at Object.executeWithRequestId (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:153428:87)
    at Immediate._onImmediate (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:152673:41)
    at processImmediate (internal/timers.js:439:21)

Expected behavior

The rule should pass or fail, not throw.

@adidahiya
Copy link
Contributor

Hi @ocket8888, TSLint is deprecated and no longer accepting bug reports. Your best bet is https://typescript-eslint.io. See #4534.

@palantir palantir locked as resolved and limited conversation to collaborators Sep 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants