@@ -234,6 +234,8 @@ var Project = function () {
234
234
} , {
235
235
key : 'lint' ,
236
236
value : function lint ( dir , callback ) {
237
+ var _this3 = this ;
238
+
237
239
warn ( 'Linting JS Files ...' ) ;
238
240
239
241
var CLIEngine = require ( 'eslint' ) . CLIEngine ;
@@ -244,9 +246,20 @@ var Project = function () {
244
246
}
245
247
246
248
// prepare eslint config file
247
- var configFilePath = sysPath . join ( __dirname , '../../cache' , '.eslintrc.json' ) ;
248
- fs . writeFileSync ( configFilePath , JSON . stringify ( this . eslintConfig ) ) ;
249
- this . eslintConfig . useEslintrc = false ;
249
+ // const configFilePath = sysPath.join(__dirname, '../../' ,'.eslintrc.json')
250
+ var eslintExts = [ '.js' , '.yaml' , '.yml' , '.json' , '' ] ;
251
+ var configFilePath = '' ;
252
+ eslintExts . forEach ( function ( eslintExtItem ) {
253
+ if ( _this3 . _fileExists ( sysPath . join ( _this3 . cwd , '.eslintrc' + eslintExtItem ) ) ) {
254
+ configFilePath = sysPath . join ( _this3 . cwd , '.eslintrc' + eslintExtItem ) ;
255
+ }
256
+ } ) ;
257
+
258
+ if ( ! configFilePath ) {
259
+ configFilePath = sysPath . join ( this . cwd , '.eslintrc.json' ) ;
260
+ fs . writeFileSync ( configFilePath , JSON . stringify ( this . eslintConfig , null , ' ' ) ) ;
261
+ }
262
+
250
263
this . eslintConfig . configFile = configFilePath ;
251
264
252
265
var cli = new CLIEngine ( this . eslintConfig ) ,
@@ -289,7 +302,7 @@ var Project = function () {
289
302
} , {
290
303
key : 'pack' ,
291
304
value : function pack ( opt , callback ) {
292
- var _this3 = this ;
305
+ var _this4 = this ;
293
306
294
307
var config = this . config . getConfig ( ) ;
295
308
UtilFs . deleteFolderRecursive ( this . cachePath ) ;
@@ -316,7 +329,7 @@ var Project = function () {
316
329
config . output = config . output . dev ;
317
330
}
318
331
319
- _this3 . fixCss ( ) ;
332
+ _this4 . fixCss ( ) ;
320
333
321
334
if ( opt . clean ) {
322
335
try {
@@ -357,7 +370,7 @@ var Project = function () {
357
370
}
358
371
} ) ;
359
372
info ( ) ;
360
- _this3 . packCallbacks . forEach ( function ( cb ) {
373
+ _this4 . packCallbacks . forEach ( function ( cb ) {
361
374
return cb ( opt , stats ) ;
362
375
} ) ;
363
376
}
@@ -368,9 +381,9 @@ var Project = function () {
368
381
369
382
if ( opt . lint ) {
370
383
async . series ( [ function ( callback ) {
371
- return _this3 . lint ( callback ) ;
384
+ return _this4 . lint ( callback ) ;
372
385
} , function ( callback ) {
373
- return _this3 . lintCss ( callback ) ;
386
+ return _this4 . lintCss ( callback ) ;
374
387
} ] , function ( err , results ) {
375
388
if ( ! err ) {
376
389
if ( results [ 0 ] && results [ 1 ] ) {
@@ -469,6 +482,15 @@ var Project = function () {
469
482
470
483
return false ;
471
484
}
485
+ } , {
486
+ key : '_fileExists' ,
487
+ value : function _fileExists ( filePath ) {
488
+ try {
489
+ return fs . statSync ( filePath ) . isFile ( ) ;
490
+ } catch ( err ) {
491
+ return false ;
492
+ }
493
+ }
472
494
} ] ) ;
473
495
474
496
return Project ;
0 commit comments