You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -205,7 +205,7 @@ You may encounter discriminated unions under different names such as tagged unio
205
205
Discriminated unions advantages:
206
206
207
207
- As mentioned in [Required & Optional Object Properties](#required--optional-object-properties), [Args as Discriminated Union](#args-as-discriminated-type) and [Props as Discriminated Type](#props-as-discriminated-type), discriminated union eliminates optional object properties which decreases complexity.
208
-
- Exhaustiveness check - TypeScript can ensure that all possible variants of a type are implemented, eliminating the risk of undefined or unexpected behavior at runtime. ([eslint rule](https://typescript-eslint.io/rules/switch-exhaustiveness-check/))
208
+
- Exhaustiveness check - TypeScript can ensure that all possible variants of a type are implemented, eliminating the risk of undefined or unexpected behavior at runtime. <Rulehref="https://typescript-eslint.io/rules/switch-exhaustiveness-check/" />
Including return type annotations is highly encouraged, although not required ([eslint rule](https://typescript-eslint.io/rules/explicit-function-return-type/)).
243
+
Including return type annotations is highly encouraged, although not required <Rulehref="https://typescript-eslint.io/rules/explicit-function-return-type/" />.
239
244
240
245
Consider benefits when explicitly typing the return value of a function:
If TypeScript error can't be mitigated, as last resort use `@ts-expect-error` to suppress it ([eslint rule](https://typescript-eslint.io/rules/prefer-ts-expect-error/)). If at any future point suppressed line becomes error-free, TypeScript compiler will indicate it.
327
-
`@ts-ignore` is not allowed, where `@ts-expect-error` must be used with provided description ([eslint rule](https://typescript-eslint.io/rules/ban-ts-comment/#allow-with-description)).
331
+
If TypeScript error can't be mitigated, as last resort use `@ts-expect-error` to suppress it <Rulehref="https://typescript-eslint.io/rules/prefer-ts-expect-error/" />. If at any future point suppressed line becomes error-free, TypeScript compiler will indicate it.
332
+
`@ts-ignore` is not allowed, where `@ts-expect-error` must be used with provided description <Rulehref="https://typescript-eslint.io/rules/ban-ts-comment/#allow-with-description" />.
TypeScript offers two options for type definitions - `type` and `interface`. As they come with some functional differences in most cases they can be used interchangeably. We try to limit syntax difference and pick one for consistency.
342
347
343
-
All types must be defined with `type` alias [(eslint rule)](https://typescript-eslint.io/rules/consistent-type-definitions/#type).
348
+
All types must be defined with `type` alias <Rulehref='https://typescript-eslint.io/rules/consistent-type-definitions/#type' />.
344
349
345
350
<Chip>
346
351
Consider using interfaces if developing a package that can be further extended, team is more comfortable working with
Array types must be defined with generic syntax ([eslint rule](https://typescript-eslint.io/rules/array-type/#generic)).
394
+
Array types must be defined with generic syntax <Rule href='https://typescript-eslint.io/rules/array-type/#generic' />.
390
395
391
396
<Chip>
392
397
As there is no functional difference between 'generic' and 'array' definition, feel free to set the one your team
@@ -602,7 +607,7 @@ Strive to keep naming conventions consistent and readable, with important contex
602
607
603
608
### Named Export
604
609
605
-
Named exports must be used to ensure that all imports follow a uniform pattern ([eslint rule](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md)).
610
+
Named exports must be used to ensure that all imports follow a uniform pattern <Rule href='https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md' />.
606
611
This keeps variables, functions... names consistent across the entire codebase.
607
612
Named exports have the benefit of erroring when import statements try to import something that hasn't been declared.
608
613
@@ -631,7 +636,7 @@ While it's often hard to find the best name, try optimize code for consistency a
@@ -774,7 +779,7 @@ React component name following "Props" postfix
774
779
#### Callback Props
775
780
776
781
Event handler (callback) props are prefixed as `on*` - e.g. `onClick`.
777
-
Event handler implementation functions are prefixed as `handle*` - e.g. `handleClick`([eslint rule](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md)).
782
+
Event handler implementation functions are prefixed as `handle*` - e.g. `handleClick`<Rule href="https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md" />.
778
783
779
784
```tsx
780
785
// ❌ Avoid inconsistent callback prop naming
@@ -788,7 +793,7 @@ Event handler (callback) props are prefixed as `on*` - e.g. `onClick`.
788
793
789
794
#### React Hooks
790
795
791
-
Camel case, prefixed as 'use' ([eslint rule](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)), symmetrically convention as `[value, setValue] =useState()`([eslint rule](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md#rule-details))
796
+
Camel case, prefixed as 'use' <Rule href="https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks" />, symmetrically convention as `[value, setValue] =useState()`<Rule href="https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md#rule-details" />:
792
797
793
798
```ts
794
799
// ❌ Avoid inconsistent useState hook naming
@@ -1202,8 +1207,9 @@ Automated test comes with benefits that helps us write better code and makes it
1202
1207
1203
1208
### Test Description
1204
1209
1205
-
All test descriptions must follow naming convention as `it('should ... when ...')`.
0 commit comments