|
1 | | -import { existsSync } from 'fs'; |
2 | | -import { resolve } from 'path'; |
| 1 | +import { existsSync } from 'node:fs'; |
| 2 | +import { resolve } from 'node:path'; |
| 3 | + |
| 4 | +import { it, expect } from 'vitest'; |
3 | 5 |
|
4 | 6 | import plugin from '../lib'; |
5 | 7 |
|
6 | 8 | const numberOfRules = 28; |
7 | 9 | const ruleNames = Object.keys(plugin.rules); |
8 | 10 |
|
9 | | -// eslint-disable-next-line jest/expect-expect |
10 | 11 | it('should have a corresponding doc for each rule', () => { |
11 | 12 | ruleNames.forEach((rule) => { |
12 | 13 | const docPath = resolve(__dirname, '../docs/rules', `${rule}.md`); |
13 | 14 |
|
14 | | - if (!existsSync(docPath)) { |
15 | | - throw new Error( |
16 | | - `Could not find documentation file for rule "${rule}" in path "${docPath}"` |
17 | | - ); |
18 | | - } |
| 15 | + expect( |
| 16 | + existsSync(docPath), |
| 17 | + `Could not find documentation file for rule "${rule}" in path "${docPath}"` |
| 18 | + ).toBe(true); |
19 | 19 | }); |
20 | 20 | }); |
21 | 21 |
|
22 | | -// eslint-disable-next-line jest/expect-expect |
23 | 22 | it('should have a corresponding test for each rule', () => { |
24 | 23 | ruleNames.forEach((rule) => { |
25 | 24 | const testPath = resolve(__dirname, './lib/rules/', `${rule}.test.ts`); |
26 | 25 |
|
27 | | - if (!existsSync(testPath)) { |
28 | | - throw new Error( |
29 | | - `Could not find test file for rule "${rule}" in path "${testPath}"` |
30 | | - ); |
31 | | - } |
| 26 | + expect( |
| 27 | + existsSync(testPath), |
| 28 | + `Could not find test file for rule "${rule}" in path "${testPath}"` |
| 29 | + ).toBe(true); |
32 | 30 | }); |
33 | 31 | }); |
34 | 32 |
|
35 | | -// eslint-disable-next-line jest/expect-expect |
36 | 33 | it('should have the correct amount of rules', () => { |
37 | 34 | const { length } = ruleNames; |
38 | 35 |
|
39 | | - if (length !== numberOfRules) { |
40 | | - throw new Error( |
41 | | - `There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.` |
42 | | - ); |
43 | | - } |
| 36 | + expect( |
| 37 | + numberOfRules, |
| 38 | + `There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.` |
| 39 | + ).toEqual(length); |
44 | 40 | }); |
45 | 41 |
|
46 | 42 | it('should export configs that refer to actual rules', () => { |
|
0 commit comments