Giter VIP home page Giter VIP logo

Comments (4)

Tim-W-James avatar Tim-W-James commented on July 19, 2024 1

Something I've noticed is total-functions/no-unsafe-mutable-readonly-assignment can be problematic with dependency arrays for useEffect, etc. hooks. Using a readonly type here prevents another rule from parsing it properly, since it is no longer an array literal - react-hooks/exhaustive-deps: React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.

So we can't satisfy both rules. I'd rather know if something is missing from my dep array here than use a readonly type, since it is being passed into React anyway. Perhaps there is some way this rule can be disabled for hook dependency arrays specifically?

from eslint-config-agile-digital.

danielnixon avatar danielnixon commented on July 19, 2024 1

That rule (total-functions/no-unsafe-mutable-readonly-assignment) is pretty hardcore and doesn't have a great Pearson metric score (it's written and maintained by one random guy: https://github.com/danielnixon/eslint-plugin-total-functions). It has some limitations (performance especially) that may make it impractical even if one does accept the premise that the linter (or even the language) should complain when a developer assigns a mutable value to a readonly value or vice versa.

I guess that's the long way of saying we should consider disabling it in the default/recommended config. Especially for the react config, but maybe even in the base config too.

from eslint-config-agile-digital.

danielnixon avatar danielnixon commented on July 19, 2024

We've added whitelisting for hooks to two rules so far:

  • functional/functional-parameters
  • functional/no-expression-statements

It's based on a clumsy function name heuristic (useFoo), but that's as good as we can do in this context.

I'll leave this issue open because there's certainly more work to do yet.

from eslint-config-agile-digital.

danielnixon avatar danielnixon commented on July 19, 2024

We should probably whitelist React components and JSX elements from prefer-immutable-types too. cc @haolinj

from eslint-config-agile-digital.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.