Repository: palantir/tslint

Issue #2862: Running --fix on .ts Files Creates Numerous Syntax Errors.
Created: 2017-06-01T23:31:42Z
Bug Report

TSLint version: 5.4.0 (also tried 5.4.2)
TypeScript version:  2.3.2
Running TSLint via: CLI

TypeScript code being linted
tslint -p "./tsconfig.json" --fix --type-check -c tslint.json
with tslint.json configuration:
{
  "extends": [
    "tslint:recommended"
  ],
  "rules": {
    "quotemark": [true,
      "single"
    ],
    "align": [true,
      "statements",
      "arguments"
    ],
    "radix": false,
    "space-before-function-paren":false,
    "array-type": [
      true,"array"
    ]
  }
}
Actual behavior
Breaks code by inserting commas and spaces where there shouldn't be any.
File before "fix":
import * as winston from 'winston';

const DefaultOptions = {
    transports: [
    new winston.transports.Console({
        json: true,
        colorize: true,
        stringify:true
    })],
    rewriters:[
        (level,message,meta)=>{
            if(meta)
            {
                meta.timeStamp = new Date();
            }
            return meta;            
        }
    ]

};

export const Logger = new winston.Logger(DefaultOptions);

File after "fix" (notice the split-lambda, spaces between "if", commas between "export" and "const"...bizarre output; this code does not compile successfully:
import * as winston from 'winston';

//Modify winston here.
const DefaultOptions = {
    transports: [
    new winston.transports.Console({
        json: true,
        colorize: true,
        stringify: true,
    })],
    rewriters :[
        (level ,message ,meta )= >{
            i f(meta)
            {
                meta.timeStamp = new Date();
            }
            return meta;
        }
    ]

};

,export, const Logger = new winston.Logger(DefaultOptions);

Expected behavior
Expected to "fix" whatever fixable rules can be fixed with acceptable anomalies. Running "fix" completely rendered 59 files broken and unable to compile because of syntax errors introduced. I realize any "fix" operation is risky which is why I did a commit right before but in any case this seems like a major issue. Even "simple" files like the one above don't appear to be parsed and fixed correctly. Is this a problem on my side? Has anybody else run into this?
P.S. Also worth noting is this codebase compiles perfectly using tsc and/or gulp-typescript and/or ts-loader before the "fixes" are applied.

Duplicate issue #2940: Side effect fix "ordered imports" + "quotemark" (single to double)
Created: 2017-06-21T09:04:31Z
Bug Report

TSLint version: 5.4.3
TypeScript version: 2.3.4
Running TSLint via:  Angular-CLI

TypeScript code being linted
Polyfills from Angular Polyfills
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
with tslint.json configuration:
{
   "rulesDirectory": [
       "node_modules/codelyzer"
   ],
   "rules": {
       "directive-selector": [true, "attribute", "sg", "camelCase"],
       "component-selector": [true, "element", "sg", "kebab-case"],
       "use-input-property-decorator": true,
       "use-output-property-decorator": true,
       "use-host-property-decorator": true,
       "no-attribute-parameter-decorator": true,
       "no-input-rename": true,
       "no-output-rename": true,
       "no-forward-ref": true,
       "use-life-cycle-interface": true,
       "use-pipe-transform-interface": true,
       "pipe-naming": [true, "camelCase", "sg"],
       "component-class-suffix": true,
       "directive-class-suffix": true,
       "templates-use-public": true,
       "invoke-injectable": true,
       "template-to-ng-template": true,

       "adjacent-overload-signatures": true,
       "align": [true, "arguments", "elements", "members", "parameters", "statements"],
       "class-name": true,
       "comment-format": [
           true,
           "check-space"
       ],
       "curly": true,
       "encoding": true,
       "forin": true,
       "indent": [
           true,
           "spaces"
       ],
       "label-position": true,
       "max-line-length": [
           true,
           150
       ],
       "max-file-line-count": [true, 1000],
       "member-access": false,
       "member-ordering": [
           true,
           {"order": "fields-first"}
       ],
       "no-angle-bracket-type-assertion": true,
       "no-arg": true,
       "no-bitwise": true,
       "no-conditional-assignment": true,
       "no-consecutive-blank-lines": true,
       "no-construct": true,
       "no-debugger": true,
       "no-duplicate-variable": true,
       "no-duplicate-super": true,
       "no-empty": false,
       "no-eval": true,
       "no-inferrable-types": true,
       "no-internal-module": true,
       "no-shadowed-variable": true,
       "no-string-literal": false,
       "no-switch-case-fall-through": true,
       "no-trailing-whitespace": true,
       "no-unused-expression": true,
       "no-use-before-declare": true,
       "no-var-keyword": true,
       "no-var-requires": true,
       "object-literal-key-quotes": [true, "as-needed"],
          wurden (Vorbeugen vor Merge-Konflikten)*/
       "object-literal-sort-keys": false,
       "one-line": [
           true,
           "check-open-brace",
           "check-catch",
           "check-else",
           "check-whitespace"
       ],
       "ordered-imports": true,
       "prefer-conditional-expression": true,
       "prefer-for-of": true,
       "prefer-switch": true,
       "prefer-template": true,
       "quotemark": [true, "double"],
       "radix": true,
       "semicolon": [true, "always"],
       "trailing-comma": [
           true, {"multiline": "never", "singleline": "never"}
       ],
       "triple-equals": [
           true,
           "allow-null-check"
       ],
       "typedef-whitespace": [true, {
           "call-signature": "nospace",
           "index-signature": "nospace",
           "parameter": "nospace",
           "property-declaration": "nospace",
           "variable-declaration": "nospace"
       }],
       "variable-name": [
           true,
           "ban-keywords"
       ],
       "whitespace": [
           true,
           "check-branch",
           "check-decl",
           "check-operator",
           "check-module",
           "check-separator",
           "check-type",
           "check-typecast",
           "check-preblock"
       ]
   }
}

Actual behavior
import "core-js/es6/symbol"
import '"core-js/es6/object"import 'co"core-js/es6/function"import 'co"core-js/es6/parse-int" 'core-js/"core-js/es6/parse-float"js/es6/num"core-js/es6/number"js/es6/obj"core-js/es6/math"e-js/es6/p"core-js/es6/string" 'core-js/"core-js/es6/date"mport 'cor"core-js/es6/array"import 'co"core-js/es6/regexp"ort 'core-"core-js/es6/map"import 'co"core-js/es6/weak-map"port 'core"core-js/es6/set";

Expected behavior
import "core-js/es6/array";
import "core-js/es6/date";
import "core-js/es6/function";
import "core-js/es6/map";
import "core-js/es6/math";
import "core-js/es6/number";
import "core-js/es6/object";
import "core-js/es6/parse-float";
import "core-js/es6/parse-int";
import "core-js/es6/regexp";
import "core-js/es6/set";
import "core-js/es6/string";
import "core-js/es6/symbol";
import "core-js/es6/weak-map";

Closing comment (2017-06-21T10:02:29Z): Looks like a duplicate of #2862 and should be fixed by #2864