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

[FEATURE]: add TS checklist #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mibled
Copy link
Member

@mibled mibled commented Oct 29, 2024

Add a new checklist for Typescript

@mibled mibled added documentation Improvements or additions to documentation review is welcome labels Oct 29, 2024
@mibled mibled self-assigned this Oct 29, 2024
@@ -1 +1,178 @@
# TypeScript Best Practices

1. **Consistent Coding Style**:
Copy link
Member

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
Copy link
Member

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:

```

3. **Interfaces**:
- **Explanation**: Prefer interfaces over type aliases for defining object shapes.
Copy link
Member

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`**:
Copy link
Member

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`**:
Copy link
Member

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**:
Copy link
Member

Choose a reason for hiding this comment

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

}
```

10. **Document Your Code**:
Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation review is welcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants