Skip to content

Commit 218ae7b

Browse files
style: add vitest lint plugin and fix new errors
1 parent bd60e9e commit 218ae7b

File tree

4 files changed

+49
-22
lines changed

4 files changed

+49
-22
lines changed

eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import gitignore from 'eslint-config-flat-gitignore';
55
import importX from 'eslint-plugin-import-x';
66
import n from 'eslint-plugin-n';
77
import tseslint from 'typescript-eslint';
8+
import vitest from '@vitest/eslint-plugin';
89

910
export default tseslint.config(gitignore(), {
1011
files: [
@@ -80,4 +81,11 @@ export default tseslint.config(gitignore(), {
8081
},
8182
],
8283
},
84+
}, {
85+
files: [
86+
'tests/**/*.ts',
87+
],
88+
extends: [
89+
vitest.configs.recommended,
90+
],
8391
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"@types/node": "^18.18.0",
7070
"@typescript-eslint/rule-tester": "^8.12.2",
7171
"@vitest/coverage-v8": "^2.1.4",
72+
"@vitest/eslint-plugin": "^1.1.7",
7273
"bumpp": "^9.8.0",
7374
"eslint": "^9.13.0",
7475
"eslint-config-flat-gitignore": "^0.3.0",

tests/utils.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ describe('utils', () => {
77
const regExp = createRegExpForWords(['add'])!;
88

99
it('should match action literals', () => {
10-
expect(`"ADD"`).to.match(regExp);
11-
expect(`"ADD_SOMETHING"`).to.match(regExp);
12-
expect(`"SOMETHING_ADD"`).to.match(regExp);
10+
expect(`"ADD"`).toMatch(regExp);
11+
expect(`"ADD_SOMETHING"`).toMatch(regExp);
12+
expect(`"SOMETHING_ADD"`).toMatch(regExp);
1313

14-
expect(`'ADD'`).to.match(regExp);
15-
expect(`'ADD_SOMETHING'`).to.match(regExp);
16-
expect(`'SOMETHING_ADD'`).to.match(regExp);
14+
expect(`'ADD'`).toMatch(regExp);
15+
expect(`'ADD_SOMETHING'`).toMatch(regExp);
16+
expect(`'SOMETHING_ADD'`).toMatch(regExp);
1717

18-
expect('`ADD`').to.match(regExp);
19-
expect('`ADD_SOMETHING`').to.match(regExp);
20-
expect('`SOMETHING_ADD`').to.match(regExp);
18+
expect('`ADD`').toMatch(regExp);
19+
expect('`ADD_SOMETHING`').toMatch(regExp);
20+
expect('`SOMETHING_ADD`').toMatch(regExp);
2121
});
2222

2323
it('should match action symbols', () => {
24-
expect('ADD').to.match(regExp);
25-
expect('ADD_SOMETHING').to.match(regExp);
26-
expect('SOMETHING_ADD').to.match(regExp);
24+
expect('ADD').toMatch(regExp);
25+
expect('ADD_SOMETHING').toMatch(regExp);
26+
expect('SOMETHING_ADD').toMatch(regExp);
2727

28-
expect(decamelize('Add')).to.match(regExp);
29-
expect(decamelize('AddSomething')).to.match(regExp);
30-
expect(decamelize('SomethingAdd')).to.match(regExp);
28+
expect(decamelize('Add')).toMatch(regExp);
29+
expect(decamelize('AddSomething')).toMatch(regExp);
30+
expect(decamelize('SomethingAdd')).toMatch(regExp);
3131
});
3232

3333
it('should not match words within larger words', () => {
34-
expect('READD').to.not.match(regExp);
35-
expect('Readd').to.not.match(regExp);
34+
expect('READD').not.toMatch(regExp);
35+
expect('Readd').not.toMatch(regExp);
3636

37-
expect('ADDER').to.not.match(regExp);
38-
expect('Adder').to.not.match(regExp);
37+
expect('ADDER').not.toMatch(regExp);
38+
expect('Adder').not.toMatch(regExp);
3939

40-
expect('LADDER').to.not.match(regExp);
41-
expect('Ladder').to.not.match(regExp);
40+
expect('LADDER').not.toMatch(regExp);
41+
expect('Ladder').not.toMatch(regExp);
4242
});
4343

4444
it('should create a RegExp from a string', () => {
45-
expect(createRegExpForWords('.')?.toString()).to.equal('/./i');
45+
expect(createRegExpForWords('.')?.toString()).toEqual('/./i');
4646
});
4747
});
4848
});

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,23 @@ __metadata:
15651565
languageName: node
15661566
linkType: hard
15671567

1568+
"@vitest/eslint-plugin@npm:^1.1.7":
1569+
version: 1.1.7
1570+
resolution: "@vitest/eslint-plugin@npm:1.1.7"
1571+
peerDependencies:
1572+
"@typescript-eslint/utils": ">= 8.0"
1573+
eslint: ">= 8.57.0"
1574+
typescript: ">= 5.0.0"
1575+
vitest: "*"
1576+
peerDependenciesMeta:
1577+
typescript:
1578+
optional: true
1579+
vitest:
1580+
optional: true
1581+
checksum: 10c0/a2c7e3361dcf02b214eaaead63838abd0a07f0fa6294871b61df4e5dc3ca951056acf75b64feeec196e12f129306dc5780601dd94a88f9df3c2e6623863b39f2
1582+
languageName: node
1583+
linkType: hard
1584+
15681585
"@vitest/expect@npm:2.1.4":
15691586
version: 2.1.4
15701587
resolution: "@vitest/expect@npm:2.1.4"
@@ -2910,6 +2927,7 @@ __metadata:
29102927
"@typescript-eslint/scope-manager": "npm:^8.12.2"
29112928
"@typescript-eslint/utils": "npm:^8.12.2"
29122929
"@vitest/coverage-v8": "npm:^2.1.4"
2930+
"@vitest/eslint-plugin": "npm:^1.1.7"
29132931
bumpp: "npm:^9.8.0"
29142932
common-tags: "npm:^1.8.0"
29152933
decamelize: "npm:^5.0.0 || ^6.0.0"

0 commit comments

Comments
 (0)