aurelia / template-lint

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

New rule for Aurelia plugins(and server side rendering): fail when using globals, that don't work with aurelia-pal-nodejs #181

Open atsu85 opened 6 years ago

atsu85 commented 6 years ago

Motivation

To be able to run Aurelia code on NodeJS (with aurelia-pal-nodejs) in addition to running it in browser, using browser globals (such as window and browser DOM Element) directly should be avoided - instead they should used via Aurelia Platform Abstraction Layer aurelia-pal instead. It would be great if this project could help Aurelia ecosystem to get ready for running code on NodeJS in addtion to browser.

Example

Instead of Element plugins should use DOM.Element and instead of window.Intl they should use PLATFORM.global.Intl (as You can see in this fix for aurelia-i18n plugin related to this bug report)

zewa666 commented 6 years ago

Fully support that, whatever can be automated ist a definitiv win

gheoan commented 6 years ago

Maybe this is better suited for the eslint aurelia plugin. https://github.com/bryanrsmith/eslint-plugin-aurelia

aluanhaddad commented 6 years ago

@zewa666 indubitably.

@gheoan that plugin lints code outside of templates. Are these functions in some when evaluating template bindings? I didn't think they were.

eslint and tslint both allow banning arbitrary globals

*eslint

*tslint

gheoan commented 6 years ago

Global values can be used in templates using view engine hooks, which are implemented in script. So this can be solved by linting the script using eslint or tslint

aluanhaddad commented 6 years ago

I see I didn't know about those hooks. Thank you for explaining.