Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gulp-tslint ignores the no-irregular-whitespace rule #139

Closed
FiniteLooper opened this issue Nov 3, 2017 · 3 comments
Closed

gulp-tslint ignores the no-irregular-whitespace rule #139

FiniteLooper opened this issue Nov 3, 2017 · 3 comments

Comments

@FiniteLooper
Copy link

gulp-tslint version: 8.1.2
tslint version: 5.8.0
Operating system: Windows 10

I have a TS file that has "irregular whitespace" reported via the no-irregular-whitespace tslint rule. I can verify this by running tslint from the command line:

tslint --format stylish --config tslint.json app/**/*.ts

which produces this console output

app/App.module.ts
ERROR: 1:1  no-irregular-whitespace  Irregular whitespace not allowed

However from the exact same project I have gulp-tslint set up like this:

const gulp        = require("gulp");
const plumber     = require("gulp-plumber");
const gulpTslint  = require("gulp-tslint");
const tslint      = require("tslint");

gulp.task("lint", () => {
    return gulp.src(["app/**/*.ts"])
        .pipe(plumber())
        .pipe(gulpTslint({
            formatter: "stylish",
        }))
        .pipe(gulpTslint.report());
});

and calling gulp lint produces zero errors! This wa first discovered in vladimir-djokic/TSLint#8 where I thought it was an issue that that project, but I was wrong.

I've attached a small demo project: 📂 irregular-whitespace-test.zip

download it and run npm install, then run gulp lint and npm run lint to see the different outputs.

no-irregular-whitespace

@panuhorsmalahti
Copy link
Owner

Can you verify that the tslint.json you've created is used by gulp-tslint? I haven't debugged this yet, but it's possible that it's not using the tslint.json file in your project folder for some reason, and maybe falls back to the default lint rules - which might not include the no-irregular-whitespace rule.

You could test by e.g. using "tslint.json can be supplied as a parameter by setting the configuration property" as per the readme.

@FiniteLooper
Copy link
Author

Yes, I have verified it. To be sure though, here's a slightly modified version of the same project that only enables only no-irregular-whitespace and no-var-keyword. I have used the var keyword in the TS file once.

Running tslint via command line produces 2 errors as expected, and running via gulp-tslint only produces 1 error, skipping the no-irregular-whitespace rule. Download the below attachment to see.

📂 no-irregular-whitespace-2.zip

@FiniteLooper
Copy link
Author

@panuhorsmalahti any updates or feedback about this?

I have a feeling it's probably related to this line in the source of gulp-tslint.

tslint.lint(file.path, file.contents.toString("utf8"), configuration);

If this auto-converts things to UTF-8 before linting, then (I think...) it will never be able to detect the unicode characters that the no-irregular-whitespace rule is looking for.

@FiniteLooper FiniteLooper closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants