Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit",
"source.fixAll.biome": "explicit"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
Expand All @@ -16,5 +20,5 @@
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
},
}
}
113 changes: 9 additions & 104 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
"quoteStyle": "single"
},
"globals": ["React"]
},
Expand All @@ -30,118 +28,25 @@
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noUselessFragments": "error",
"noBannedTypes": "error",
"noExtraBooleanCast": "error",
"noUselessCatch": "error",
"noUselessTypeConstraint": "error",
"useArrowFunction": "error",
"noAdjacentSpacesInRegex": "error"
},
"nursery": {
"useExplicitType": "error"
"noMisusedPromises": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useExhaustiveDependencies": "warn",
"useHookAtTopLevel": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error",
"noInvalidBuiltinInstantiation": "error",
"useValidTypeof": "error"
"useExhaustiveDependencies": "warn"
},
"style": {
"noNamespace": "error",
"useAsConstAssertion": "error",
"useConst": "error",
"useBlockStatements": "off",
"useArrayLiterals": "off"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noExplicitAny": "off",
"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noMisleadingInstantiator": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeDeclarationMerging": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"noWith": "error"
"noVar": "error"
},
"complexity": {
"noArguments": "error"
}
},
"includes": ["**", "!**/dist", "!**/.eslintrc.cjs"]
},
"overrides": [
{
"includes": ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"useConst": "error"
},
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off",
"noVar": "error"
},
"complexity": {
"noArguments": "error"
}
}
}
}
]
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"prepublishOnly": "npm run check:all",
"test": "vitest run && npm run test:jest",
"test:jest": "jest",
"check:all": "npm run build && npm run check:format && npm run check:exports && npm run test",
"check:all": "npm run build && npm run check:lint && npm run check:format && npm run check:exports && npm run test",
"check:type": "tsc --noEmit",
"check:exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"check:lint": "biome lint ./src",
"check:format": "biome format ./src",
"fix:format": "biome format --write ./src"
"check:lint": "biome lint ./src ./examples",
"check:format": "biome format ./src ./examples",
"fix:format": "biome format --write ./src ./examples"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion src/customMatchers/helpers/DiffError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { diff as jestDiff } from 'jest-diff';

const isVitest = typeof process !== 'undefined' && 'VITEST' in process.env;
const isVitest: boolean =
typeof process !== 'undefined' && 'VITEST' in process.env;

/**
* Error class with actual and expected fields for Jest/Vitest diff display.
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ declare module 'expect' {
}

declare global {
// biome-ignore lint/style/noNamespace: Jest type augmentation requires namespace
namespace jest {
interface Matchers<R> {
toHaveProps: ToHavePropsMatcherType<R>;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/createMockComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ComponentType, ReactNode, JSX } from 'react';
import { useRef, createElement } from 'react';
import type { ComponentMockElement } from '../types/common.js';
import type { ComponentType, JSX, ReactNode } from 'react';
import { createElement, useRef } from 'react';
import { MOCK_COMPONENT } from '../const.js';
import type { ComponentMockElement } from '../types/common.js';
import { preparePropsToStringify } from '../utils/preparePropsToStringify.js';

type MockComponentType<P = Record<string, unknown>> = (props: P) => JSX.Element;
Expand All @@ -16,7 +16,7 @@ export const createMockComponent = <T extends ComponentType<any>>(
const MockComponent: MockComponentType<InferredProps<T>> = ({
children,
...restProps
}) => {
}: InferredProps<T>) => {
const ref = useRef<ComponentMockElement>(null);
const propsToAssign =
Object.keys(restProps).length > 0 ? restProps : undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/preparePropsToStringify.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('preparePropsToStringify', () => {
'string',
42,
() => 'test',
function namedFunc() {
function namedFunc(): string {
return 'named';
},
],
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('preparePropsToStringify', () => {
options: ['option1', () => 'option2'],
},
callbacks: [
function callback1() {
function callback1(): string {
return 'cb1';
},
{
Expand Down