Tslint: "Unnecessary semicolon" error if semicolon placed on function declaration

Created on 29 Mar 2017  路  4Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.0.0
  • __TypeScript version__: 2.0.3
  • __Running TSLint via__: (pick one) CLI

TypeScript code being linted

function Foo() {
    let a = 3;

    a++;

    return a;
};

with tslint.json configuration:

{
  "extends": "tslint:recommended",
  "rules": {
     "semicolon": [true, "always"]
  },
  "jsRules": { },
  "rulesDirectory": [ ]
}

Actual behavior

According to the docs, no error should be thrown. "always" enforces semicolons at the end of every statement, and says nothing about any behaviour on unnecessary semicolons.

Expected behavior

"Unnecessary semicolon" error.

Duplicate

Most helpful comment

for those we want to enforce semicolon after class methods, use:

"semicolon": [true, "always", "strict-bound-class-methods"]

All 4 comments

Ideally I would like an option to enforce semicolon usage after a function declaration. Happy to submit a PR for this.

going to lump this together with #2015; see my comment https://github.com/palantir/tslint/issues/2015#issuecomment-271642753 -- we'd welcome a PR to separate the "unnecessary semicolon" checking into a new rule option

"Unnecessary semicolon" when only set to "always".

  • tslint: 5.12.0
  • typescript: 3.2
  • Running TSLint via: cli
private method = () => {
        // do something
};

No error when "ignore-bound-class-methods" also applied.

for those we want to enforce semicolon after class methods, use:

"semicolon": [true, "always", "strict-bound-class-methods"]
Was this page helpful?
0 / 5 - 0 ratings