panuhorsmalahti / gulp-tslint

TypeScript linter plugin for Gulp
MIT License
118 stars 44 forks source link

Does not seem to do anything #5

Closed miffels closed 8 years ago

miffels commented 10 years ago

Hi,

I just got a fresh copy of gulp-tslint from npm. Unfortunately, when I pipe my .ts files into it, nothing seems to happen - even running your sample code does nothing:

var gulp = require('gulp');
var tslint = require('gulp-tslint');

gulp.task('tslint', function(){
      gulp.src('source.ts')
        .pipe(tslint())
        .pipe(tslint.report('verbose'));
});

I would at least expect some error since source.ts does not exist on my system.

panuhorsmalahti commented 10 years ago

If gulp-tslint finds no errors, nothing is printed. Well, something is, but no errors are to be reported.

Here's the example output of running gulp-tslint on a single missing file. This is identical to linting a file which has no errors.

nawi ~/dev/gulp-tslint/test $ gulp missing
[gulp] Using file /home/nawi/dev/gulp-tslint/test/gulpfile.js
[gulp] Working directory changed to /home/nawi/dev/gulp-tslint/test
[gulp] Running 'missing'...
[gulp] Finished 'missing' in 4.84 ms
nawi ~/dev/gulp-tslint/test $ 

I think that's expected behaviour in Gulp plugins. If the file pattern (say, *.ts) doesn't match anything, there shouldn't be any errors, as there's nothing wrong with non-existing files. Perhaps this should be a Gulp option, similar to Grunt's nonull option.

To your original problem, what's the exact console output? Try

cd node_modules/gulp-tslint/test
gulp invalid-emit
miffels commented 10 years ago

Your test works flawlessly, that's one good thing :)

When I add some gibberish to one of my .ts files and run gulp tslint:

[21:24:22] Starting 'tslint'...
[21:24:22] Finished 'tslint' after 36 ms

So - nothing really at that point. But when I add tsc to the pipe, like so:

gulp.task('tslint', function() {
    return gulp.src('app/ts/app.ts')
        .pipe(tslint())
        .pipe(tslint.report('verbose'))
        .pipe(typescript({
            sourcemap: true,
            outDir: OUT_DIR
        }))
        .pipe(gulp.dest(OUT_DIR));
});

I get instead:

[21:23:36] Starting 'tslint'...
[21:23:36] Compiling TypeScript files using tsc version 1.0.1.0
[21:23:38] [tsc] > path/to/app.ts(26,2): error TS2095: Could not find symbol 'asdasdsd'.
[21:23:41] Failed to compile TypeScript: Error: tsc command has exited with code
:1

Which is kind of strange, I thought. Any idea what might cause such an interference?

panuhorsmalahti commented 10 years ago

I think the reason is that you're using 'return' there.

gulp-tslint has a testcase with this comment: // TODO: Find why this doesn't throw an error to the command line You can run it with 'gulp invalid-emit-return' in the test folder.

Even though it doesn't throw an error to the command line like it should, the errors are still reported in the test case.

Are you certain that your test file has actual tslint issues? What seems to be happening is that the tslint task is executed but it doesn't find anything to report, so the next step (compilation) is then executed.

I'll probably need to investigate this bug further..

miffels commented 10 years ago

I tried adding the contents of invalid.ts to my test file, removed and added the return statement in the gulp task, tried it with and without tsc in the pipe - nothing changed. Since tsc does process the very same file and detects syntax error in it, I am certain that tslint should report something.

I will try to isolate some sort of "minimal broken example" tomorrow, which might help you if this really is a bug in gulp-tslint.

miffels commented 10 years ago

Here you go. The log.txt contains the last output I got, i.e., ./node_modules/.bin/gulp tslint > log.txt.

jocelyn-stericker commented 9 years ago

I had the same problem until I added a tslint.json. Should this be added to the readme?

(I know this is really late...)

panuhorsmalahti commented 9 years ago

The readme states: tslint.json is attempted to be read from near the input file.

I'll try to clarify that a bit.

panuhorsmalahti commented 9 years ago

I updated the readme, added a few bold bits in it. Hopefully it'll be noticed better.

miffels commented 9 years ago

@jnetterf better late than never :) This was the issue, it seems. @panuhorsmalahti Ah well, that might have sounded "optional" before. Would it be possible to emit a warning when gulp-tslint is run without a tslint.json?

panuhorsmalahti commented 9 years ago

@miffels That's a good idea. I'll take a look at that.

khuezy commented 9 years ago

Hi @panuhorsmalahti ,

I'm having the same issue, even with the tslint.json file.

When I downgrade to 2.0.0, it works flawlessly.

panuhorsmalahti commented 9 years ago

Hmm, that's odd. Are you using custom rules?

panuhorsmalahti commented 9 years ago

Could you try running the tests, do they work for you? What's the minimum setup to reproduce the issue? (E.g. gulpfile.js and file.ts)?

khuezy commented 9 years ago

I think it's because I'm using TypeScript 1.5.0-beta.

panuhorsmalahti commented 9 years ago

Does it work when using plain tslint directly?

peinearydevelopment commented 9 years ago

You state in the docs: "It must be available or supplied directly through the options." How do you supply it directly through the options? This has had me a bit stuck as well.

panuhorsmalahti commented 9 years ago

That it explained in the 'tslint.json can be supplied as a parameter by setting the configuration property.' part of the documentation.

ericis commented 8 years ago

I can reproduce. The issue appears easily when the code is in a sub-directory. https://gist.github.com/ericis/35161f8eca326e001c11

*I've also tried adding tslint.json to the "code" subdirectory to no avail. I also tried reading in the "tslint.json" from gulp using:

var tsLintConfig = require("./tslint.json");

... .pipe(tslint({ configuration: tsLintConfig }))

*I've also tried copying the contents of tslint.json directly into the "configuration" property above.

Nothing I did got tslint to work properly except placing the .ts files in the root.

ericis commented 8 years ago

Solved! Windows users need to use the forward-slash in their path and it magically works!

felschr commented 7 years ago

I'm having this issue right now. Running tslint directly works.

I'm running gulp 3.9.1, gulp-tslint 7.1.0 and tslint 5.0.0.

peterzagoranski commented 7 years ago

+1 ... same configuration as FelschR

amirburbea commented 7 years ago

+1 - this is annoying. Should I just have my gulp file shell out to run tslint directly??

begincalendar commented 7 years ago

@FelschR @peterzagoranski @amirburbea There is a pull request (that is yet to be merged), which addresses the issue.

As TSLint v5.x introduced quite a few breaking changes, you may want to temporarily use v4.x while that PR gets sorted.