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

Autofix - Negative string numbers being used as an object key are having the quotes removed #2260

Closed
nascosto opened this issue Feb 27, 2017 · 0 comments · Fixed by #2272
Closed

Comments

@nascosto
Copy link

nascosto commented Feb 27, 2017

Bug Report

  • TSLint version:4.5.0
  • TypeScript version:2.1.1
  • Running TSLint via: Node.js API

TypeScript code being linted

const testVar = {
		'-1': 'test',
		0: 'test1',
		1: 'test2';
	};

with tslint.json configuration:

{
	"formatter": "verbose",
	"rules": {
		"adjacent-overload-signatures": true,
		"member-access": true,
		"member-ordering": [true, { "order": "fields-first" }],
		"no-any": false,
		"no-empty-interface": true,
		"no-inferrable-types": [false, "ignore-params"],
		"no-internal-module": true,
		"no-magic-numbers": false,
		"no-namespace": false,
		"no-reference": true,
		"no-var-requires": true,
		"only-arrow-functions": [false, "allow-declarations"],
		"prefer-for-of": true,
		"promise-function-async": false,
		"typedef": [false, "call-signature", "parameter", "member-variable-declaration"],
		"typedef-whitespace": [false],
		"unified-signatures": true,
		"await-promise": false,
		"ban": [false],
		"curly": true,
		"forin": true,
		"import-blacklist": [false],
		"label-position": true,
		"no-arg": true,
		"no-bitwise": true,
		"no-conditional-assignment": false,
		"no-console": [true, "log"],
		"no-construct": true,
		"no-debugger": true,
		"no-duplicate-variable": true,
		"no-empty": true,
		"no-eval": true,
		"no-floating-promises": false,
		"no-for-in-array": false,
		"no-inferred-empty-object-type": false,
		"no-invalid-this": [false],
		"no-misused-new": true,
		"no-null-keyword": false,
		"no-shadowed-variable": false,
		"no-string-literal": false,
		"no-string-throw": true,
		"no-switch-case-fall-through": false,
		"no-unbound-method": false,
		"no-unsafe-any": false,
		"no-unsafe-finally": true,
		"no-unused-expression": true,
		"no-unused-new": true,
		"no-unused-variable": [true],
		"no-use-before-declare": true,
		"no-var-keyword": true,
		"no-void-expression": false,
		"radix": false,
		"restrict-plus-operands": false,
		"strict-boolean-expressions": [false],
		"strict-type-predicates": false,
		"switch-default": false,
		"triple-equals": true,
		"typeof-compare": true,
		"use-isnan": true,
		"cyclomatic-complexity": [false, 10],
		"eofline": true,
		"indent": [true, "tabs"],
		"linebreak-style": [false, "LF"],
		"max-classes-per-file": [false, 5],
		"max-file-line-count": [false, 300],
		"max-line-length": [false, 240],
		"no-default-export": false,
		"no-mergeable-namespace": true,
		"no-require-imports": true,
		"no-trailing-whitespace": true,
		"object-literal-sort-keys": false,
		"prefer-const": false,
		"trailing-comma": [true, { "multiline": "never", "singleline": "never" }],
		"align": [false, "parameters", "arguments", "statements"],
		"array-type": [true, "array"],
		"arrow-parens": true,
		"arrow-return-shorthand": [true],
		"callable-types": true,
		"class-name": true,
		"comment-format": [true, "check-space"],
		"completed-docs": [false],
		"file-header": [false],
		"import-spacing": true,
		"interface-name": [true, "always-prefix"],
		"interface-over-type-literal": false,
		"jsdoc-format": false,
		"new-parens": true,
		"no-angle-bracket-type-assertion": false,
		"no-boolean-literal-compare": false,
		"no-consecutive-blank-lines": [true],
		"no-parameter-properties": false,
		"no-unnecessary-initializer": true,
		"no-unnecessary-qualifier": false,
		"object-literal-key-quotes": [true, "as-needed"],
		"object-literal-shorthand": false,
		"one-line": [true, "check-catch", "check-finally", "check-else"],
		"one-variable-per-declaration": [false],
		"ordered-imports": [true, { "named-imports-order": "lowercase-first" }],
		"prefer-function-over-method": false,
		"prefer-method-signature": false,
		"quotemark": [true, "single", "avoid-escape"],
		"semicolon": [true, "always"],
		"space-before-function-paren": [true, "never"],
		"variable-name": [true, "ban-keywords"],
		"whitespace": [true, "check-branch", "check-operator"]
	}
}

Actual behavior

It is removing the quotes and throwing in several semicolons:
const testVar = {
- 1:; 'test',
0;: 'test1',
1;: 'test2';
};

Expected behavior

const testVar = {
'-1': 'test',
0: 'test1',
1: 'test2';
};

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