gitKrystan / prettier-plugin-ember-template-tag

A prettier plugin for formatting Ember template tags
MIT License
22 stars 12 forks source link

[Bug] Breaks @trivago/prettier-plugin-sort-imports #62

Closed evoactivity closed 1 year ago

evoactivity commented 1 year ago

🐞 Describe the Bug

If the parser for a gts file is set to 'ember-template-tag' then @trivago/prettier-plugin-sort-imports does not run.

If parser is set to typescript and the <template/> tag is removed @trivago/prettier-plugin-sort-imports will run.

🔬 Minimal Reproduction

Describe steps to reproduce. If possible, please create a PR with a failing test as described in CONTRIBUTING.md.

😕 Actual Behavior

@trivago/prettier-plugin-sort-imports is not run

🤔 Expected Behavior

@trivago/prettier-plugin-sort-imports is run as part of prettier action.

🌍 Environment

This is my .prettierrc.js

'use strict';

module.exports = {
  semi: true,
  singleQuote: true,
  useTabs: false,
  quoteProps: 'consistent',
  bracketSpacing: true,
  arrowParens: 'always',
  printWidth: 120,
  plugins: ['@trivago/prettier-plugin-sort-imports', 'prettier-plugin-ember-template-tag'],
  importOrder: ['web', '^node:(.*)$', '^@glimmer/(.*)$', '^@ember/(.*)$', '<THIRD_PARTY_MODULES>', '^[./]'],
  importOrderSeparation: false,
  importOrderSortSpecifiers: true,
  importOrderGroupNamespaceSpecifiers: true,
  importOrderCaseInsensitive: true,
  importOrderParserPlugins: ['typescript', '["decorators", { "decoratorsBeforeExport": true }]'],
  overrides: [
    {
      files: '*.gjs',
      options: {
        parser: 'ember-template-tag',
      },
    },
    {
      files: '*.gts',
      options: {
        parser: 'ember-template-tag',
      },
    },
  ],
};

➕ Additional Context

Vue is supported by adding a preprocessor to the plugin https://github.com/trivago/prettier-plugin-sort-imports/blob/main/src/preprocessors/vue-preprocessor.ts

I'm not sure if that would be the fix here. Feels like it needs the template tag to be processed before it can operate. If that does seem to be the case I'll open an issue on the sort imports plugin.