Skip to content

Commit

Permalink
ref(eslint): Remove mocha (getsentry#11296)
Browse files Browse the repository at this point in the history
ref getsentry#11084

Removes usage of `mocha` from eslint plugin
  • Loading branch information
AbhiPrasad authored and cadesalaberry committed Apr 19, 2024
1 parent 83f2211 commit c85f5c6
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 249 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@ module.exports = {
'no-console': 'off',
},
},
{
files: ['vite.config.ts'],
parserOptions: {
project: ['tsconfig.test.json'],
},
},
],
};
10 changes: 3 additions & 7 deletions packages/eslint-plugin-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@
"publishConfig": {
"access": "public"
},
"dependencies": {
"requireindex": "~1.1.0"
},
"devDependencies": {
"mocha": "^6.2.0"
},
"dependencies": {},
"scripts": {
"clean": "yarn rimraf sentry-internal-eslint-plugin-sdk-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "mocha test --recursive",
"test": "vitest run",
"test:watch": "vitest --watch",
"build:tarball": "npm pack",
"circularDepCheck": "madge --circular src/index.js"
},
Expand Down
100 changes: 0 additions & 100 deletions packages/eslint-plugin-sdk/test/lib/rules/no-eq-empty.js

This file was deleted.

91 changes: 91 additions & 0 deletions packages/eslint-plugin-sdk/test/lib/rules/no-eq-empty.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { RuleTester } from 'eslint';
import { describe } from 'vitest';

// @ts-expect-error untyped module
import rule from '../../../src/rules/no-eq-empty';

describe('no-eq-empty', () => {
test('ruleTester', () => {
const arrayMessage = 'Do not apply the equality operator on an empty array. Use .length or Array.isArray instead.';
const objectMessage = 'Do not apply the equality operator on an empty object.';

const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 8,
},
});

ruleTester.run('no-eq-empty', rule, {
valid: [
{
code: 'const hey = [] === []',
},
{
code: 'const hey = [] == []',
},
{
code: 'const hey = {} === {}',
},
{
code: 'const hey = {} == {}',
},
],
invalid: [
{
code: 'empty === []',
errors: [
{
message: arrayMessage,
type: 'BinaryExpression',
},
],
},
{
code: 'empty == []',
errors: [
{
message: arrayMessage,
type: 'BinaryExpression',
},
],
},
{
code: 'const hey = function() {}() === []',
errors: [
{
message: arrayMessage,
type: 'BinaryExpression',
},
],
},
{
code: 'empty === {}',
errors: [
{
message: objectMessage,
type: 'BinaryExpression',
},
],
},
{
code: 'empty == {}',
errors: [
{
message: objectMessage,
type: 'BinaryExpression',
},
],
},
{
code: 'const hey = function(){}() === {}',
errors: [
{
message: objectMessage,
type: 'BinaryExpression',
},
],
},
],
});
});
});
13 changes: 13 additions & 0 deletions packages/eslint-plugin-sdk/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",

"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"allowJs": true,
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": []

// other package-specific, test-specific options
}
}
5 changes: 5 additions & 0 deletions packages/eslint-plugin-sdk/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import baseConfig from '../../vite/vite.config';

export default {
...baseConfig,
};
2 changes: 1 addition & 1 deletion packages/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"test": "yarn test:unit",
"test:unit": "vitest run --outputDiffMaxLines=2000",
"test:unit": "vitest run",
"test:watch": "vitest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig"
},
Expand Down
Loading

0 comments on commit c85f5c6

Please sign in to comment.