Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLocalStorage: Unsafe return of an any typed value @typescript-eslint/no-unsafe-return #22

Closed
selvinkuik opened this issue Aug 4, 2021 · 3 comments

Comments

@selvinkuik
Copy link

My linter is kicking up a fuss on the useLocalStorage hook:

Line 17:7:  Unsafe return of an any typed value  @typescript-eslint/no-unsafe-return

My .eslintrc.js:

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin'],
  extends: [
    'react-app',
    'react-app/jest',
    'plugin:@typescript-eslint/recommended',
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    'plugin:prettier/recommended',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  rules: {
    '@typescript-eslint/no-empty-interface': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
  },
}

And .tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src"]
}

Is there any way to get the hook to work under these conditions?

@juliencrn
Copy link
Owner

Hi @selvinkuik, I've just added your Eslint rules and I have a ton of new errors, good catch! Thank you for the opportunity to increase useHooks's quality.
I will fix it, and I'm come back to you with the useLocalStorage() hook updated.

@juliencrn
Copy link
Owner

Hi @selvinkuik, you can try this version from the develop branch.

@juliencrn
Copy link
Owner

Deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants