-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEATURE]: add TS checklist #13
base: main
Are you sure you want to change the base?
Conversation
@@ -1 +1,178 @@ | |||
# TypeScript Best Practices | |||
|
|||
1. **Consistent Coding Style**: |
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.
I think that the official lint recommended configuration is :
https://github.com/typescript-eslint/typescript-eslint
https://typescript-eslint.io/getting-started
https://typescript-eslint.io/users/configs/
I think we dont need again to use "airbnb-typescript".
|
||
Configure ESLint: Create or modify the `.eslintrc.json` file at the root of your project with the following configuration: | ||
|
||
```json |
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.
I recommend to not add a configuration code since it can oftenly changes. We can say:
- Use a linter like ESLint to maintain a consistent coding style.
- The recommended configuration => link to https://typescript-eslint.io/getting-started
``` | ||
|
||
3. **Interfaces**: | ||
- **Explanation**: Prefer interfaces over type aliases for defining object shapes. |
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.
personally I prefer using type until I need to "extends" then I use interface.
type is more intuitive to define type.
interface is more about contract that an object must adhere to or protocol.
} | ||
``` | ||
|
||
4. **Avoid `any`**: |
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.
and unkonw
} | ||
``` | ||
|
||
7. **Prefer `const` over `let`**: |
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.
this is more related to JS than a specific TS feature, it's common for both JS and TS.
We can have as prerequisite at the begin for example: Adhere to JS best practices => link to JS gems.
type UserWithoutEmail = Omit<User, 'email'>; | ||
``` | ||
|
||
9. **Avoid Magic Numbers and Strings**: |
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.
} | ||
``` | ||
|
||
10. **Document Your Code**: |
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.
Add a new checklist for Typescript