embroider-build / addon-blueprint

Blueprint for v2-formatted Ember addons
MIT License
29 stars 27 forks source link

Align Prettier configuration between Ember CLI and Embroider addon blueprints #246

Open jelhan opened 8 months ago

jelhan commented 8 months ago

I noticed a mismatch of the Prettier config between Ember CLI and Embroider addon blueprint.

Embroider addon blueprint configures Prettier to use single quotes for every file type: https://github.com/embroider-build/addon-blueprint/blob/b1168b4616adf748bd713c5af39e104325982e9b/files/.prettierrc.cjs#L3-L6 https://github.com/embroider-build/addon-blueprint/blob/b1168b4616adf748bd713c5af39e104325982e9b/files/__addonLocation__/.prettierrc.cjs#L3-L6

Ember CLI blueprints configure Prettier to use single quotes only for JavaScript and TypeScript files: https://github.com/ember-cli/ember-cli/blob/f824a6aee6e804fe4584fb037e893e3bbf93370a/blueprints/app/files/.prettierrc.js#L3-L12

I think both should be aligned.

Embroider addon blueprint supports template tag out of the box. So we need to extend Ember CLI's Prettier configuration to support .gjs and *.gts files as well. I think it should look like the following:

module.exports = {
  overrides: [
    {
      files: '*.{js,ts,gjs,gts}',
      options: {
        singleQuote: true,
      },
    },
  ],
};

If there aren't any concerns against implementing it, I can try providing a PR this week.

aklkv commented 8 months ago

Currently, we have double quotes in on all template files, to keep it this way in v2 addon we might want to have the following config:

module.exports = {
  plugins: ['prettier-plugin-ember-template-tag'],
  templateSingleQuote: false,
  overrides: [
    {
      files: '*.{js,ts,gjs,gts}',
      options: {
        singleQuote: true,
      },
    },
  ],
};