Skip to content

Extract isDefinition helper #196

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

Merged
merged 1 commit into from
Oct 28, 2022
Merged

Extract isDefinition helper #196

merged 1 commit into from
Oct 28, 2022

Conversation

valerybugakov
Copy link
Member

This PR improves the readability of the isDefinition logic. Follow-up on this comment.

Test plan

Tests are green, and the comment on the isDefinition function looks ok.

@valerybugakov valerybugakov self-assigned this Oct 28, 2022
@@ -10,5 +10,7 @@ module.exports = {
ignorePatterns: ['temp', 'scip.ts', 'snapshots'],
rules: {
'no-sync': 'off',
'jsdoc/check-indentation': 'off',
'class-methods-use-this': 'error',
Copy link
Member Author

@valerybugakov valerybugakov Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up on this comment by @varungandhi-src. This rule forbids class methods without instance context usage. @olafurpg, let me know what you think about that!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. Big +1 from me

@@ -707,3 +681,46 @@ function isEqualArray<T>(a: T[], b: T[]): boolean {
}
return true
}

function declarationName(node: ts.Node): ts.Node | undefined {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted into an independent function to satisfy the class-methods-use-this ESLint rule.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big improvement in readability to have a toplevel function instead of an instance method.

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 Very nice!

@@ -10,5 +10,7 @@ module.exports = {
ignorePatterns: ['temp', 'scip.ts', 'snapshots'],
rules: {
'no-sync': 'off',
'jsdoc/check-indentation': 'off',
'class-methods-use-this': 'error',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. Big +1 from me

@@ -707,3 +681,46 @@ function isEqualArray<T>(a: T[], b: T[]): boolean {
}
return true
}

function declarationName(node: ts.Node): ts.Node | undefined {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big improvement in readability to have a toplevel function instead of an instance method.

@olafurpg olafurpg merged commit e17a427 into main Oct 28, 2022
@olafurpg olafurpg deleted the vb/is-definition-function branch October 28, 2022 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants