Tslint: --fix breaks this file

Created on 13 Oct 2018  ยท  6Comments  ยท  Source: palantir/tslint

Unsure of what the issue is so feel free to change the title.

I tried to simplify this example as much as possible but anything I remove makes it work properly.

yarn tslint --fix testFile.tsx

Bug Report

  • __TSLint version__: 5.9.2 & 5.11.0
  • __TypeScript version__: 2.9.2
  • __Running TSLint via__: CLI

TypeScript code being linted

import styled from 'styled-components';
import ModalImport from 'components/Modal';

import './MakerApp.scss';

import { Serialized } from 'services';
import { AppLoaded } from '@maker/events';

import { IBrand, IStringStringMap, IUser } from 'Types';

import Authorize from './Authorize';
import * as MakersPath from '@maker/paths';
import Brand from './Brand';

import Report from './Report';
import Api from '../Api';

const Modal: any = ModalImport;

interface IMakerAppPropTypes {}

const Scrollable = styled.div``;

class SomeClass {
  stringMap: IStringStringMap;
  scrollable = Scrollable;

  model = Modal;
  brand: IBrand;
  iUser: IUser;
  rsatyun: IMakerAppPropTypes;

  handler = () => {
    Serialized.updateEmployeeState();
    AppLoaded.publish();
    Authorize.bind(this);
    Brand.bind(this);
    Api.brandLead();
    MakersPath.home();
    Report.toLocaleString();
  };
}

with tslint.json configuration:

{
  "extends": ["tslint-react", "tslint-config-prettier"],
  "rules": {
    "ban": false,
    "class-name": false,
    "comment-format": [true, "check-space"],
    "curly": true,
    "eofline": false,
    "forin": true,
    "indent": [true, "spaces"],
    "interface-name": [true, "always-prefix"],
    "jsdoc-format": true,
    "jsx-no-lambda": false,
    "jsx-no-multiline-js": false,
    "jsx-boolean-value": [true, "never"],
    "label-position": true,
    "member-ordering": false,
    "no-any": false,
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [
      true,
      "log",
      "error",
      "debug",
      "info",
      "time",
      "timeEnd",
      "trace"
    ],
    "no-consecutive-blank-lines": true,
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-duplicate-imports": true,
    "no-empty": false,
    "no-eval": true,
    "no-return-await": true,
    "no-shadowed-variable": true,
    "no-string-literal": true,
    "no-switch-case-fall-through": true,
    "no-trailing-whitespace": false,
    "no-unused-variable": true,
    "no-unused-expression": true,
    "object-literal-shorthand": true,
    "one-line": [
      true,
      "check-catch",
      "check-else",
      "check-open-brace",
      "check-whitespace"
    ],
    "ordered-imports": [
      true,
      {
        "grouped-imports": true
      }
    ],
    "prefer-template": true,
    "radix": true,
    "switch-default": true,

    "trailing-comma": [false],

    "triple-equals": [true, "allow-null-check"],
    "typedef": [true, "parameter", "property-declaration"],
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      }
    ],
    "variable-name": [
      true,
      "ban-keywords",
      "check-format",
      "allow-leading-underscore",
      "allow-pascal-case",
      "allow-snake-case"
    ],
    "whitespace": [
      true,
      "check-branch",
      "check-decl",
      "check-module",
      "check-operator",
      "check-separator",
      "check-type",
      "check-typecast"
    ]
  },
  "jsRules": {
    "no-unused-expression": true
  }
}

Actual behavior

Deletes part of the code

Expected behavior

noop formating

Hard Bug ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

๐Ÿ’€ _It's time!_ ๐Ÿ’€

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. โ˜ ๏ธ
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. โœ…

๐Ÿ‘‹ It was a pleasure open sourcing with you!

All 6 comments

Not sure how abstract syntax tree works, but the mixing of colons and equals for value assignment in the creation of SomeClass are probably the problem. That's super invalid code, to the point at which it's probably invisible to the AST. Did the compiler catch that?

It is definitely valid typescript.

In typescript brand: IBrand; says that the this.brand is of type IBrand but does not define it.

First like of this class in the docs: https://www.typescriptlang.org/docs/handbook/classes.html

Yes, this is a bug. These lines are deleted:

const Modal: any = ModalImport;

interface IMakerAppPropTypes {}

const Scrollable = styled.div``;

...and replaced with:

le = styled.div``;

Unclear why. Related: #2556.

I had a very similar experience with a function that returned a promise:
return new Promise(....
was replaced with
turn; new Promise(...

๐Ÿ’€ _It's time!_ ๐Ÿ’€

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. โ˜ ๏ธ
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. โœ…

๐Ÿ‘‹ It was a pleasure open sourcing with you!

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bertolo1988 picture bertolo1988  ยท  20Comments

am11 picture am11  ยท  57Comments

gclifford picture gclifford  ยท  43Comments

nrip-monotype picture nrip-monotype  ยท  35Comments

zdychacek picture zdychacek  ยท  33Comments