-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Changes from 1 commit
8ee1fc5
02c9286
08d429d
70027c5
970e49c
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 |
---|---|---|
|
@@ -16,26 +16,33 @@ module.exports = async function ({ core }) { | |
const moduleNameRegex = /^\- \[\`(.+)\`\]/ | ||
let hasOutOfOrderItem = false | ||
let lineNumber = 0 | ||
let inCommmunitySection = false | ||
let inCommunitySection = false | ||
let modules = [] | ||
|
||
for await (const line of rl) { | ||
lineNumber += 1 | ||
if (line.startsWith('#### [Community]')) { | ||
inCommmunitySection = true | ||
inCommunitySection = true | ||
} | ||
if (line.startsWith('#### [Community Tools]')) { | ||
inCommmunitySection = false | ||
inCommunitySection = false | ||
} | ||
if (inCommmunitySection === false) { | ||
if (inCommunitySection === false) { | ||
continue | ||
} | ||
|
||
if (line.startsWith('- [`') !== true) { | ||
if (line.startsWith('- [') !== true) { | ||
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. Okay, this makes sense. We were just skipping the line if it started like 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. Indeed, cases like 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. 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. 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. Alright then, should I then open another PR with this state? 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. I'd rather just review the feature in isolation instead of trying to pick it out of other changes. 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. I've opened another PR at #4258 |
||
continue | ||
} | ||
|
||
const moduleName = moduleNameRegex.exec(line)[1] | ||
const moduleNameTest = moduleNameRegex.exec(line) | ||
|
||
if (moduleNameTest === null) | ||
{ | ||
return core.setFailed(`line ${lineNumber}: improper pattern, module name should be enclosed with backticks`) | ||
} | ||
|
||
const moduleName = moduleNameTest[1] | ||
if (modules.length > 0) { | ||
if (compare(moduleName, modules.at(-1)) > 0) { | ||
core.error(`line ${lineNumber}: ${moduleName} not listed in alphabetical order`) | ||
|
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 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]
sectionsThere 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'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)
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'll keep this comment unresolved, feel free to resolve it if you don't have any comments regarding this