File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -28,5 +28,19 @@ module.exports = {
28
28
} ;
29
29
30
30
return applyOptionsCallback ( webpackConfig . eslintLoaderOptionsCallback , eslintLoaderOptions ) ;
31
+ } ,
32
+
33
+ /**
34
+ * @param {WebpackConfig } webpackConfig
35
+ * @return {RegExp } to use for eslint-loader `test` rule
36
+ */
37
+ getTest ( webpackConfig ) {
38
+ const extensions = [ 'jsx?' ] ;
39
+
40
+ if ( webpackConfig . eslintOptions . lintVue ) {
41
+ extensions . push ( 'vue' ) ;
42
+ }
43
+
44
+ return new RegExp ( `\\.(${ extensions . join ( '|' ) } )$` ) ;
31
45
}
32
46
} ;
Original file line number Diff line number Diff line change @@ -77,4 +77,21 @@ describe('loaders/eslint', () => {
77
77
const actualOptions = eslintLoader . getOptions ( config ) ;
78
78
expect ( actualOptions ) . to . deep . equals ( { foo : true } ) ;
79
79
} ) ;
80
+
81
+ it ( 'getTest() base behavior' , ( ) => {
82
+ const config = createConfig ( ) ;
83
+
84
+ const actualTest = eslintLoader . getTest ( config ) ;
85
+ expect ( actualTest . toString ( ) ) . to . equals ( / \. ( j s x ? ) $ / . toString ( ) ) ;
86
+ } ) ;
87
+
88
+ it ( 'getTest() with Vue' , ( ) => {
89
+ const config = createConfig ( ) ;
90
+ config . enableEslintLoader ( ( ) => { } , {
91
+ lintVue : true ,
92
+ } ) ;
93
+
94
+ const actualTest = eslintLoader . getTest ( config ) ;
95
+ expect ( actualTest . toString ( ) ) . to . equals ( / \. ( j s x ? | v u e ) $ / . toString ( ) ) ;
96
+ } ) ;
80
97
} ) ;
You can’t perform that action at this time.
0 commit comments