-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a rule to require the @logger decorator #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,54 @@ ruleTester.run("component-prefix", plugin.rules["component-prefix"], { | |
} | ||
] | ||
}); | ||
|
||
const isNotAComponent = ` | ||
export class ManifoldSelect { | ||
@Prop() answer: number; | ||
|
||
render() { | ||
return null; | ||
} | ||
}`; | ||
|
||
const componentMissingLogger = ` | ||
import { h, Component, Prop } from '@stencil/core'; | ||
|
||
@Component({ tag: 'quux-component' }) | ||
export class ManifoldSelect { | ||
@Prop() answer: number = 42; | ||
|
||
render() { | ||
return null; | ||
} | ||
}`; | ||
|
||
const componentWithLogger = ` | ||
import { h, Component, Prop } from '@stencil/core'; | ||
|
||
@Component({ tag: 'quux-component' }) | ||
export class ManifoldSelect { | ||
@Prop() answer: number = 42; | ||
|
||
@logger() | ||
render() { | ||
return null; | ||
} | ||
}`; | ||
|
||
ruleTester.run("require-logger", plugin.rules["require-logger"], { | ||
valid: [ | ||
{ | ||
code: isNotAComponent | ||
}, | ||
{ | ||
code: componentWithLogger | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: componentMissingLogger, | ||
errors: [{ messageId: "loggerMissing" }] | ||
} | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is so great—testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah! In fact you have to include both valid and invalid examples, otherwise the test will throw an error. |
||
}); |
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.
So this doesn’t get evaluated by JS, because
@stencil/core
isn’t a dependency? The ESLint parser supports decorators and stuff out-of-the-box?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.
Yeah, there's no evaluation here, only parsing the text into nodes. And yes, decorators are supported out of the box!