File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed
packages/@vue/cli-plugin-typescript Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ test('lint', async () => {
7272 ] )
7373
7474 expect ( pkg . scripts . lint ) . toBe ( `vue-cli-service lint` )
75- expect ( pkg . vue ) . toEqual ( { lintOnSave : true } )
7675 expect ( pkg . devDependencies ) . toHaveProperty ( 'lint-staged' )
7776 expect ( pkg . gitHooks ) . toEqual ( { 'pre-commit' : 'lint-staged' } )
7877 expect ( pkg [ 'lint-staged' ] ) . toEqual ( {
@@ -83,6 +82,20 @@ test('lint', async () => {
8382 expect ( files [ 'tslint.json' ] ) . toBeTruthy ( )
8483} )
8584
85+ test ( 'lint with no lintOnSave' , async ( ) => {
86+ const { pkg } = await generateWithPlugin ( [
87+ {
88+ id : 'ts' ,
89+ apply : require ( '../generator' ) ,
90+ options : {
91+ tsLint : true ,
92+ lintOn : [ 'commit' ]
93+ }
94+ }
95+ ] )
96+ expect ( pkg . vue ) . toEqual ( { lintOnSave : false } )
97+ } )
98+
8699test ( 'compat with unit-mocha' , async ( ) => {
87100 const { pkg } = await generateWithPlugin ( [
88101 {
Original file line number Diff line number Diff line change @@ -50,12 +50,17 @@ module.exports = (api, {
5050 api . extendPackage ( {
5151 scripts : {
5252 lint : 'vue-cli-service lint'
53- } ,
54- vue : {
55- lintOnSave : lintOn . includes ( 'save' )
5653 }
5754 } )
5855
56+ if ( ! lintOn . includes ( 'save' ) ) {
57+ api . extendPackage ( {
58+ vue : {
59+ lintOnSave : false
60+ }
61+ } )
62+ }
63+
5964 if ( lintOn . includes ( 'commit' ) ) {
6065 api . extendPackage ( {
6166 devDependencies : {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = (api, {
33 lintOnSave,
44 experimentalCompileTsWithBabel
55} ) => {
6+ const fs = require ( 'fs' )
67 const useThreads = process . env . NODE_ENV === 'production' && parallel
78 const cacheDirectory = api . resolve ( 'node_modules/.cache/cache-loader' )
89
@@ -81,7 +82,7 @@ module.exports = (api, {
8182 . plugin ( 'fork-ts-checker' )
8283 . use ( require ( 'fork-ts-checker-webpack-plugin' ) , [ {
8384 vue : true ,
84- tslint : lintOnSave !== false ,
85+ tslint : lintOnSave !== false && fs . existsSync ( api . resolve ( 'tslint.json' ) ) ,
8586 formatter : 'codeframe' ,
8687 // https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
8788 checkSyntacticErrors : useThreads
You can’t perform that action at this time.
0 commit comments