1- 'use strict' ;
2- import os from 'os' ;
3- import path from 'path' ;
1+ import os from 'node:os' ;
2+ import path from 'node:path' ;
43import fsExtra from 'fs-extra' ;
54import arrify from 'arrify' ;
65import { mergeWith , groupBy , flow , pick } from 'lodash-es' ;
@@ -43,7 +42,7 @@ const resolveFrom = (moduleId, fromDirectory = process.cwd()) => resolveModule(m
4342resolveFrom . silent = ( moduleId , fromDirectory ) => {
4443 try {
4544 return resolveFrom ( moduleId , fromDirectory ) ;
46- } catch { }
45+ } catch { }
4746} ;
4847
4948const resolveLocalConfig = name => resolveModule ( normalizePackageName ( name , 'eslint-config' ) , import . meta. url ) ;
@@ -92,7 +91,7 @@ const getEmptyXOConfig = () => ({
9291const mergeFn = ( previousValue , value , key ) => {
9392 if ( Array . isArray ( previousValue ) ) {
9493 if ( MERGE_OPTIONS_CONCAT . includes ( key ) ) {
95- return previousValue . concat ( value ) ;
94+ return [ ... previousValue , ... value ] ;
9695 }
9796
9897 return value ;
@@ -186,7 +185,7 @@ const mergeWithFileConfigs = async (files, options, configFiles) => {
186185
187186 await Promise . all ( Object . entries ( groupBy ( groups . filter ( ( { options} ) => Boolean ( options . ts ) ) , group => group . options . tsConfigPath || '' ) ) . map (
188187 ( [ tsConfigPath , groups ] ) => {
189- const files = [ ] . concat ( ... groups . map ( group => group . files ) ) ;
188+ const files = groups . flatMap ( group => group . files ) ;
190189 const cachePath = getTsConfigCachePath ( files , tsConfigPath ) ;
191190
192191 for ( const group of groups ) {
@@ -386,7 +385,7 @@ const buildXOConfig = options => config => {
386385
387386 // Only apply if the user has the React plugin
388387 if ( options . cwd && resolveFrom . silent ( 'eslint-plugin-react' , options . cwd ) ) {
389- config . baseConfig . plugins = config . baseConfig . plugins . concat ( 'react' ) ;
388+ config . baseConfig . plugins . push ( 'react' ) ;
390389 config . baseConfig . rules [ 'react/jsx-indent-props' ] = [ 'error' , spaces ] ;
391390 config . baseConfig . rules [ 'react/jsx-indent' ] = [ 'error' , spaces ] ;
392391 }
@@ -452,10 +451,10 @@ const buildExtendsConfig = options => config => {
452451const buildPrettierConfig = ( options , prettierConfig ) => config => {
453452 if ( options . prettier ) {
454453 // The prettier plugin uses Prettier to format the code with `--fix`
455- config . baseConfig . plugins = config . baseConfig . plugins . concat ( 'prettier' ) ;
454+ config . baseConfig . plugins . push ( 'prettier' ) ;
456455
457456 // The prettier config overrides ESLint stylistic rules that are handled by Prettier
458- config . baseConfig . extends = config . baseConfig . extends . concat ( 'prettier' ) ;
457+ config . baseConfig . extends . push ( 'prettier' ) ;
459458
460459 // The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
461460 config . baseConfig . rules [ 'prettier/prettier' ] = [ 'error' , mergeWithPrettierConfig ( options , prettierConfig ) ] ;
@@ -464,7 +463,7 @@ const buildPrettierConfig = (options, prettierConfig) => config => {
464463 // See https://github.com/prettier/eslint-config-prettier for the list of plugins overrrides
465464 for ( const [ plugin , prettierConfig ] of Object . entries ( PRETTIER_CONFIG_OVERRIDE ) ) {
466465 if ( options . cwd && resolveFrom . silent ( plugin , options . cwd ) ) {
467- config . baseConfig . extends = config . baseConfig . extends . concat ( prettierConfig ) ;
466+ config . baseConfig . extends . push ( prettierConfig ) ;
468467 }
469468 }
470469 }
@@ -505,7 +504,7 @@ const mergeWithPrettierConfig = (options, prettierOptions) => {
505504
506505const buildTSConfig = options => config => {
507506 if ( options . ts ) {
508- config . baseConfig . extends = config . baseConfig . extends . concat ( 'xo-typescript' ) ;
507+ config . baseConfig . extends . push ( 'xo-typescript' ) ;
509508 config . baseConfig . parser = require . resolve ( '@typescript-eslint/parser' ) ;
510509 config . baseConfig . parserOptions = {
511510 ...config . baseConfig . parserOptions ,
@@ -532,7 +531,7 @@ const applyOverrides = (file, options) => {
532531
533532 const { applicable, hash} = findApplicableOverrides ( path . relative ( options . cwd , file ) , overrides ) ;
534533
535- options = mergeWith ( ... [ getEmptyXOConfig ( ) , options ] . concat ( applicable . map ( override => normalizeOptions ( override ) ) , mergeFn ) ) ;
534+ options = mergeWith ( getEmptyXOConfig ( ) , options , ... applicable . map ( override => normalizeOptions ( override ) ) , mergeFn ) ;
536535 delete options . files ;
537536 return { options, hash} ;
538537 }
0 commit comments