-
Notifications
You must be signed in to change notification settings - Fork 389
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
Conversation
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
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/sanity-io/test-studio/7u40j3rcp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ Thank you ✨
Nice work! |
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
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 thana
,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 wherePromise.all
or a concurrency limiter should be in place.@typescript-eslint/explicit-module-boundary-types
- disable for tsx because definingReact.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 checksreact/require-default-props
- Disable for typescript because we want types, not runtime prop checksAlso exposed an
eslint-config-sanity/typescript
preset for easy use in other projects