-
Notifications
You must be signed in to change notification settings - Fork 28k
/
Copy pathindex.test.ts
29 lines (24 loc) · 932 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { basename } from 'path'
import glob from 'glob'
import index from '@next/eslint-plugin-next'
const getRuleNameFromRulePath = (path) => basename(path, '.js')
const rulePaths = glob.sync('packages/eslint-plugin-next/dist/rules/*js', {
absolute: true,
})
describe('@next/eslint-plugin-next index', () => {
it('should include all defined rules and no extra / undefined rules', () => {
const rules = rulePaths.map((rulePath) => getRuleNameFromRulePath(rulePath))
expect(index.rules).toContainAllKeys(rules)
})
rulePaths.forEach((rulePath) => {
let rule = require(rulePath)
rule = rule.default ?? rule
const ruleName = getRuleNameFromRulePath(rulePath)
const { recommended = false } = rule.meta.docs
it(`${ruleName}: recommend should be \`${recommended}\``, () => {
expect(`@next/next/${ruleName}` in index.configs.recommended.rules).toBe(
recommended
)
})
})
})