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

[eslint] Tweak ESLint rules for commonly ignored cases #2010

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Sep 16, 2020

Rationale for rule changes:

  • complexity - Seems very low, very common to have large React components where breaking them into separate modules only leads to prop-drilling and unnecessarily deep trees. Also quite common to have readable but long validation/switch statements where adjusting to standard only makes code less readable rather than more. Depend on code reviews to catch hard-to-read code. If 30 is not enough for actual cases, ignore in-place.
  • id-length - itemA/itemB and similar is not necessarily more readable than a, b. Lots of exceptions already in place. Commonly disabled. Catch in code reviews if variables are difficultly named.
  • max-depth - Seems arbitrarily low. Quite common to have valid, deeper blocks than this. Again, catch exceptions in code-reviews rather than linting.
  • max-len - Tab size seems to be set wrong. Have not seen this play out anywhere, but tweaked for consistency.
  • no-await-in-loop - Lots of cases where this is useful and "correct" (retrying, for instance). Catch in code reviews if using it in cases where Promise.all or a concurrency limiter should be in place.
  • @typescript-eslint/explicit-module-boundary-types - disable for tsx because defining React.ReactElement as return value is annoying. Still a good rule to ensure return values are what you expect in most other cases, however.
  • react/prop-types - Disable for typescript because we want types, not runtime prop checks
  • react/require-default-props - Disable for typescript because we want types, not runtime prop checks

Also exposed an eslint-config-sanity/typescript preset for easy use in other projects

Rationale:
- `complexity` - Seems very low, very common to have large React components where breaking them into separate modules only leads to prop-drilling and unnecessarily deep trees. Also quite common to have readable but long validation/switch statements where adjusting to standard only makes code less readable rather than more. Depend on code reviews to catch hard-to-read code. If 30 is not enough for actual cases, ignore in-place.
- `id-length` - `itemA`/`itemB` and similar is not necessarily more readable than `a`, `b`. Lots of exceptions already in place. Commonly disabled. Catch in code reviews if variables are difficultly named.
- `max-depth` - Seems arbitrarily low. Quite common to have valid, deeper blocks than this. Again, catch exceptions in code-reviews rather than linting.
- `max-len` - Tab size seems to be set wrong. Have not seen this play out anywhere, but tweaked for consistency.
- `no-await-in-loop` - Lots of cases where this is useful and "correct" (retrying, for instance). Catch in code reviews if using it in cases where `Promise.all` or a concurrency limiter should be in place.
- `@typescript-eslint/explicit-module-boundary-types` - disable for tsx because defining `React.ReactElement` as return value is annoying. Still a good rule to ensure return values are what you expect in most other cases, however.
- `react/prop-types` - Disable for typescript because we want types, not runtime prop checks
- `react/require-default-props` - Disable for typescript because we want types, not runtime prop checks

Also exposed an `eslint-config-sanity/typescript` preset for easy use in other projects
@vercel
Copy link

vercel bot commented Sep 16, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sanity-io/test-studio/7u40j3rcp
✅ Preview: https://test-studio-git-improve-eslint-config.sanity-io.vercel.app

Copy link
Member

@mariuslundgard mariuslundgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Thank you ✨

@rexxars rexxars merged commit 7ea6d52 into next Sep 16, 2020
@rexxars rexxars deleted the improve-eslint-config branch September 16, 2020 13:50
@saasen
Copy link
Contributor

saasen commented Sep 16, 2020

Nice work!

rexxars added a commit that referenced this pull request Sep 22, 2020
Rationale:
- `complexity` - Seems very low, very common to have large React components where breaking them into separate modules only leads to prop-drilling and unnecessarily deep trees. Also quite common to have readable but long validation/switch statements where adjusting to standard only makes code less readable rather than more. Depend on code reviews to catch hard-to-read code. If 30 is not enough for actual cases, ignore in-place.
- `id-length` - `itemA`/`itemB` and similar is not necessarily more readable than `a`, `b`. Lots of exceptions already in place. Commonly disabled. Catch in code reviews if variables are difficultly named.
- `max-depth` - Seems arbitrarily low. Quite common to have valid, deeper blocks than this. Again, catch exceptions in code-reviews rather than linting.
- `max-len` - Tab size seems to be set wrong. Have not seen this play out anywhere, but tweaked for consistency.
- `no-await-in-loop` - Lots of cases where this is useful and "correct" (retrying, for instance). Catch in code reviews if using it in cases where `Promise.all` or a concurrency limiter should be in place.
- `@typescript-eslint/explicit-module-boundary-types` - disable for tsx because defining `React.ReactElement` as return value is annoying. Still a good rule to ensure return values are what you expect in most other cases, however.
- `react/prop-types` - Disable for typescript because we want types, not runtime prop checks
- `react/require-default-props` - Disable for typescript because we want types, not runtime prop checks

Also exposed an `eslint-config-sanity/typescript` preset for easy use in other projects
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

Successfully merging this pull request may close these issues.

None yet

4 participants