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
- Host: GitHub
- URL: https://github.com/cjmarkham/gherklin
- Owner: cjmarkham
- License: isc
- Created: 2024-08-22T09:36:10.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-02T02:13:58.000Z (7 months ago)
- Last Synced: 2024-12-02T02:41:45.450Z (7 months ago)
- Topics: cucumber, cucumber-js, cucumberjs, gherkin, gherkin-files, gherkin-language, gherkin-lint, lint, linter, linting
- Language: TypeScript
- Homepage: https://gherklin.com
- Size: 837 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: .github/readme-checker.ts
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
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)