From aa8d4822c080384d74168bac005ff061522bab01 Mon Sep 17 00:00:00 2001 From: ktsn Date: Wed, 8 Aug 2018 10:58:32 +0900 Subject: [PATCH] Avoid false positive of no-consecutive-blank-lines TSLint rule in Vue file --- src/VueProgram.ts | 12 +++++++--- test/integration/vue.spec.js | 11 +++++++++ test/unit/VueProgram.spec.js | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/VueProgram.ts b/src/VueProgram.ts index b1ba72ef..b99e469d 100644 --- a/src/VueProgram.ts +++ b/src/VueProgram.ts @@ -195,7 +195,7 @@ class VueProgram { } } - private static resolveScriptBlock(content: string): ResolvedScript { + static resolveScriptBlock(content: string): ResolvedScript { // We need to import vue-template-compiler lazily because it cannot be included it // as direct dependency because it is an optional dependency of fork-ts-checker-webpack-plugin. // Since its version must not mismatch with user-installed Vue.js, @@ -209,7 +209,7 @@ class VueProgram { } const { script } = parser.parseComponent(content, { - pad: 'line' + pad: 'space' }); // No ' + ].join('\n'); + + var result = VueProgram.resolveScriptBlock(content); + + expect(result.scriptKind).to.be.equal(ts.ScriptKind.TS); + expect(result.content).to.be.equal([ + '', + 'import Vue from "vue";', + 'export default Vue.extend({});', + '' + ].join('\n')); + }); + + it('should pad lines', function() { + var content = [ + '', + '', + '' + ].join('\n'); + + var result = VueProgram.resolveScriptBlock(content); + + expect(result.content).to.be.equal([ + '//', + '//', + '//', + '//', + '', + 'import Vue from "vue";', + 'export default Vue.extend({});', + '' + ].join('\n')); + }); });