Skip to content

TSlint rule "no-consecutive-blank-lines" doesn't work with vue-service tslint #1766

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

Closed
hdurix opened this issue Jul 5, 2018 · 5 comments
Closed

Comments

@hdurix
Copy link

hdurix commented Jul 5, 2018

Version

3.0.0-rc.3

Reproduction link

https://github.com/hdurix/vue-consecutive-empty-lines

Steps to reproduce

Create a TypeScript project using vue cli.

Set no-consecutive-blank-lines to true (or remove it) in tslint.json

Change HelloWorld.vue to extract TypeScript in a dedicated file (HelloWorld.ts)

In HelloWorld.ts, add two consecutive empty lines.

In App.vue, add // @ts-ignore before the import statement (more information in #1576)

Launch npm run lint.

What is expected?

Consecutive empty lines are replaced by only one empty line.

What is actually happening?

The prompt says: No lint errors found.


The same thing works if we call directly tslint using tslint --project . --fix or if we run npm run serve.

I think, it comes from:

rules.set('no-consecutive-blank-lines', Object.assign({}, rule, {
ruleSeverity: 'off'
}))
.

@Akryum
Copy link
Member

Akryum commented Jul 5, 2018

It's explained in the comment just above:

// so that we get correct line numbers in error reports for *.vue files.

@Akryum Akryum closed this as completed Jul 5, 2018
@hdurix
Copy link
Author

hdurix commented Jul 5, 2018

So @Akryum, why, there is a different behaviour between npm run serve and npm run lint?

Note: the problem is not with the Vue file but with the dedicated TypeScript file.

Is there a documentation to explain why some tslint rules are not allowed?

@Akryum
Copy link
Member

Akryum commented Jul 6, 2018

there is a different behaviour between npm run serve and npm run lint

It wans't clear to me from your issue.

@backbone87
Copy link

why, there is a different behaviour between npm run serve and npm run lint?

I guess its because npm run serve runs tslint as part of a webpack build process and npm run lint calls a monkey-patched tslint directly. in the webpack process the rule isnt disabled.

@LinusBorg
Copy link
Member

Exactly. And we patch tslint in the lint script to make it work with .vue files. It's a necessary hack.

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

No branches or pull requests

4 participants