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 @@ -69,5 +69,19 @@ Install ${chalk.yellow('babel-eslint')} to prevent potential parsing issues: ${p
69
69
} ;
70
70
71
71
return applyOptionsCallback ( webpackConfig . eslintLoaderOptionsCallback , eslintLoaderOptions ) ;
72
+ } ,
73
+
74
+ /**
75
+ * @param {WebpackConfig } webpackConfig
76
+ * @return {RegExp } to use for eslint-loader `test` rule
77
+ */
78
+ getTest ( webpackConfig ) {
79
+ const extensions = [ 'jsx?' ] ;
80
+
81
+ if ( webpackConfig . eslintOptions . lintVue ) {
82
+ extensions . push ( 'vue' ) ;
83
+ }
84
+
85
+ return new RegExp ( `\\.(${ extensions . join ( '|' ) } )$` ) ;
72
86
}
73
87
} ;
Original file line number Diff line number Diff line change @@ -74,4 +74,21 @@ describe('loaders/eslint', () => {
74
74
const actualOptions = eslintLoader . getOptions ( config ) ;
75
75
expect ( actualOptions ) . to . deep . equals ( { foo : true } ) ;
76
76
} ) ;
77
+
78
+ it ( 'getTest() base behavior' , ( ) => {
79
+ const config = createConfig ( ) ;
80
+
81
+ const actualTest = eslintLoader . getTest ( config ) ;
82
+ expect ( actualTest . toString ( ) ) . to . equals ( / \. ( j s x ? ) $ / . toString ( ) ) ;
83
+ } ) ;
84
+
85
+ it ( 'getTest() with Vue' , ( ) => {
86
+ const config = createConfig ( ) ;
87
+ config . enableEslintLoader ( ( ) => { } , {
88
+ lintVue : true ,
89
+ } ) ;
90
+
91
+ const actualTest = eslintLoader . getTest ( config ) ;
92
+ expect ( actualTest . toString ( ) ) . to . equals ( / \. ( j s x ? | v u e ) $ / . toString ( ) ) ;
93
+ } ) ;
77
94
} ) ;
You can’t perform that action at this time.
0 commit comments