Skip to content

Commit

Permalink
Relax ESLint a bit in own test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Dec 28, 2023
1 parent 2f7bb64 commit 7383afd
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 72 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ module.exports = {
},
],
},

// Relax ESLint a bit in tests
overrides: [
{
files: ['test/**'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'no-restricted-syntax': 'off',
},
},
],
};
2 changes: 0 additions & 2 deletions src/lib/_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

type RequiredKeys<T extends object> = {
[K in keyof T]: undefined extends T[K] ? never : K;
}[keyof T];
Expand Down
84 changes: 34 additions & 50 deletions test/_fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,51 @@
// prettier-ignore
export const STRINGS: string[] = [
'',
'1',
'3.14',
'foo',
' 1 2 3 ',
'not a number',
'42',
'',
'1',
'3.14',
'foo',
' 1 2 3 ',
'not a number',
'42',
];

// prettier-ignore
export const NUMBERS: number[] = [
-317.827682288236872,
-1,
-0,
0,
1,
2,
3.14,
Number.EPSILON,
Math.PI,
42,
-317.827682288236872,
-1,
-0,
0,
1,
2,
3.14,
Number.EPSILON,
Math.PI,
42,
];

// prettier-ignore
export const SPECIAL_NUMBERS: number[] = [
NaN,
Number.NEGATIVE_INFINITY,
Number.POSITIVE_INFINITY,
NaN,
Number.NEGATIVE_INFINITY,
Number.POSITIVE_INFINITY,
];

// prettier-ignore
export const DATES: Date[] = [
new Date('1996-3-17'),
new Date(1534521367000),
new Date('2017-11-28T15:56:07+0200'),
new Date(),
new Date('1996-3-17'),
new Date(1534521367000),
new Date('2017-11-28T15:56:07+0200'),
new Date(),
];

// prettier-ignore
export const SPECIAL_DATES: Date[] = [
new Date('not a date'),
];
export const SPECIAL_DATES: Date[] = [new Date('not a date')];

// prettier-ignore
export const BOOLS: boolean[] = [
false,
true,
];
export const BOOLS: boolean[] = [false, true];

// prettier-ignore
export const CONSTANTS: (null | undefined)[] = [
null,
undefined,
];
export const CONSTANTS: (null | undefined)[] = [null, undefined];

// prettier-ignore
export const INPUTS: unknown[] = [
...STRINGS,
...NUMBERS,
...SPECIAL_NUMBERS,
...DATES,
...SPECIAL_DATES,
...BOOLS,
...CONSTANTS,
...STRINGS,
...NUMBERS,
...SPECIAL_NUMBERS,
...DATES,
...SPECIAL_DATES,
...BOOLS,
...CONSTANTS,
];
2 changes: 0 additions & 2 deletions test/_utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import { indent, subtract } from '~/_utils';
import type { Scalar } from '~/Decoder';
Expand Down
3 changes: 0 additions & 3 deletions test/annotate.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-explicit-any */

import { describe, expect, test } from 'vitest';
import { annotate, array, circularRef, merge, object, scalar } from '~/annotate';

Expand Down
2 changes: 0 additions & 2 deletions test/basics.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import {
always,
Expand Down
2 changes: 0 additions & 2 deletions test/booleans.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import { boolean, numericBoolean, truthy } from '~/lib/booleans';
import { INPUTS } from './_fixtures';
Expand Down
2 changes: 0 additions & 2 deletions test/dates.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import { date, iso8601 } from '~/lib/dates';
import { INPUTS } from './_fixtures';
Expand Down
2 changes: 0 additions & 2 deletions test/numbers.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import {
anyNumber,
Expand Down
3 changes: 0 additions & 3 deletions test/strings.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* globals URL */
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import {
email,
Expand Down
2 changes: 0 additions & 2 deletions test/unions.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import { boolean } from '~/lib/booleans';
import { constant, undefined_ } from '~/lib/basics';
Expand Down
2 changes: 0 additions & 2 deletions test/utilities.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-restricted-syntax */

import { describe, expect, test } from 'vitest';
import { array } from '~/lib/arrays';
import { constant } from '~/lib/basics';
Expand Down

0 comments on commit 7383afd

Please sign in to comment.