From 3d18b46166220cf5dcae45662c095cf53329b381 Mon Sep 17 00:00:00 2001 From: Nikita Ovchinnikov Date: Mon, 4 Oct 2021 17:01:40 +0400 Subject: [PATCH] Add disable-mutants comments --- README.md | 4 ++++ src/components/Grid/Cell.tsx | 1 + src/components/Grid/Grid.tsx | 1 + src/components/Scoreboard/Counter.tsx | 1 + src/components/Scoreboard/Level.tsx | 1 + src/components/Scoreboard/Reset.tsx | 1 + src/components/Top/Top.tsx | 1 + src/components/hooks/useMouseDown.ts | 17 ++++++++++------- src/core/Field.ts | 2 ++ src/modules/GameWithHooks/GameWithHooks.tsx | 1 + src/modules/GameWithHooks/useGame.ts | 7 ++++++- 11 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dc6d967..4342d5c 100644 --- a/README.md +++ b/README.md @@ -268,3 +268,7 @@ ### React.memo + useCallback optimization [Pull request](https://github.com/nickovchinnikov/minesweeper/pull/47/files) + +### Stryker disable mutants + +[Pull request](https://github.com/nickovchinnikov/minesweeper/pull/49/files) diff --git a/src/components/Grid/Cell.tsx b/src/components/Grid/Cell.tsx index 527dea0..ab92b02 100644 --- a/src/components/Grid/Cell.tsx +++ b/src/components/Grid/Cell.tsx @@ -73,6 +73,7 @@ export const Cell: FC = memo(({ children, coords, ...rest }) => { return {children}; }, areEqual); +// Stryker disable next-line StringLiteral Cell.displayName = 'Cell'; interface ComponentsMapProps { diff --git a/src/components/Grid/Grid.tsx b/src/components/Grid/Grid.tsx index bf52663..03583c4 100644 --- a/src/components/Grid/Grid.tsx +++ b/src/components/Grid/Grid.tsx @@ -24,6 +24,7 @@ export const Grid: FC = ({ children, ...rest }) => ( {children.map((row, y) => row.map((cell, x) => ( + // Stryker disable next-line StringLiteral {cell} diff --git a/src/components/Scoreboard/Counter.tsx b/src/components/Scoreboard/Counter.tsx index c9c823b..d0db6b2 100644 --- a/src/components/Scoreboard/Counter.tsx +++ b/src/components/Scoreboard/Counter.tsx @@ -12,6 +12,7 @@ export const Counter: FC = memo(({ children }) => ( {children} )); +// Stryker disable next-line StringLiteral Counter.displayName = 'Counter'; const Frame = styled.div` diff --git a/src/components/Scoreboard/Level.tsx b/src/components/Scoreboard/Level.tsx index 58216c0..f61e6a0 100644 --- a/src/components/Scoreboard/Level.tsx +++ b/src/components/Scoreboard/Level.tsx @@ -26,6 +26,7 @@ export const Level: FC = memo(({ children, value, onChange }) => ( )); +// Stryker disable next-line StringLiteral Level.displayName = 'Level'; const Select = styled.select` diff --git a/src/components/Scoreboard/Reset.tsx b/src/components/Scoreboard/Reset.tsx index a8c2205..c7a1e48 100644 --- a/src/components/Scoreboard/Reset.tsx +++ b/src/components/Scoreboard/Reset.tsx @@ -25,6 +25,7 @@ export const Reset: FC = memo(({ onReset }) => { ); }); +// Stryker disable next-line StringLiteral Reset.displayName = 'Reset'; const Button = styled.button` diff --git a/src/components/Top/Top.tsx b/src/components/Top/Top.tsx index 7d8f892..6246eda 100644 --- a/src/components/Top/Top.tsx +++ b/src/components/Top/Top.tsx @@ -15,6 +15,7 @@ export const Top: FC = memo( ) ); +// Stryker disable next-line StringLiteral Top.displayName = 'Top'; const Header = styled.header` diff --git a/src/components/hooks/useMouseDown.ts b/src/components/hooks/useMouseDown.ts index c7da382..055e736 100644 --- a/src/components/hooks/useMouseDown.ts +++ b/src/components/hooks/useMouseDown.ts @@ -1,4 +1,4 @@ -import { useState, useDebugValue } from 'react'; +import { useState, useCallback } from 'react'; export type SetMouseDownStatus = () => void; export type SetMouseUpStatus = () => void; @@ -10,13 +10,16 @@ export const useMouseDown = (): [ ] => { const [mouseDown, setMouseDown] = useState(false); - useDebugValue( - `mouseDown: ${mouseDown}`, - (str) => `${str} ${new Date().toISOString()}` + const onMouseDown = useCallback( + () => setMouseDown(true), + // Stryker disable next-line ArrayDeclaration + [] + ); + const onMouseUp = useCallback( + () => setMouseDown(false), + // Stryker disable next-line ArrayDeclaration + [] ); - - const onMouseDown = () => setMouseDown(true); - const onMouseUp = () => setMouseDown(false); return [mouseDown, onMouseDown, onMouseUp]; }; diff --git a/src/core/Field.ts b/src/core/Field.ts index 9b9565f..cc8c542 100644 --- a/src/core/Field.ts +++ b/src/core/Field.ts @@ -59,8 +59,10 @@ export const fieldGenerator = (size: number, probability: number): Field => { const result: Field = generateFieldWithDefaultState(size); + // Stryker disable next-line EqualityOperator for (let y = 0; y < size; y++) { for (let x = 0; x < size; x++) { + // Stryker disable next-line EqualityOperator if (restCellsWithBombs / unprocessedCells > Math.random()) { result[y][x] = CellState.bomb; incrementNeibours([y, x], result); diff --git a/src/modules/GameWithHooks/GameWithHooks.tsx b/src/modules/GameWithHooks/GameWithHooks.tsx index 5c778ae..f4dbdc8 100644 --- a/src/modules/GameWithHooks/GameWithHooks.tsx +++ b/src/modules/GameWithHooks/GameWithHooks.tsx @@ -29,6 +29,7 @@ export const GameWithHooks: FC = () => { const onChangeLevelHandler = useCallback( ({ target: { value: level } }: React.ChangeEvent) => onChangeLevel(level as LevelNames), + // Stryker disable next-line ArrayDeclaration [] ); diff --git a/src/modules/GameWithHooks/useGame.ts b/src/modules/GameWithHooks/useGame.ts index 3d64579..3d93ae0 100644 --- a/src/modules/GameWithHooks/useGame.ts +++ b/src/modules/GameWithHooks/useGame.ts @@ -118,9 +118,14 @@ export const useGame = (): ReturnType => { const onChangeLevel = useCallback((level: LevelNames) => { const newSettings = setLevel(level); resetHandler(newSettings); + // Stryker disable next-line ArrayDeclaration }, []); - const onReset = useCallback(() => resetHandler([size, bombs]), [size, bombs]); + const onReset = useCallback( + () => resetHandler([size, bombs]), + // Stryker disable next-line ArrayDeclaration + [size, bombs] + ); return { level,