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
Copy file name to clipboardExpand all lines: website/src/pages/index.mdx
+95-77Lines changed: 95 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,7 +204,9 @@ You may encounter discriminated unions under different names such as tagged unio
204
204
Discriminated unions advantages:
205
205
206
206
- 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.
207
-
- 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/" />
207
+
- Exhaustiveness check - TypeScript can ensure that all possible variants of a type are implemented, eliminating the risk of undefined or unexpected behavior at runtime.
Including return type annotations is highly encouraged, although not required <Rulehref="https://typescript-eslint.io/rules/explicit-function-return-type/" />.
239
+
<Rule
240
+
prefix="Including return type annotations is highly encouraged, although not required"
If TypeScript error can't be mitigated, as last resort use `@ts-expect-error` to suppress it <Rulehref="https://typescript-eslint.io/rules/ban-ts-comment" />. If at any future point suppressed line becomes error-free, TypeScript compiler will indicate it.
381
-
`@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" />.
385
+
If TypeScript error can't be mitigated, as last resort use `@ts-expect-error` to suppress it. If at any future point suppressed line becomes error-free, TypeScript compiler will indicate it. `@ts-ignore` is not
386
+
allowed, where `@ts-expect-error` must be used with provided 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.
406
408
407
-
All types must be defined with `type` alias <Rulehref='https://typescript-eslint.io/rules/consistent-type-definitions/#type' />.
409
+
<Rule
410
+
prefix="All types must be defined with `type` alias"
TypeScript allows specifying a `type` keyword on imports to indicate that the export exists only in the type system, not at runtime.
473
488
474
-
Type imports must always be separated <Rule href="https://typescript-eslint.io/rules/consistent-type-imports/" />:
489
+
Type imports must always be separated:
475
490
476
491
- Tree Shaking and Dead Code Elimination: If you use `import` for types instead of `importtype`, the bundler might include the imported module in the bundle unnecessarily, increasing the size. Separating imports ensures that only necessary runtime code is included.
477
492
- Minimizing Dependencies: Some modules may contain both runtime and type definitions. Mixing type imports with runtime imports might lead to accidental inclusion of unnecessary runtime code.
478
493
- Improves code clarity by making the distinction between runtime dependencies and type-only imports explicit.
// ❌ Avoid using `import` for both runtime and type
482
499
import { MyClass } from'some-library';
@@ -686,25 +703,26 @@ Strive to keep naming conventions consistent and readable, with important contex
686
703
687
704
### Named Export
688
705
689
-
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' />.
690
-
This keeps variables, functions etc. names consistent across the entire codebase.
691
-
Named exports have the benefit of erroring when import statements try to import something that hasn't been declared.
692
-
693
-
In case of exceptions e.g. Next.js pages, disable rule:
706
+
<Rule
707
+
prefix="Named exports must be used to ensure that all imports follow a uniform pattern"
@@ -792,6 +807,18 @@ A generic variable must start with the capital letter T followed by a descriptiv
792
807
Creating more complex types often include generics, which can make them hard to read and understand, that's why we try to put best effort when naming them.
793
808
Naming generics using popular convention with one letter `T`, `K` etc. is not allowed, the more variables we introduce, the easier it is to mistake them.
// Generic type parameter must start with letter T, followed by any uppercase letter.
817
-
selector: 'typeParameter',
818
-
format: ['PascalCase'],
819
-
custom: { regex: '^T[A-Z]', match: true },
820
-
},
821
-
],
822
-
```
823
-
824
836
#### Abbreviations & Acronyms
825
837
826
838
Treat acronyms as whole words, with capitalized first letter only.
@@ -858,7 +870,9 @@ React component name following "Props" postfix
858
870
#### Callback Props
859
871
860
872
Event handler (callback) props are prefixed as `on*` - e.g. `onClick`.
861
-
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" />.
873
+
Event handler implementation functions are prefixed as `handle*` - e.g. `handleClick`.
0 commit comments