This repository was archived by the owner on Sep 28, 2020. It is now read-only.
File tree 1 file changed +26
-10
lines changed
1 file changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -155,20 +155,10 @@ module.exports = function(input, map) {
155
155
) ;
156
156
157
157
var userEslintPath = userOptions . eslintPath ;
158
- var formatter = require ( "eslint/lib/formatters/stylish" ) ;
159
-
160
- if ( userEslintPath ) {
161
- try {
162
- formatter = require ( userEslintPath + "/lib/formatters/stylish" ) ;
163
- } catch ( e ) {
164
- formatter = require ( "eslint/lib/formatters/stylish" ) ;
165
- }
166
- }
167
158
168
159
var config = assign (
169
160
// loader defaults
170
161
{
171
- formatter : formatter ,
172
162
cacheIdentifier : JSON . stringify ( {
173
163
"eslint-loader" : pkg . version ,
174
164
eslint : require ( userEslintPath || "eslint" ) . version
@@ -178,6 +168,32 @@ module.exports = function(input, map) {
178
168
userOptions
179
169
) ;
180
170
171
+ if ( typeof config . formatter === "string" ) {
172
+ try {
173
+ config . formatter = require ( config . formatter ) ;
174
+ if (
175
+ config . formatter &&
176
+ typeof config . formatter !== "function" &&
177
+ typeof config . formatter . default === "function"
178
+ ) {
179
+ config . formatter = config . formatter . default ;
180
+ }
181
+ } catch ( _ ) {
182
+ // ignored
183
+ }
184
+ }
185
+ if ( config . formatter == null || typeof config . formatter !== "function" ) {
186
+ if ( userEslintPath ) {
187
+ try {
188
+ config . formatter = require ( userEslintPath + "/lib/formatters/stylish" ) ;
189
+ } catch ( e ) {
190
+ config . formatter = require ( "eslint/lib/formatters/stylish" ) ;
191
+ }
192
+ } else {
193
+ config . formatter = require ( "eslint/lib/formatters/stylish" ) ;
194
+ }
195
+ }
196
+
181
197
var cacheDirectory = config . cache ;
182
198
var cacheIdentifier = config . cacheIdentifier ;
183
199
You can’t perform that action at this time.
0 commit comments