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
Provenance
- Commit
30f5505- Tree
01a7b13- Author
Daishi Kato <dai-shi@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
bb26cd0
5 files changed+43 added−9 removed
modified:src/middleware/devtools.ts+3 added-1 removed
66 unmodified lines67686970717172737475767792 unmodified lines66 unmodified lines try { extension = (window as any).__REDUX_DEVTOOLS_EXTENSION__ || (window as any).top.__REDUX_DEVTOOLS_EXTENSION__ } catch {} } catch { // ignored }
if (!extension) { if ( process.env.NODE_ENV === 'development' &&92 unmodified linesmodified:src/middleware/persist.ts+1 added-1 removed
1 import { GetState, SetState, State, StoreApi } from '../vanilla'2 3-type DeepPartial<T extends Object> = {3+type DeepPartial<T> = {4 [P in keyof T]?: DeepPartial<T[P]>5 }6 7 export type StateStorage = {338 unmodified linesmodified:tests/basic.test.tsx+11 added-4 removed
1 import {2 Component as ClassComponent,3+ ReactNode,4 useEffect,5 useLayoutEffect,6 useState,7 } from 'react'281 unmodified lines289 const selector: StateSelector<State, string | void> = (s) =>290 // @ts-expect-error This function is supposed to throw an error291 s.value.toUpperCase()292 292- 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 lines335 const equalityFn: EqualityChecker<State> = (a, b) =>336 // @ts-expect-error This function is supposed to throw an error337 a.value.trim() === b.value.trim()338 335- 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 linesmodified:tests/context.test.tsx+11 added-3 removed
1-import { Component as ClassComponent, useEffect, useState } from 'react'1+import {2+ Component as ClassComponent,3+ ReactNode,4+ useEffect,5+ useState,6+} from 'react'7 import { render } from '@testing-library/react'8 import create, { GetState, SetState } from 'zustand'9 import createContext from 'zustand/context'10 import {111 unmodified lines122 123 it('throws error when not using provider', async () => {124 console.error = jest.fn()125 121- 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 linesmodified:.eslintrc.json+17 added
4 unmodified lines5 "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 lines30 "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 lines112 "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 }