-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add "banana in a box" rule #322
Conversation
Haha, I love the error messages. Would be awesome if we're able to introduce this rule as part of the next release as well! |
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.
Added some initial comments. Great job!
src/bananaInBoxRule.ts
Outdated
|
||
const getReplacements = (text: ast.BoundEventAst, absolutePosition: number) => { | ||
const expr: string = (text.sourceSpan as any).toString(); | ||
const internalStart = expr.indexOf('(['); |
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.
Let's use the constants defined above.
src/bananaInBoxRule.ts
Outdated
import {NgWalker} from './angular/ngWalker'; | ||
|
||
|
||
const BoxInABananaOpen = '(['; |
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.
Lets rename it to ValidSyntaxOpen
or something similar. I'm getting confused reading BoxInABanana*
, wondering if that was the valid or invalid syntax.
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.
Sure. Done
templateVisitorCtrl: BananaInBoxTemplateVisitor, | ||
})); | ||
} | ||
} |
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.
Newline.
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/bananaInBoxRule.ts
Outdated
let error = null; | ||
const expr: any = (<any>prop.sourceSpan).toString(); | ||
if (BoxInABananaRe.test(expr)) { | ||
error = 'The box is in a banana! Expecting Banana in a box [(expr)]'; |
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.
This warning message is fun but lets change it to something like: "Invalid binding syntax. Use [(expr)] instead".
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.
No problem ;) . Done
Thanks! Will take a look tomorrow & merge/comment. |
Part of #314