@@ -32,3 +32,38 @@ test('should work', async () => {
32
32
// test if tslint is fixing vue files properly
33
33
expect ( lintedApp ) . toBe ( app )
34
34
} )
35
+
36
+ test ( 'should not fix with --no-fix option' , async ( ) => {
37
+ const project = await create ( 'ts-lint-nofix' , {
38
+ plugins : {
39
+ '@vue/cli-plugin-typescript' : {
40
+ tsLint : true
41
+ }
42
+ }
43
+ } )
44
+ const { read, write, run } = project
45
+ const main = await read ( 'src/main.ts' )
46
+ expect ( main ) . toMatch ( ';' )
47
+ const app = await read ( 'src/App.vue' )
48
+ expect ( main ) . toMatch ( ';' )
49
+ // remove semicolons
50
+ const updatedMain = main . replace ( / ; / g, '' )
51
+ await write ( 'src/main.ts' , updatedMain )
52
+ // for Vue file, only remove semis in script section
53
+ const updatedApp = app . replace ( / < s c r i p t ( .| \n ) * \/ s c r i p t > / , $ => {
54
+ return $ . replace ( / ; / g, '' )
55
+ } )
56
+ await write ( 'src/App.vue' , updatedApp )
57
+
58
+ // lint with no fix should fail
59
+ try {
60
+ await run ( 'vue-cli-service lint --no-fix' )
61
+ } catch ( e ) {
62
+ expect ( e . code ) . toBe ( 1 )
63
+ expect ( e . failed ) . toBeTruthy ( )
64
+ }
65
+
66
+ // files should not have been fixed
67
+ expect ( await read ( 'src/main.ts' ) ) . not . toMatch ( ';' )
68
+ expect ( ( await read ( 'src/App.vue' ) ) . match ( / < s c r i p t ( .| \n ) * \/ s c r i p t > / ) [ 1 ] ) . not . toMatch ( ';' )
69
+ } )
0 commit comments