mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
Doc: Update coding style
This commit is contained in:
parent
f15d2793cc
commit
1b9901d232
@ -32,6 +32,26 @@ If this is a large file however please ask first if it needs to be converted. So
|
||||
|
||||
In TypeScript files prefer `import` to `require` so that we can benefit from type-checking. If it does not work, you may have to add the type using `yarn add @types/NAME_OF_PACKAGE`. If you are trying to import an old package, it may not have TypeScript types and in this case using `require()` is acceptable.
|
||||
|
||||
### Avoid inline styles
|
||||
|
||||
In general please define types separately as it improves readability and it means the type can be re-used.
|
||||
|
||||
**BAD:**
|
||||
```ts
|
||||
const config: { [key: string]: Knex.Config } = {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
**Good:**
|
||||
```ts
|
||||
type Config = Record<string, Knex.Config>;
|
||||
|
||||
const config: Config = {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## Filenames
|
||||
|
||||
* `camelCase.ts`: Files that export multiple things.
|
||||
|
Loading…
x
Reference in New Issue
Block a user