DonIsaac/react-hooks

View on GitHub

Showing 45 of 71 total issues

Function useFetch has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function useFetch<T = any, E = Error>(
    to: RequestInfo,
    opts?: RequestInit
): RequestState<T, E> {
    const [manualRefetch, forceRefetch] = useReducer(s => (s + 1) % 10, 0)
Severity: Major
Found in src/useFetch/useFetch.ts - About 2 hrs to fix

    Function handler has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const handler: http.RequestListener = (req, res) => {
        switch (req.url) {
            // mock json todo object route
            case '/todos/1':
                res.writeHead(200, { 'Content-Type': 'application/json' })
    Severity: Minor
    Found in src/useFetch/__tests__/mockServer.ts - About 1 hr to fix

      Function sendRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              const sendRequest = async () => {
                  if (!memoTo) {
                      return
                  }
      
      
      Severity: Minor
      Found in src/useFetch/useFetch.ts - About 1 hr to fix

        Function handler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        const handler: http.RequestListener = (req, res) => {
            switch (req.url) {
                // mock json todo object route
                case '/todos/1':
                    res.writeHead(200, { 'Content-Type': 'application/json' })
        Severity: Minor
        Found in src/useFetch/__tests__/mockServer.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        import {
        Severity: Minor
        Found in src/useFetch/useFetch.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        React Hook useEffect has missing dependencies: 'E' and 'T'. Either include them or remove the dependency array.
        Open

            }, [memoTo, memoOpts, manualRefetch, receiveResponse, receiveError])
        Severity: Minor
        Found in src/useFetch/useFetch.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        import { useState } from 'react'
        Severity: Minor
        Found in src/useDidMount.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        /* eslint-disable @typescript-eslint/no-explicit-any */
        Severity: Minor
        Found in src/useDelayedCallback.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Missing return type on function.
        Open

        const useDidMount = () => {
        Severity: Minor
        Found in src/useDidMount.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        React Hook useEffect has a missing dependency: 'callback.name'. Either include it or remove the dependency array.
        Open

            }, [delayedCallback])
        Severity: Minor
        Found in src/useDelayedCallback.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        import type React from 'react'
        Severity: Minor
        Found in src/usePermissions.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        /**
        Severity: Minor
        Found in src/useFetch/parseBody.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Delete ,
        Open

                  opts?: O extends void ? P : O,
        Severity: Minor
        Found in src/useDelayedCallback.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        /**
        Severity: Minor
        Found in src/lib/compare.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Missing return type on function.
        Open

        const useMount = (effect: EffectCallback) => {
        Severity: Minor
        Found in src/useMount.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        import { useCallback, DependencyList } from 'react'
        Severity: Minor
        Found in src/useMeasuredCallback.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Missing return type on function.
        Open

        const useDelayedCallback = <T extends (...args: any[]) => any>(
        Severity: Minor
        Found in src/useDelayedCallback.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Definition for rule 'tsdoc/syntax' was not found.
        Open

        export const sleep = (delay: number) =>
        Severity: Minor
        Found in src/lib/util.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Missing return type on function.
        Open

        export const sleep = (delay: number) =>
        Severity: Minor
        Found in src/lib/util.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Don't use object as a type. The object type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)). Consider using Record<string unknown></string> instead, as it allows you to more easily inspect and use the keys.
        Open

                const bKeys = Object.keys(b as object).sort()
        Severity: Minor
        Found in src/lib/compare.ts by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Severity
        Category
        Status
        Source
        Language