Skip to content

Commit

Permalink
chore: improve Ecosystem.md linter to validate all sections
Browse files Browse the repository at this point in the history
  • Loading branch information
nooreldeensalah committed Sep 7, 2022
1 parent af27b78 commit c79a22c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions .github/scripts/lint-ecosystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,29 @@ module.exports = async function ({ core }) {
let inCommunitySection = false
let modules = []
let hasImproperFormat = false
let moduleName

for await (const line of rl) {
lineNumber += 1

if (line.startsWith('- [') === true) {
moduleName = moduleNameRegex.exec(line)?.[1]
if (moduleName === undefined)
{
core.error(`line ${lineNumber}: improper pattern, module name should be enclosed with backticks`)
hasImproperFormat = true
continue
}
}

if (line.startsWith('#### [Community]')) {
inCommunitySection = true
}

if (line.startsWith('#### [Community Tools]')) {
inCommunitySection = false
}

if (inCommunitySection === false) {
continue
}
Expand All @@ -36,16 +50,6 @@ module.exports = async function ({ core }) {
continue
}

const moduleNameTest = moduleNameRegex.exec(line)

if (moduleNameTest === null)
{
core.error(`line ${lineNumber}: improper pattern, module name should be enclosed with backticks`)
hasImproperFormat = true
continue
}

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`)
Expand All @@ -58,7 +62,7 @@ module.exports = async function ({ core }) {
if (hasOutOfOrderItem === true) {
core.setFailed('Some ecosystem modules are not in alphabetical order.')
}

if (hasImproperFormat === true) {
core.setFailed('Some ecosystem modules are improperly formatted.')
}
Expand Down

0 comments on commit c79a22c

Please sign in to comment.