aurelia / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
56 stars 17 forks source link

Support custom elements that generate local variables #156

Closed RomkeVdMeulen closed 7 years ago

RomkeVdMeulen commented 7 years ago

Currently I'm getting a lot of mistaken warnings from templates that use our datagrid. They look something like this:

<datagrid rows.bind="myData">
  <column header="ID" field="id"></kolom>
  <column header="Name">
    <a href.bind="row.detailUrl">${row.name}</a>
  </kolom>
</datagrid>

which gives warnings like:

WARNING: cannot find 'row' in type 'MyComponent'

The row variable is provided by the Datagrid. Type analysis won't find it though: the Datagrid generates and compiles its own template.

I was thinking the best way to solve this would be to add this to my config:

config.aureliaBindingAccessOpts.localProvidors.concat("datagrid");

However, this doesn't help. Reading the docs more closely I see that localProvidors only works with attributes.

It would be great if localProvidors could also accept elements, and warnings about variables no be thrown from inside these elements.

Even better would be if I could specify a precise list of variables available within each element, but that may be another story for another day.

MeirionHughes commented 7 years ago

bolted on something for you to add local overrides for now. will need a more comprehensive fix at some point.

https://github.com/MeirionHughes/aurelia-template-lint/blob/b8fe917b6ce7feabfa1fc03c2325ad1046121d06/source/config.ts#L139

https://github.com/MeirionHughes/aurelia-template-lint/blob/b8fe917b6ce7feabfa1fc03c2325ad1046121d06/spec/triage.spec.ts#L288

published: 0.9.22

RomkeVdMeulen commented 7 years ago

Thanks! This works great. Could you publish a release of gulp-aurelia-template-lint with this change as well?

MeirionHughes commented 7 years ago

Shouldn't need it? gulp-aurelia-template-lint is locked to aurelia-template-lint @ 0.9.x, npm install aurelia-template-lint to force the update. :)

RomkeVdMeulen commented 7 years ago

Ah: I ran yarn upgrade gulp-aurelia-template-lint, figuring that would also upgrade the dependencies, but that isn't the case. Learned something new.