Skip to content

Commit dde1b3d

Browse files
authored
ref(eslint): Remove mocha (#11296)
ref #11084 Removes usage of `mocha` from eslint plugin
1 parent fcd63fa commit dde1b3d

File tree

8 files changed

+364
-249
lines changed

8 files changed

+364
-249
lines changed

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,11 @@ module.exports = {
5959
'no-console': 'off',
6060
},
6161
},
62+
{
63+
files: ['vite.config.ts'],
64+
parserOptions: {
65+
project: ['tsconfig.test.json'],
66+
},
67+
},
6268
],
6369
};

packages/eslint-plugin-sdk/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@
2121
"publishConfig": {
2222
"access": "public"
2323
},
24-
"dependencies": {
25-
"requireindex": "~1.1.0"
26-
},
27-
"devDependencies": {
28-
"mocha": "^6.2.0"
29-
},
24+
"dependencies": {},
3025
"scripts": {
3126
"clean": "yarn rimraf sentry-internal-eslint-plugin-sdk-*.tgz",
3227
"fix": "eslint . --format stylish --fix",
3328
"lint": "eslint . --format stylish",
34-
"test": "mocha test --recursive",
29+
"test": "vitest run",
30+
"test:watch": "vitest --watch",
3531
"build:tarball": "npm pack",
3632
"circularDepCheck": "madge --circular src/index.js"
3733
},

packages/eslint-plugin-sdk/test/lib/rules/no-eq-empty.js

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { RuleTester } from 'eslint';
2+
import { describe } from 'vitest';
3+
4+
// @ts-expect-error untyped module
5+
import rule from '../../../src/rules/no-eq-empty';
6+
7+
describe('no-eq-empty', () => {
8+
test('ruleTester', () => {
9+
const arrayMessage = 'Do not apply the equality operator on an empty array. Use .length or Array.isArray instead.';
10+
const objectMessage = 'Do not apply the equality operator on an empty object.';
11+
12+
const ruleTester = new RuleTester({
13+
parserOptions: {
14+
ecmaVersion: 8,
15+
},
16+
});
17+
18+
ruleTester.run('no-eq-empty', rule, {
19+
valid: [
20+
{
21+
code: 'const hey = [] === []',
22+
},
23+
{
24+
code: 'const hey = [] == []',
25+
},
26+
{
27+
code: 'const hey = {} === {}',
28+
},
29+
{
30+
code: 'const hey = {} == {}',
31+
},
32+
],
33+
invalid: [
34+
{
35+
code: 'empty === []',
36+
errors: [
37+
{
38+
message: arrayMessage,
39+
type: 'BinaryExpression',
40+
},
41+
],
42+
},
43+
{
44+
code: 'empty == []',
45+
errors: [
46+
{
47+
message: arrayMessage,
48+
type: 'BinaryExpression',
49+
},
50+
],
51+
},
52+
{
53+
code: 'const hey = function() {}() === []',
54+
errors: [
55+
{
56+
message: arrayMessage,
57+
type: 'BinaryExpression',
58+
},
59+
],
60+
},
61+
{
62+
code: 'empty === {}',
63+
errors: [
64+
{
65+
message: objectMessage,
66+
type: 'BinaryExpression',
67+
},
68+
],
69+
},
70+
{
71+
code: 'empty == {}',
72+
errors: [
73+
{
74+
message: objectMessage,
75+
type: 'BinaryExpression',
76+
},
77+
],
78+
},
79+
{
80+
code: 'const hey = function(){}() === {}',
81+
errors: [
82+
{
83+
message: objectMessage,
84+
type: 'BinaryExpression',
85+
},
86+
],
87+
},
88+
],
89+
});
90+
});
91+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
4+
"include": ["test/**/*", "vite.config.ts"],
5+
6+
"compilerOptions": {
7+
"allowJs": true,
8+
// should include all types from `./tsconfig.json` plus types for all test frameworks used
9+
"types": []
10+
11+
// other package-specific, test-specific options
12+
}
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import baseConfig from '../../vite/vite.config';
2+
3+
export default {
4+
...baseConfig,
5+
};

packages/sveltekit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"fix": "eslint . --format stylish --fix",
7171
"lint": "eslint . --format stylish",
7272
"test": "yarn test:unit",
73-
"test:unit": "vitest run --outputDiffMaxLines=2000",
73+
"test:unit": "vitest run",
7474
"test:watch": "vitest --watch",
7575
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig"
7676
},

0 commit comments

Comments
 (0)