@@ -89,6 +89,15 @@ const ENGINE_RULES = {
8989 }
9090} ;
9191
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+
92101// Keep the same behaviour in mergeWith as deepAssign
93102const mergeFn = ( previousValue , value ) => {
94103 if ( Array . isArray ( previousValue ) && Array . isArray ( value ) ) {
@@ -281,23 +290,20 @@ const buildConfig = options => {
281290
282291 // If the user sets the `prettier` options then add the `prettier` plugin and config
283292 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' ;
288293 // The prettier plugin uses Prettier to format the code with `--fix`
289294 config . plugins = config . plugins . concat ( 'prettier' ) ;
290295 // The prettier config overrides ESLint stylistic rules that are handled by Prettier
291296 config . baseConfig . extends = config . baseConfig . extends . concat ( 'prettier' ) ;
297+ config . baseConfig . extends = config . baseConfig . extends . concat ( 'prettier/unicorn' ) ;
292298 // The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
293299 config . rules [ 'prettier/prettier' ] = [
294300 'error' , mergeWithPrettierConfig ( options , prettier . resolveConfig . sync ( options . cwd || process . cwd ( ) ) || { } )
295301 ] ;
296302 // If the user has the React, Flowtype, or Standard plugin, add the corresponding Prettier rule overrides
297303 // 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 ) ;
301307 }
302308 }
303309 }
0 commit comments