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

False positive for semicolon rule #2206

Closed
ChrisMBarr opened this issue Feb 14, 2017 · 3 comments
Closed

False positive for semicolon rule #2206

ChrisMBarr opened this issue Feb 14, 2017 · 3 comments

Comments

@ChrisMBarr
Copy link
Contributor

ChrisMBarr commented Feb 14, 2017

Bug Report

  • TSLint version: 4.4.2
  • TypeScript version: 2.1.6
  • Running TSLint via: gulp-tslint 7.1.0

TypeScript code being linted

class myClass {

    public foo = () => { }

    public bar = () => {
      
    }

}

with tslint.json configuration:

"semicolon": [ true, "always", "ignore-interfaces" ],

Actual behavior

The method foo on a single line reports an invalid "Missing semicolon" violation, but the method bar on multiple lines does not report a violation (correctly).

Expected behavior

The number of lines a method takes up should not affect whether a semicolon is required or not. I would expect a single-line method to not require a semicolon just like the rest.

@nchen63
Copy link
Contributor

nchen63 commented Feb 15, 2017

duplicate of #1949

@nchen63 nchen63 closed this as completed Feb 15, 2017
@ChrisMBarr
Copy link
Contributor Author

ChrisMBarr commented Feb 15, 2017

@nchen63 Perhaps I am misunderstanding, but this does not appear to be a duplicate of that issue.

Improper semicolons are being reported on class method members unless they are declared on a single line, in which case it reports that a semicolon is required which is incorrect.

Here's a better example:

class myClass {

    public foo1 = () => { }  //<-- reports "missing semicolon" (incorrect)

    public bar1 = () => {
  
    }   //<-- nothing reported  (correct)

    public foo2 = () => { };  //<-- nothing reported (incorrect, this should not be required)

    public bar2 = () => {
  
    };   //<-- reports "misplaced semicolon" (correct)

}

@nchen63
Copy link
Contributor

nchen63 commented Feb 15, 2017

Previously, all of those cases required semicolons. #1476 was a change that allowed missing semicolons for the multiline case, so this is by design

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants