#ember/no-empty-glimmer-component-classes in .gts files

1 messages · Page 1 of 1 (latest)

deft anchor
#

Hi all,

I am trying to create new components as .gts but I have a few cases where they are only template. Now I usually still create a class since I need to define the Signature for glint. How do I properly handle the ember/no-empty-glimmer-component-classes linting rule in that case? Ignore or some template-only helper for .gts?

fierce vessel
#

You can define a template only component signature too.
You can use an lint ignore directive or just turn that rule off completely.

inland tulip
#

my2c:

  • There are some speed advantages to template only components
  • Your app is very likely not going to have an issue without this anyway
  • It's annoying to see lint annoyances from the get-go for things that you don't really care about
    ==> Disable globally (DX is important)
formal hamlet
#

@deft anchor you can still provide Signatures for template only componens through </template> satisfies TOC<MySignature> at the end

deft anchor
#

Thanks! @formal hamlet 's suggestion works well:

import { type TOC } from '@ember/component/template-only';

export interface CellSignature {
  Blocks: {
    default: [];
  };
}

const component = <template>
  <div class="d-flex py-1">
    {{yield}}
  </div>
</template> satisfies TOC<CellSignature>;

export default component;
fierce vessel
#

Pretty sure that can just be this

import { type TOC } from '@ember/component/template-only';

export interface CellSignature {
  Blocks: {
    default: [];
  };
}

<template>
  <div class="d-flex py-1">
    {{yield}}
  </div>
</template> satisfies TOC<CellSignature>;
deft anchor
#

glint then complains about missing default export when importing that component

fierce vessel
#

hm, it should be auto exported but you can add export default infront of the <template>

inland tulip
#

Tangential, but: Why? Why does glimmer auto-export? AFAIK JS ecosystem does not do this. So why deviate?

fierce vessel
#

I would tend to agree, as do others. It's under discussion.

marble schooner
inland tulip
# marble schooner We already deviate via custom syntax. It's only come up recently because glint i...

I skimmed through the conversation and will write my more elaborate answer later, but I do see this as problematic, I don't think that "we deviate already" has any weight here as people do-do pattern matching (I did and that's why I asked) and then are confused when same-same-but-different happens. We can also do the export if the mod13() of the amount of the letters of the template would be an odd number, but we don't because we can clearly tell it's confusing. This case, to me, is similar, just less in the face. If we have problem with export default ..., then let's do something that will tell the user that something special is expected to happen. </rant>

marble schooner
#

do something that will tell ..

How do you mean?