-
Notifications
You must be signed in to change notification settings - Fork 11
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 requireTypeCheck option to guard-super-call #135
base: master
Are you sure you want to change the base?
Conversation
}, | ||
|
||
create(context): Rule.RuleListener { | ||
let insideNonNativeElement = false; | ||
let errNode = null; | ||
const source = context.getSourceCode(); | ||
const options = context.options?.[0] ?? {}; | ||
const requireTypeCheck = options.requireTypeCheck ?? false; |
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.
its probably better to just compare here, like options.requireTypeCheck === true
} | ||
}, | ||
schema: [{ | ||
requireTypeCheck: {type: 'boolean'} |
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 object is meant to have a type i think, like:
schema: [
{
type: 'object',
properties: {
requireTypeCheck: {type: 'boolean'}
}
}
]
@@ -100,7 +119,11 @@ const rule: Rule.RuleModule = { | |||
if (isSuperHookExpression(node, hook)) { | |||
errNode = node; | |||
return true; | |||
} else if (node.type === 'IfStatement' && !isSuperHook(node.test, hook)) { |
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.
i think i'd leave this as it is and just change isSuperHook
to accept an extra requireTypeCheck
parameter
inside isSuperHook
, we could then:
if (requireTypeCheck) {
return /* whatever a type checked super hook looks like */
}
return /* whatever a regular super hook looks like */
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.
can we also add some tests? 👀
This fixes #134.