Skip to content

fix(tslint): correctly pad the script content #3561

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
wants to merge 1 commit into from

Conversation

backbone87
Copy link

this avoids manipulating the tslint ruleset, which is only necessary
because the padding of vueCompiler does not work for lang="ts" scripts.
this also makes vue-cli tslint work with tslint-plugin-prettier

prereq for: #761
unexpected upstream behavior:
https://github.com/vuejs/vue/blob/dev/src/sfc/parser.js#L119

@backbone87
Copy link
Author

backbone87 commented Mar 3, 2019

edit: i have dropped support for single line scripts completely, see comment below

notes on leading and trailing linebreaks inside script content:

(examples using prettier)

first leading linebreak (imediately after the script tag) is preserved:

<script>
import Vue from 'vue';
</script>

-> will become

<script>
import Vue from 'vue';
</script>

no leading linebreak is preserved:

<script>import Vue from 'vue';
</script>

-> will become

<script>import Vue from 'vue';
</script>

trailing linebreak is added, if not present (after linter fixing)

<script>
import Vue from 'vue';</script>

-> will become

<script>
import Vue from 'vue';
</script>

therefore this is not possible:

<script>import Vue from 'vue';</script>

-> will become

<script>import Vue from 'vue';
</script>

also:

<script>
import Vue from 'vue';

</script>

-> will become

<script>
import Vue from 'vue';
</script>

but since single line scripts are rare and probably not recommended, i decided to leave it this way for now

… the tslint ruleset, which is only necessarybecause the padding of vueCompiler does not work for lang="ts" scripts.this also makes vue-cli tslint work with tslint-plugin-prettierprereq for: https://github.com/vuejs/vue-cli/issues/761unexpected upstream behavior:https://github.com/vuejs/vue/blob/dev/src/sfc/parser.js#L119
@backbone87
Copy link
Author

backbone87 commented Mar 4, 2019

after experimenting more with the single line scripts, i noticed that vscode + vetur dont correctly syntax color them anyway, so i dropped the preservation of single line scripts completely.

there is just one caveat:
<script>import Vue from 'vue';: no leading linebreak in script content wont be reported as a lint failure (at least for prettier, i guess its the some for consecutive newlines tslint rule). however when the file is written (because of another lint failure), this leadine linebreak is added.`

so basically with prettier the following would be reported as error:

<script>

import Vue from 'vue';

while

<script>
import Vue from 'vue';

and

<script>import Vue from 'vue';

causes no error.
if the file gets written (because of any lint error in the file), all result in the following:

<script>
import Vue from 'vue';

this could be solved by creating a custom tslint rule for vue files, where this special case is handled

@backbone87
Copy link
Author

any update on this? its really annoying not being able to use the lint command especially in CI

@haoqunjiang
Copy link
Member

Thanks for the PR.

As TSLint has been officially deprecated, we do not plan to add any new feature to this functionality and it will be removed in the next major.
So I'm closing this PR.

Thanks anyway!

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

Successfully merging this pull request may close these issues.

2 participants