Skip to content

Commit

Permalink
[chore] Add test to detect duplicate rule id (#2141)
Browse files Browse the repository at this point in the history
* Add test to detect duplicate rule id

* Simplify duplicate testing
  • Loading branch information
Jym77 authored Jan 10, 2024
1 parent 5e2e06a commit bb7e4c5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions _rules/__tests__/unique-ids.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const getMarkdownData = require('../../utils/get-markdown-data')
const rulesData = getMarkdownData(`./_rules`)

describe('Rule ids verification', () => {
const duplicates = rulesData.filter(
(ruleData, idx) => rulesData.findIndex(r => r.frontmatter.id === ruleData.frontmatter.id) !== idx
)

test('Rule ids are unique', () => {
expect(duplicates.length, `Duplicated rules: ${duplicates.map(ruleData => ruleData.filename).join(', ')}`).toBe(0)
})
})

0 comments on commit bb7e4c5

Please sign in to comment.