@@ -89,6 +89,15 @@ const ENGINE_RULES = {
89
89
}
90
90
} ;
91
91
92
+ const PRETTIER_CONFIG_OVERRIDE = {
93
+ '@typescript-eslint/eslint-plugin' : 'prettier/@typescript-eslint' ,
94
+ 'eslint-plugin-babel' : 'prettier/babel' ,
95
+ 'eslint-plugin-flowtype' : 'prettier/flowtype' ,
96
+ 'eslint-plugin-react' : 'prettier/react' ,
97
+ 'eslint-plugin-standard' : 'prettier/standard' ,
98
+ 'eslint-plugin-vue' : 'prettier/vue'
99
+ } ;
100
+
92
101
// Keep the same behaviour in mergeWith as deepAssign
93
102
const mergeFn = ( previousValue , value ) => {
94
103
if ( Array . isArray ( previousValue ) && Array . isArray ( value ) ) {
@@ -281,23 +290,20 @@ const buildConfig = options => {
281
290
282
291
// If the user sets the `prettier` options then add the `prettier` plugin and config
283
292
if ( options . prettier ) {
284
- // Disable formatting rules conflicting with Prettier
285
- config . rules [ 'unicorn/number-literal-case' ] = 'off' ;
286
- // Can be re-enabled when https://github.com/prettier/prettier/issues/4157 is fixed
287
- config . rules [ 'unicorn/no-nested-ternary' ] = 'off' ;
288
293
// The prettier plugin uses Prettier to format the code with `--fix`
289
294
config . plugins = config . plugins . concat ( 'prettier' ) ;
290
295
// The prettier config overrides ESLint stylistic rules that are handled by Prettier
291
296
config . baseConfig . extends = config . baseConfig . extends . concat ( 'prettier' ) ;
297
+ config . baseConfig . extends = config . baseConfig . extends . concat ( 'prettier/unicorn' ) ;
292
298
// The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
293
299
config . rules [ 'prettier/prettier' ] = [
294
300
'error' , mergeWithPrettierConfig ( options , prettier . resolveConfig . sync ( options . cwd || process . cwd ( ) ) || { } )
295
301
] ;
296
302
// If the user has the React, Flowtype, or Standard plugin, add the corresponding Prettier rule overrides
297
303
// See https://github.com/prettier/eslint-config-prettier for the list of plugins overrrides
298
- for ( const override of [ 'react' , 'flowtype' , 'standard' ] ) {
299
- if ( options . cwd && resolveFrom . silent ( options . cwd , `eslint- plugin- ${ override } ` ) ) {
300
- config . baseConfig . extends = config . baseConfig . extends . concat ( `prettier/ ${ override } ` ) ;
304
+ for ( const [ plugin , prettierConfig ] of Object . entries ( PRETTIER_CONFIG_OVERRIDE ) ) {
305
+ if ( options . cwd && resolveFrom . silent ( options . cwd , plugin ) ) {
306
+ config . baseConfig . extends = config . baseConfig . extends . concat ( prettierConfig ) ;
301
307
}
302
308
}
303
309
}
0 commit comments