File tree 3 files changed +24
-5
lines changed
packages/@vue/cli-plugin-typescript
3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ test('lint', async () => {
72
72
] )
73
73
74
74
expect ( pkg . scripts . lint ) . toBe ( `vue-cli-service lint` )
75
- expect ( pkg . vue ) . toEqual ( { lintOnSave : true } )
76
75
expect ( pkg . devDependencies ) . toHaveProperty ( 'lint-staged' )
77
76
expect ( pkg . gitHooks ) . toEqual ( { 'pre-commit' : 'lint-staged' } )
78
77
expect ( pkg [ 'lint-staged' ] ) . toEqual ( {
@@ -83,6 +82,20 @@ test('lint', async () => {
83
82
expect ( files [ 'tslint.json' ] ) . toBeTruthy ( )
84
83
} )
85
84
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
+
86
99
test ( 'compat with unit-mocha' , async ( ) => {
87
100
const { pkg } = await generateWithPlugin ( [
88
101
{
Original file line number Diff line number Diff line change @@ -50,12 +50,17 @@ module.exports = (api, {
50
50
api . extendPackage ( {
51
51
scripts : {
52
52
lint : 'vue-cli-service lint'
53
- } ,
54
- vue : {
55
- lintOnSave : lintOn . includes ( 'save' )
56
53
}
57
54
} )
58
55
56
+ if ( ! lintOn . includes ( 'save' ) ) {
57
+ api . extendPackage ( {
58
+ vue : {
59
+ lintOnSave : false
60
+ }
61
+ } )
62
+ }
63
+
59
64
if ( lintOn . includes ( 'commit' ) ) {
60
65
api . extendPackage ( {
61
66
devDependencies : {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module.exports = (api, {
3
3
lintOnSave,
4
4
experimentalCompileTsWithBabel
5
5
} ) => {
6
+ const fs = require ( 'fs' )
6
7
const useThreads = process . env . NODE_ENV === 'production' && parallel
7
8
const cacheDirectory = api . resolve ( 'node_modules/.cache/cache-loader' )
8
9
@@ -81,7 +82,7 @@ module.exports = (api, {
81
82
. plugin ( 'fork-ts-checker' )
82
83
. use ( require ( 'fork-ts-checker-webpack-plugin' ) , [ {
83
84
vue : true ,
84
- tslint : lintOnSave !== false ,
85
+ tslint : lintOnSave !== false && fs . existsSync ( api . resolve ( 'tslint.json' ) ) ,
85
86
formatter : 'codeframe' ,
86
87
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
87
88
checkSyntacticErrors : useThreads
You can’t perform that action at this time.
0 commit comments