Skip to content
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

chore: improve Ecosystem.md linter to check for improper module name patterns #4257

Merged
merged 5 commits into from Sep 7, 2022

Conversation

nooreldeensalah
Copy link
Contributor

@nooreldeensalah nooreldeensalah commented Sep 7, 2022

Improve ecosystem linting script by returning an error in case of an improperly added module name pattern (i.e., not enclosed with backticks)

Resolves #4256

Checklist

Improve ecosystem linting script by returning an error in case of an improperly added module name pattern (i.e., not enclosed with backticks)
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +30 to 32
if (inCommunitySection === false) {
continue
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to point out that the script currently only lints the modules in the #### [Community] section, it doesn't lint modules in either #### [Community Tools] or #### [Core] sections

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've re-arranged the order of the conditionals to make the script check for misformatted patterns in all sections, but it only checks for ordering in the community section (the previously existing behavior before I add any changes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll keep this comment unresolved, feel free to resolve it if you don't have any comments regarding this

@nooreldeensalah nooreldeensalah changed the title chore: improve Ecosystem.md linting script chore: improve Ecosystem.md linter to check for improper module name patterns Sep 7, 2022
Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Please reduce the change set to only solve the issue being addressed. Fixing the misspelling is okay, but changing around the logic makes it difficult to review the proposed change.

@nooreldeensalah
Copy link
Contributor Author

nooreldeensalah commented Sep 7, 2022

Please reduce the change set to only solve the issue being addressed. Fixing the misspelling is okay, but changing around the logic makes it difficult to review the proposed change.

The change set only addresses the issue of checking for improperly formatted module names (specifically, module names missing either or both the backticks, as in the linked issue)

I can try to make a self-review to attempt to clarify the changes in case they aren't clear, but the overall code changes can be summarized as follows:

  • Fixed the misspelling
  • Checking for improperly formatted modules in all sections (Core, Community, Community Tools)
  • Reduced the startsWith argument for detecting lines containing module names to '- [' instead of '- [`' (Notice the missing starting backtick), my justification is to be able to detect for all scenarios of bad backticks formatting (instead of being only able to detect the missing ending backtick only), but I haven't changed the regex pattern itself.
    • Missing starting backtick
    • Missing ending backtick
    • Missing both starting and ending backticks
  • Not a change per se, but I've changed the scope of moduleName to be a global one, to be able to use the result of the regex test it in this conditional block (https://github.com/nooreldeensalah/fastify/blob/70027c57c12c64d0846fa415a7ce2e6c007472e2/.github/scripts/lint-ecosystem.js#L27-L35) that checks for the ill-formatted patterns (which constitutes most of the logic in the set of changes) and to use the result (the value of the regex test) in the conditional block checking for ordering as well.
    • The continue statement (Line 34) is to avoid adding the value undefined (i.e., the result of a failed regex check due to a bad pattern) to the array of modules and order checking altogether.

Hope this comment clarifies the changes better now in case of checking the individual commits is unclear

@jsumners
Copy link
Member

jsumners commented Sep 7, 2022

The issue at hand is #4256 in which want verify that items are formatted as

- [`foo`] bar

instead of allowing - [foo] bar. Please keep the PR narrowed to that specific issue instead of changing around which sections are verified and other items.

@nooreldeensalah
Copy link
Contributor Author

nooreldeensalah commented Sep 7, 2022

The change set addresses this specific issue only, but I've had to make a few changes to address the issue, and I've attempted to clarify them in my comment, which code blocks in your opinion are irrelevant, so I can remove them?

I might try to make the diff as small as possible (perhaps removing the line breaks I've added and to use a local scope for moduleName but that would require doing the regex check twice 😅)

Btw, I've used https://github.com/nektos/act to test and run the script locally

@jsumners
Copy link
Member

jsumners commented Sep 7, 2022

The change set addresses this specific issue only, but I've had to make a few changes to address the issue, and I've attempted to clarify them in my comment, which code blocks in your opinion are irrelevant, so I can remove them?

You stated:

I wanted to point out that the script currently only lints the modules in the #### [Community] section, it doesn't lint modules in either #### [Community Tools] or #### [Core] sections

And:

I've re-arranged the order of the conditionals to make the script check for misformatted patterns in all sections, but it only checks for ordering in the community section (the previously existing behavior before I add any changes)

This has resulted in a difficult to read change set in regards to the issue purportedly being solved, as I have outlined. Please do not change the functionality of the script in this pull request, and limit it fixing the line validation what was previously being performed.

@nooreldeensalah
Copy link
Contributor Author

I apologize if this is the source of confusion, but I've made this comment when I had only the first commit 8ee1fc5, (notice that the conditional block was at the bottom).

So, I was stating the general functionality of the script, and I've stated that it currently only checks for bad module formats (but it was limited to Community section only), so I've just moved the block up (before the conditional used to check for community section to account for all the sections, but I haven't altered/removed any previously existing functionality. If this is still an issue, I can drop the remaining commits and keep the first one if you wish

@nooreldeensalah
Copy link
Contributor Author

nooreldeensalah commented Sep 7, 2022

This has resulted in a difficult to read change set in regards to the issue purportedly being solved, as I have outlined. Please do not change the functionality of the script in this pull request, and limit it fixing the line validation what was previously being performed.

I've reverted back to a previous state, the script now is limited to the Community section (i.e., neither lines in Core, nor Community Tools will be validated)

Hopefully this is more clear, but if you wish that I drop the final commit (i.e., the revert commit), I can do so, but I've done this to make it the diff as small as possible, so you can easily review it.

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me.

continue
}

if (line.startsWith('- [`') !== true) {
if (line.startsWith('- [') !== true) {
Copy link
Member

Choose a reason for hiding this comment

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

Okay, this makes sense. We were just skipping the line if it started like - [f.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, cases like - [foo], - [foo`] were undetectable.
In regard to extending the script functionality, do you wish that I make another commit with it? (as I stated, Core and Community Tools were being validated, but I've reverted this part in my last commit)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that would be a new pull request with an improvement. I originally left those out because they are generally only added by the core Fastify team. We don't usually have out-of-order issues with those. But it doesn't hurt to add the validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright then, should I then open another PR with this state? 70027c57c1 (i.e., before the revert commit). Or are there any other changes you would like to point out to?

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather just review the feature in isolation instead of trying to pick it out of other changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've opened another PR at #4258

@jsumners jsumners merged commit af27b78 into fastify:main Sep 7, 2022
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ecosystem script check
3 participants