Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Add a warning for databinding to undeclared properties/attributes #35

Merged
merged 10 commits into from
Feb 25, 2017

Conversation

rictic
Copy link
Contributor

@rictic rictic commented Feb 23, 2017

  • CHANGELOG.md has been updated

Fixes #25


This change is Reviewable

@rictic rictic force-pushed the bind-to-undeclared branch 2 times, most recently from f6ce6fd to f1496f3 Compare February 23, 2017 21:23
const propertyOptions = element.properties.map((a) => a.name)
.concat(Array.from(sharedProperties.keys()));
const closestAttribute =
minBy(attributeOptions, (option) => levenshtein.get(name, option));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

CHANGELOG.md Outdated
element.

This catches misspellings, forgetting to convert camelCase to kebab-case,
and binding to attributes like class and style like they were properties.Warns when setting an unknown attribute or property on a custom element in a polymer databinding template. Catches misspellings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

properties.\n Warns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



export class BindToUndeclaredAttributes extends HtmlRule {
code = 'unknown-set-attribute';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this code so different from the rule class name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, updated

@rictic rictic force-pushed the bind-to-undeclared branch from bd8587f to abefc4b Compare February 24, 2017 16:11
@rictic rictic changed the base branch from master to unbalanced-delimitors February 24, 2017 16:11
@rictic rictic force-pushed the unbalanced-delimitors branch from 32dc95c to 40ef567 Compare February 24, 2017 16:12
@rictic rictic force-pushed the bind-to-undeclared branch from abefc4b to 609bcdd Compare February 24, 2017 16:13
@rictic
Copy link
Contributor Author

rictic commented Feb 24, 2017

Comments addressed. Also now understands and correctly lints setting attributes outside a polymer databinding context too.

Copy link
Contributor

@usergenic usergenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rictic rictic merged commit fc6ae8e into unbalanced-delimitors Feb 25, 2017
@rictic rictic deleted the bind-to-undeclared branch February 25, 2017 01:03
rictic added a commit that referenced this pull request Feb 25, 2017
* Add two known failures in expression parsing to integration tests.

* Warn when binding to undeclared attributes and properties.

* Add test, suggest nearest spelling when no attribute found.

* Fix the warning for data-* attributes.

* Add issue for TODO

* Update CHANGELOG, improve documentation

* Remove TODO for implemented feature.

* Update integration test with new rule code.

* Use consistent naming, also check attributes outside polymer databindings.

* Update integration tests
rictic added a commit that referenced this pull request Feb 25, 2017
* Add two known failures in expression parsing to integration tests.

* Warn when binding to undeclared attributes and properties.

* Add test, suggest nearest spelling when no attribute found.

* Fix the warning for data-* attributes.

* Add issue for TODO

* Update CHANGELOG, improve documentation

* Remove TODO for implemented feature.

* Update integration test with new rule code.

* Use consistent naming, also check attributes outside polymer databindings.

* Update integration tests
rictic added a commit that referenced this pull request Feb 25, 2017
* Add two known failures in expression parsing to integration tests.

* Warn when binding to undeclared attributes and properties.

* Add test, suggest nearest spelling when no attribute found.

* Fix the warning for data-* attributes.

* Add issue for TODO

* Update CHANGELOG, improve documentation

* Remove TODO for implemented feature.

* Update integration test with new rule code.

* Use consistent naming, also check attributes outside polymer databindings.

* Update integration tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants