Skip to content
Myr

chore(eslint): add recommended rules and etc (#678)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daishi Kato · committed by GitHub · parent bb26cd0 · Browse files · 5 files+43 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+43 added−9 removed

  • tests:+22 added−7 removed
  • other:+21 added−2 removed

5 files+43 added−9 removed

modified:src/middleware/devtools.ts+3 added-1 removed
modified:src/middleware/persist.ts+1 added-1 removed
1import { GetState, SetState, State, StoreApi } from '../vanilla'23type DeepPartial<T extends Object> = {3type DeepPartial<T> = {4 [P in keyof T]?: DeepPartial<T[P]>5}67export type StateStorage = {
338 unmodified lines
modified:tests/basic.test.tsx+11 added-4 removed
1import {2 Component as ClassComponent,3 ReactNode,4 useEffect,5 useLayoutEffect,6 useState,7} from 'react'
281 unmodified lines
289 const selector: StateSelector<State, string | void> = (s) =>290 // @ts-expect-error This function is supposed to throw an error291 s.value.toUpperCase()292292 class ErrorBoundary extends ClassComponent<{}, { hasError: boolean }> {293 constructor(props: {}) {293 class ErrorBoundary extends ClassComponent<294 { children?: ReactNode | undefined },295 { hasError: boolean }296 > {297 constructor(props: { children?: ReactNode | undefined }) {298 super(props)299 this.state = { hasError: false }300 }301 static getDerivedStateFromError() {
33 unmodified lines
335 const equalityFn: EqualityChecker<State> = (a, b) =>336 // @ts-expect-error This function is supposed to throw an error337 a.value.trim() === b.value.trim()338335 class ErrorBoundary extends ClassComponent<{}, { hasError: boolean }> {336 constructor(props: {}) {339 class ErrorBoundary extends ClassComponent<340 { children?: ReactNode | undefined },341 { hasError: boolean }342 > {343 constructor(props: { children?: ReactNode | undefined }) {344 super(props)345 this.state = { hasError: false }346 }347 static getDerivedStateFromError() {
248 unmodified lines
modified:tests/context.test.tsx+11 added-3 removed
1import { Component as ClassComponent, useEffect, useState } from 'react'1import {2 Component as ClassComponent,3 ReactNode,4 useEffect,5 useState,6} from 'react'7import { render } from '@testing-library/react'8import create, { GetState, SetState } from 'zustand'9import createContext from 'zustand/context'10import {
111 unmodified lines
122123it('throws error when not using provider', async () => {124 console.error = jest.fn()125121 class ErrorBoundary extends ClassComponent<{}, { hasError: boolean }> {122 constructor(props: {}) {126 class ErrorBoundary extends ClassComponent<127 { children?: ReactNode | undefined },128 { hasError: boolean }129 > {130 constructor(props: { children?: ReactNode | undefined }) {131 super(props)132 this.state = { hasError: false }133 }134 static getDerivedStateFromError() {
20 unmodified lines
modified:.eslintrc.json+17 added
4 unmodified lines
5 "node": true,6 "es6": true7 },8 "extends": [9 "eslint:recommended",10 "plugin:@typescript-eslint/recommended",11 "prettier",12 "plugin:prettier/recommended",13 "plugin:react-hooks/recommended",14 "plugin:import/errors",
15 unmodified lines
30 "jsx": true31 }32 },33 "rules": {34 "eqeqeq": "error",35 "no-var": "error",36 "prefer-const": "error",37 "curly": ["warn", "multi-line", "consistent"],38 "no-console": "off",39 "import/no-unresolved": ["error", { "commonjs": true, "amd": true }],40 "import/export": "error",
71 unmodified lines
112 "files": ["src"],113 "parserOptions": {114 "project": "./tsconfig.json"115 }116 },117 {118 "files": ["tests/**/*.tsx"],119 "env": {120 "jest/globals": true121 }122 },123 {124 "files": ["./*.js"],125 "rules": {126 "@typescript-eslint/no-var-requires": "off"127 }128 }129 ]130}