Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions code/javascriptCode.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
# [<](README.md) &nbsp; JavaScript Code Conventions

* [File Names](#file-names)
* [Comments](#comments)
* [Exports](#exports)

&nbsp;

----

## File Names

* Postfix the names of index files with the name of its parent directory

```javascript
// incorrect
src/
components/
MyComponent/
index.js // <--
MyComponent.js
styles.js
// correct
src/
components/
MyComponent/
indexMyComponent.js // <--
MyComponent.js
styles.js
```

----

[Back to the top](#--javascript-code-conventions)

&nbsp;
Expand All @@ -51,24 +27,6 @@ const denomination = {
}
```

* Break more than double nested array dereferences into multiple lines

```javascript
// incorrect

// correct

```

* Break more than double nested or function calls into multiple lines

```javascript
// incorrect

// correct

```

----

[Back to the top](#--javascript-code-conventions)
Expand Down
77 changes: 75 additions & 2 deletions code/react.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,87 @@
# [<](README.md) &nbsp; React Conventions

* [TODO](#todo)
* [Component Exports](#component-exports)
* [Hooks](#hooks)
* [Component Patterns](#component-patterns)

&nbsp;

----
&nbsp;

## TODO
## Component Exports

Components should be exported using the following pattern:

### Preferred Pattern

```typescript
export const ComponentName: React.FC<Props> = props => {
// component implementation
}
```

[Back to the top](#--react-conventions)

&nbsp;

----

## Hooks

### useHandler

Prefer `useHandler` over `useCallback` for event handlers and async functions:

```typescript
import { useHandler } from '../../hooks/useHandler'

const handleAction = useHandler(async () => {
// async handler implementation
})
```

This hook provides better TypeScript inference and handles async functions more gracefully than `useCallback`.

### Custom Hooks

Custom hooks should be placed in `src/hooks/` and follow the `use*` naming convention:

```typescript
// src/hooks/useMyHook.ts
export const useMyHook = () => {
// hook implementation
}
```

[Back to the top](#--react-conventions)

&nbsp;

----

## Component Patterns

### Functional Components

Use functional components with hooks instead of class components:

```typescript
// preferred
export const MyComponent: React.FC<Props> = props => {
const theme = useTheme()
const dispatch = useDispatch()
// component implementation
}

// avoid (unless necessary for legacy code)
export class MyComponent extends React.Component<Props> {
// class component implementation
}
```

### Error Handling

Use proper error boundaries and avoid throwing errors in render methods. Handle errors gracefully within components.

[Back to the top](#--react-conventions)
24 changes: 19 additions & 5 deletions git/commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,23 @@ Put your commits in some sort of logical order, for example:
3. Implement the feature
4. Remove old code that was replaced

> Renaming files or variables should always happen in their own commits, separate from any code changes.
>
> – <cite>Paul Puey</cite>
Renaming files or variables should always happen in their own commits, separate from any code changes.

### Work-in-Progress Commits

When working on a feature that is not yet complete, you may use "WIP" as a prefix in the commit message:

```bash
# acceptable for incomplete work
git commit -m "WIP Theme server in Settings"
```

However, WIP commits should be cleaned up before creating a pull request. Use interactive rebase to either:
- Complete the work and update the commit message
- Split the WIP commit into logical, complete commits
- Remove the WIP prefix once the work is complete

WIP commits are useful for saving progress but should not be included in pull requests unless the PR is explicitly marked as a draft for early feedback.

### Clean Commit Principles

Expand Down Expand Up @@ -212,7 +226,7 @@ If it’s complex:
#### Joining commits

- Use the "fixup" or "f" command to join two commits keeping the first commit message
- Use the "squash" or "s" command to join two commits and edit the commit message
- Use the "squash" or "s" command to join two commits and edit the commit message
- Use “fixup!” “squash!” in your commit message and add `--autosquash` to your rebase command to tell git to automatically use these commands in your rebase.

#### Editing commits
Expand All @@ -221,4 +235,4 @@ If it’s complex:
- Make sure to run `yarn precommit && git rebase --continue` before commiting changes.
- You can even create whole new commits in this mode (omit `--amend`!

[Back to the top](#--commit-rules)
[Back to the top](#--commit-rules)
Loading