An open API service indexing awesome lists of open source software.

https://github.com/cjmarkham/gherklin

A modern linter for Gherkin, using TypeScript and ESM
https://github.com/cjmarkham/gherklin

cucumber cucumber-js cucumberjs gherkin gherkin-files gherkin-language gherkin-lint lint linter linting

Last synced: 7 months ago
JSON representation

A modern linter for Gherkin, using TypeScript and ESM

Awesome Lists containing this project

README

        

#!/bin/node

import { readdirSync, readFileSync } from 'node:fs'

const fileLocation = './src/rules/README.md'
const rules = readdirSync('./src/rules')
.filter((f) => f !== 'README.md' && f !== 'index.ts')
.map((r) => r.replace('.ts', ''))

const content = readFileSync(fileLocation, { encoding: 'utf-8' })
const errors: Array = []

rules.forEach((rule) => {
const smallWords = ['at', 'in']
const largeWords = ['eof']

const ruleTitlized = rule
.split('-')
.map((p) => {
if (smallWords.includes(p)) {
return p.toLowerCase()
}
if (largeWords.includes(p)) {
return p.toUpperCase()
}
return `${p.charAt(0).toUpperCase()}${p.slice(1, p.length)}`
})
.join(' ')

// Look for the rule in the table
const tableIndex = content.indexOf(`[${ruleTitlized}](#${rule})`)
if (tableIndex === -1) {
errors.push(`\u001b[91mCould not find rule ${rule} in README index\u001b[0m`)
}

const index = content.indexOf(`### ${ruleTitlized}`)
if (index === -1) {
errors.push(`\u001b[91mCould not find entry for ${ruleTitlized} in README\u001b[0m`)
}
})

if (errors.length) {
console.error(errors.join('\n'))
process.exit(1)
}

process.exit(0)