-
Notifications
You must be signed in to change notification settings - Fork 11
Add a warning for databinding to undeclared properties/attributes #35
Conversation
f6ce6fd
to
f1496f3
Compare
src/polymer/bind-to-undeclared.ts
Outdated
const propertyOptions = element.properties.map((a) => a.name) | ||
.concat(Array.from(sharedProperties.keys())); | ||
const closestAttribute = | ||
minBy(attributeOptions, (option) => levenshtein.get(name, option)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
properties.\n Warns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/polymer/bind-to-undeclared.ts
Outdated
|
||
|
||
export class BindToUndeclaredAttributes extends HtmlRule { | ||
code = 'unknown-set-attribute'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, updated
bd8587f
to
abefc4b
Compare
32dc95c
to
40ef567
Compare
abefc4b
to
609bcdd
Compare
Comments addressed. Also now understands and correctly lints setting attributes outside a polymer databinding context too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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
* 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
* 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
Fixes #25
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)