Skip to content

Commit 6f61791

Browse files
committed
Apply lint rules
1 parent 280ceff commit 6f61791

7 files changed

Lines changed: 21 additions & 18 deletions

File tree

packages/tree-changes-hook/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useEffect, useRef } from 'react';
22
import * as equal from 'fast-deep-equal';
3-
43
import treeChanges, { Data, KeyType, TreeChanges } from 'tree-changes';
54

65
export default function useTreeChanges<T extends Data>(value: T) {

packages/tree-changes-hook/test/__snapshots__/index.spec.tsx.snap

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ exports[`useTreeChanges with state 1`] = `
88
<h1>
99
tree-changes
1010
</h1>
11-
<button>
11+
<button
12+
type="button"
13+
>
1214
Clicked
1315
0
1416
times
@@ -28,7 +30,9 @@ exports[`useTreeChanges with state 2`] = `
2830
<h1>
2931
tree-changes
3032
</h1>
31-
<button>
33+
<button
34+
type="button"
35+
>
3236
Clicked
3337
0
3438
times

packages/tree-changes-hook/test/index.spec.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
2-
import { fireEvent, render, screen } from '@testing-library/react';
32
import { act } from 'react-dom/test-utils';
3+
import { fireEvent, render, screen } from '@testing-library/react';
44

55
import useTreeChanges from '../src';
66

@@ -24,7 +24,7 @@ function WithState() {
2424
isReady: false,
2525
milestones: [],
2626
});
27-
const { added, changed, filled, removed, emptied } = useTreeChanges(state);
27+
const { added, changed, emptied, filled, removed } = useTreeChanges(state);
2828

2929
React.useEffect(() => {
3030
setTimeout(() => {
@@ -77,7 +77,7 @@ function WithState() {
7777
if (emptied('milestones')) {
7878
mockState('emptied:milestones');
7979
}
80-
}, [changed, state]);
80+
}, [added, changed, emptied, filled, removed, state]);
8181

8282
const handleClickCount = () => {
8383
setState(s => ({ ...s, count: s.count + 1 }));
@@ -87,7 +87,9 @@ function WithState() {
8787
<div data-testid="app">
8888
<header>
8989
<h1>tree-changes</h1>
90-
<button onClick={handleClickCount}>Clicked {state.count} times</button>
90+
<button onClick={handleClickCount} type="button">
91+
Clicked {state.count} times
92+
</button>
9193
{state.isReady ? <p>side-effect is complete</p> : <p>loading...</p>}
9294
</header>
9395
</div>

packages/tree-changes/src/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as equal from 'fast-deep-equal';
22
import is from 'is-lite';
3+
34
import { CompareValuesOptions, Data, Key, Options, ValidTypes, Value } from './types';
45

56
export function canHaveLength(...args: any): boolean {

packages/tree-changes/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as equal from 'fast-deep-equal';
22
import is from 'is-lite';
3-
import { compareNumbers, compareValues, getIterables, includesOrEqualsTo, nested } from './helpers';
43

4+
import { compareNumbers, compareValues, getIterables, includesOrEqualsTo, nested } from './helpers';
55
import { Data, KeyType, TreeChanges, Value } from './types';
66

77
export default function treeChanges<P extends Data, D extends Data, K = KeyType<P, D>>(

packages/tree-changes/test/helpers.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
compareNumbers,
55
compareValues,
66
getIterables,
7-
includesOrEqualsTo,
87
hasEntry,
98
hasExtraKeys,
109
hasValue,
10+
includesOrEqualsTo,
1111
isSameType,
1212
nested,
1313
} from '../src/helpers';
@@ -249,7 +249,7 @@ describe('hasValue', () => {
249249
});
250250

251251
describe('includesOrEqualsTo', () => {
252-
it('should ', () => {
252+
it('should match', () => {
253253
expect(
254254
includesOrEqualsTo(
255255
{

packages/tree-changes/test/index.spec.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,16 @@ describe('tree-changes', () => {
6161
describe('basic', () => {
6262
it('should throw without all parameters', () => {
6363
// @ts-ignore
64-
expect(() => treeChanges()).toThrowError('Missing required parameters');
64+
expect(() => treeChanges()).toThrow('Missing required parameters');
6565
// @ts-ignore
66-
expect(() => treeChanges(A)).toThrowError('Missing required parameters');
66+
expect(() => treeChanges(A)).toThrow('Missing required parameters');
6767
});
6868

6969
it('should throw with invalid parameters', () => {
7070
// @ts-ignore
71-
expect(() => treeChanges(A.missing, B.missing)).toThrowError(
72-
'Expected plain objects or array',
73-
);
71+
expect(() => treeChanges(A.missing, B.missing)).toThrow('Expected plain objects or array');
7472
// @ts-ignore
75-
expect(() => treeChanges(A.hasData, B.hasData)).toThrowError(
76-
'Expected plain objects or array',
77-
);
73+
expect(() => treeChanges(A.hasData, B.hasData)).toThrow('Expected plain objects or array');
7874
});
7975
});
8076

@@ -366,6 +362,7 @@ describe('tree-changes', () => {
366362

367363
it('with objects', () => {
368364
const { emptied } = treeChanges(A, B);
365+
369366
expect(emptied('messages')).toBe(true);
370367

371368
expect(emptied('notifications')).toBe(false);

0 commit comments

Comments
 (0)