brodycj / prettierx

a less opinionated fork of Prettier code formatter
MIT License
209 stars 22 forks source link

How to use presets from eslint-plugin-prettierx configuration? #469

Open ronag opened 3 years ago

ronag commented 3 years ago

I have the following eslint config which works fine.

    "plugins": [
      "prettierx",
      "node",
      "promise"
    ],
    "extends": [
      "eslint:recommended",
      "plugin:prettierx/standardx",
      "plugin:promise/recommended",
      "plugin:node/recommended"
    ],

How do I setup prettierx to grab the configuration from here during formatting? Or do I have to duplicate it in a prettierrc file or something?

brodycj commented 3 years ago

Hi I took the liberty to rewrite the title.

I think it should be possible to make a prettier.config.js file that will grab the configuration from eslint-config-prettierx. It would be ideal to make this a shareable config. Here is the documentation: https://prettier.io/docs/en/configuration.html

I suspect it would be easier to configure prettierx in the prettierrc file and configure eslint-plugin-prettierx to use the same configuration.

/cc @aMarCruz

ronag commented 3 years ago

Even if I don't read the config and create a duplicate. How do I create a corresponding config? Does prettier configs support extends?

brodycj commented 3 years ago

See the note at the end of https://prettier.io/docs/en/configuration.html#sharing-configurations:

Note: This method does not offer a way to extend the configuration to overwrite some properties from the shared configuration. If you need to do that, import the file in a .prettierrc.js file and export the modifications, e.g:

module.exports = {
  ...require("@company/prettier-config"),
  semi: false,
};

I would love to make the Prettier stack more pluggable and extensible but am not in a position to make this a priority as a lone freelancer :)

ronag commented 3 years ago

Thanks. Feel free to close.

aMarCruz commented 3 years ago

@ronag , @brodybits , sorry by the delay.

DELETED, THIS COMMENT IS NOT VALID FOR eslint-plugin-prettierx 😖