Skip to content

Commit

Permalink
Merge pull request #465 from romeerez/extend-eslint
Browse files Browse the repository at this point in the history
Enforce interface consistency with ESLint
  • Loading branch information
fabian-hiller committed Mar 7, 2024
2 parents 30b2ee7 + 1c1f59a commit a635382
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ module.exports = {
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
'regexp/prefer-regexp-exec': 'error', // Enforce that RegExp#exec is used instead of String#match if no global flag is provided, as exec is faster

// TypeScript
'@typescript-eslint/consistent-type-definitions': 'error', // Enforce declaring types using `interface` keyword for better TS performance.

// Redos detector
'redos-detector/no-unsafe-regex': ['error', { ignoreError: true }], // Prevent DoS regexps

Expand Down
1 change: 1 addition & 0 deletions library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"test": "vitest",
"coverage": "vitest run --coverage --isolate",
"lint": "eslint \"src/**/*.ts*\" && tsc --noEmit",
"eslint.fix": "eslint \"src/**/*.ts*\" --fix",
"format": "prettier --write ./src",
"format.check": "prettier --check ./src",
"build": "tsup",
Expand Down
3 changes: 3 additions & 0 deletions library/src/methods/forward/forward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { forward } from './forward.ts';

describe('forward', () => {
test('should forward issues to end of path list', () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string } };
const requirement = () => false;
const validate = forward<Input>(custom(requirement, 'Custom error'), [
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('forward', () => {
});

test('should stop forwarding if path input is undefined', () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string }[] };
const requirement = () => false;
const validate = forward<Input>(custom(requirement, 'Custom error'), [
Expand Down Expand Up @@ -91,6 +93,7 @@ describe('forward', () => {
});

test('should do nothing if there are no issues', () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string } };
const requirement = () => true;
const validate = forward<Input>(custom(requirement), ['nested']);
Expand Down
3 changes: 3 additions & 0 deletions library/src/methods/forward/forwardAsync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { forwardAsync } from './forwardAsync.ts';

describe('forwardAsync', () => {
test('should forward issues to end of path list', async () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string } };
const requirement = async () => false;
const validate = forwardAsync<Input>(
Expand Down Expand Up @@ -48,6 +49,7 @@ describe('forwardAsync', () => {
});

test('should stop forwarding if path input is undefined', async () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string }[] };
const requirement = async () => false;
const validate = forwardAsync<Input>(
Expand Down Expand Up @@ -91,6 +93,7 @@ describe('forwardAsync', () => {
});

test('should do nothing if there are no issues', async () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Input = { nested: { key: string } };
const requirement = async () => true;
const validate = forwardAsync<Input>(customAsync(requirement), ['nested']);
Expand Down

0 comments on commit a635382

Please sign in to comment.