このコミットが含まれているのは:
@@ -125,6 +125,54 @@ npm run preview
|
||||
- TypeScript and TSX use 4-space logical indentation.
|
||||
- In TypeScript and TSX only, replace every leading run of 8 spaces with a tab.
|
||||
- Tabs are only for leading indentation, never for spaces after non-space text.
|
||||
- TypeScript and TSX imports may stay on one line if they remain within the
|
||||
line limit; do not expand short type-only imports mechanically.
|
||||
- In TypeScript and TSX, when a function takes one destructured object
|
||||
argument plus an inline type, prefer this shape when it fits locally:
|
||||
|
||||
```ts
|
||||
const helper = (
|
||||
{ value, flag }: { value: string
|
||||
flag: boolean },
|
||||
): Result => {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
- In TypeScript and TSX, put `switch` case block braces on their own lines
|
||||
when a case needs a lexical block:
|
||||
|
||||
```ts
|
||||
case 'yes':
|
||||
case 'no':
|
||||
{
|
||||
const expected = valueFor (item)
|
||||
return expected == null || expected === answer
|
||||
}
|
||||
```
|
||||
|
||||
- In TypeScript and TSX, use `value == null` and `value != null` as the
|
||||
default nullish checks. Do not use `=== null`, `=== undefined`,
|
||||
`!== null`, or `!== undefined`.
|
||||
- If code appears to need a distinction between `null` and `undefined`, treat
|
||||
that as a design smell and revise the logic to avoid the distinction.
|
||||
External library APIs that explicitly require distinguishing the two are the
|
||||
only exception.
|
||||
- In TypeScript and TSX, keep short arrays on one line when they fit under the
|
||||
line limit; break arrays only when readability or line length requires it.
|
||||
- In TypeScript and TSX, when a ternary expression is split across multiple
|
||||
lines, align `?` and `:` with the condition expression. Do not indent `?` and
|
||||
`:` one extra level under the condition.
|
||||
|
||||
```ts
|
||||
const value =
|
||||
condition
|
||||
? consequent
|
||||
: alternate
|
||||
```
|
||||
|
||||
- In TypeScript and TSX, keep short ternary expressions on one line when they
|
||||
fit cleanly under the line limit.
|
||||
- Do not add production dependencies without explicit approval.
|
||||
- Do not create, modify, or run tests unless the user explicitly asks for
|
||||
test work. When the user asks for tests, keep working and rerun them until
|
||||
|
||||
新しい課題から参照
ユーザをブロックする