Tslint: Docs are missing instructions for implementing fix for lints

Created on 26 Jun 2017  Â·  9Comments  Â·  Source: palantir/tslint

Help Request

  • TSLint version: 5.4.3:
  • Typescript version: 2.4.0:
  • Using: VSCode

Test.ts.lint

// simple call
console.clear( );
              ~ [0]

[0]: No space within parentheses

Test.ts.fix

// simple call
console.clear();

with tslint.json configuration:

{
    "rules": {
        "space-within-parens": [true, 0]
    }
}

Expected behavior

I cannot figure out how to write fixes for my lints. I already implemented the rule and it works but when I run fix that is corresponding with the output, I always get below message and I couldn't find any docs to understand what's the problem!

Expected (from .fix file)
Actual (from TSLint)
// simple call
console.clear();

Fix implementation

let lintMsg: string;
let lintFix: Lint.Replacement;
if (this.options.size === 0) {
  lintMsg = Rule.FAILURE_NO_SPACE;
  lintFix = Lint.Replacement.deleteText(position, length);
}
this.addFailureAt(position, length, lintMsg, lintFix);
Question

Most helpful comment

Add a line break to your .fix file and it will work
The second line in your .lint file results in an empty line in the .fix output

All 9 comments

Add a line break to your .fix file and it will work
The second line in your .lint file results in an empty line in the .fix output

Wonderful!
We're missing this in results, an indicator may worth thousands... I assume this happens only with empty lines.

How can I PR this new rule?
What I already did:

  1. Forked tslint
  2. Added new rule
  3. Compiled and tests are working

We're missing this in results, an indicator may worth thousands...

I thought about that, too. I don't know if only empty lines should be handles specially or all lines...

How can I PR this new rule?

Add it to src/config/latest.ts and src/config/all.ts
Log into https://circleci.com/ and enable test for your fork. Also set the concurrency to 4, otherwise CI will fail.

(In case you haven't done this before) Commit and push your rule to a new branch and visit https://github.com/palantir/tslint. Github will automatically suggest a PR from that branch.

Where is this concurrency settings?
It already fail without my commit as you said!

Tests on my local pass, but they failed with CI!
Do you have access to see the logs in my branch or not?

CI tests with different versions of typescript. That may cause failures
even if tests pass locally.

I'll look into that tomorrow.

You can still open a PR though, so I can also give you feedback on the
implementation.

Am 26.06.2017 22:18 schrieb "Amin Pakseresht" notifications@github.com:

Tests on my local pass, but they failed with CI!
Do you have access to see the logs in my branch
https://github.com/aminpaks/tslint/tree/space-within-parens or not?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/palantir/tslint/issues/2956#issuecomment-311169848,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALaeKJifD-vfWpi6ORSN9Zz1Hb0nw6gNks5sIBH3gaJpZM4OFr6l
.

Great, thanks.

Was this page helpful?
0 / 5 - 0 ratings