-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix(eslint-plugin): [method-signature-style] don't auto-fix interfaces within namespaces #2678
fix(eslint-plugin): [method-signature-style] don't auto-fix interfaces within namespaces #2678
Conversation
Signed-off-by: Moulik Aggarwal <[email protected]>
Thanks for the PR, @aggmoulik! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
…ipt-eslint into method-signature
Fixes #2340 |
Signed-off-by: Moulik Aggarwal <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #2678 +/- ##
==========================================
- Coverage 92.82% 92.79% -0.04%
==========================================
Files 294 294
Lines 9670 9682 +12
Branches 2712 2717 +5
==========================================
+ Hits 8976 8984 +8
- Misses 328 330 +2
- Partials 366 368 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Moulik Aggarwal <[email protected]>
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.
the logic itself LGTM - just two comments.
thanks for working on this!
function isNodeParentModuleDeclaration(node: any): boolean { | ||
if (node.parent?.type === AST_NODE_TYPES.TSModuleDeclaration) { | ||
return true; | ||
} | ||
|
||
if (node.parent?.type === AST_NODE_TYPES.Program) { | ||
return false; | ||
} | ||
return isNodeParentModuleDeclaration(node.parent); | ||
} |
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.
We can remove the any
here with the catch-all Node
type
function isNodeParentModuleDeclaration(node: any): boolean { | |
if (node.parent?.type === AST_NODE_TYPES.TSModuleDeclaration) { | |
return true; | |
} | |
if (node.parent?.type === AST_NODE_TYPES.Program) { | |
return false; | |
} | |
return isNodeParentModuleDeclaration(node.parent); | |
} | |
function isNodeParentModuleDeclaration(node: TSESTree.Node): boolean { | |
if (!node.parent) { | |
return false; | |
} | |
if (node.parent.type === AST_NODE_TYPES.TSModuleDeclaration) { | |
return true; | |
} | |
if (node.parent.type === AST_NODE_TYPES.Program) { | |
return false; | |
} | |
return isNodeParentModuleDeclaration(node.parent); | |
} |
code: noFormat` | ||
declare global { | ||
namespace jest { | ||
interface Matchers<R, T> { | ||
// Add overloads specific to the DOM | ||
toHaveProp<K extends keyof DomPropsOf<T>>(name: K, value?: DomPropsOf<T>[K]): R; | ||
toHaveProps(props: Partial<DomPropsOf<T>>): R; | ||
} | ||
} | ||
} | ||
`, |
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.
indent the example one line, and then you can use the fixer to auto-format the code block
code: noFormat` | |
declare global { | |
namespace jest { | |
interface Matchers<R, T> { | |
// Add overloads specific to the DOM | |
toHaveProp<K extends keyof DomPropsOf<T>>(name: K, value?: DomPropsOf<T>[K]): R; | |
toHaveProps(props: Partial<DomPropsOf<T>>): R; | |
} | |
} | |
} | |
`, | |
code: ` | |
declare global { | |
namespace jest { | |
interface Matchers<R, T> { | |
// Add overloads specific to the DOM | |
toHaveProp<K extends keyof DomPropsOf<T>>(name: K, value?: DomPropsOf<T>[K]): R; | |
toHaveProps(props: Partial<DomPropsOf<T>>): R; | |
} | |
} | |
} | |
`, |
…ode reviews Signed-off-by: Moulik Aggarwal <[email protected]>
Signed-off-by: Moulik Aggarwal <[email protected]>
…-eslint into method-signature
Hy @bradzacher , I have updated things you suggested. |
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 - thanks for your contribution!
Hy @bradzacher, Can you please add |
I thought they only need a tag if they weren't going to be merged in October? |
Fixes #2340
Signed-off-by: Moulik Aggarwal [email protected]