Skip to content

Commit

Permalink
Merge pull request #425 from popcorndao/pre-commit-hook
Browse files Browse the repository at this point in the history
Pre commit hook
  • Loading branch information
mefuru authored Sep 2, 2021
2 parents 1f75781 + ae9ccf8 commit d784ebf
Show file tree
Hide file tree
Showing 612 changed files with 16,419 additions and 8,286 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/run-coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -19,19 +18,19 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: canastro/copy-file-action@master
name: "copy env file"
name: 'copy env file'
with:
source: .env.example
target: .env
- uses: borales/[email protected]
name: "yarn install"
name: 'yarn install'
with:
cmd: install # will run `yarn install` command
- uses: borales/[email protected]
name: "build"
name: 'build'
with:
cmd: app:build # will run `yarn app:build` command
- uses: borales/[email protected]
name: "solidity coverage"
name: 'solidity coverage'
with:
cmd: coverage
9 changes: 4 additions & 5 deletions .github/workflows/run-fork-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -19,20 +18,20 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: canastro/copy-file-action@master
name: "copy env file"
name: 'copy env file'
with:
source: .env.example
target: .env
- uses: borales/[email protected]
name: "yarn install"
name: 'yarn install'
with:
cmd: install # will run `yarn install` command
- uses: borales/[email protected]
name: "build"
name: 'build'
with:
cmd: app:build # will run `yarn app:build` command
- uses: borales/[email protected]
name: "run tests"
name: 'run tests'
with:
cmd: test:fork
env:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -19,19 +18,19 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: canastro/copy-file-action@master
name: "copy env file"
name: 'copy env file'
with:
source: .env.example
target: .env
- uses: borales/[email protected]
name: "yarn install"
name: 'yarn install'
with:
cmd: install # will run `yarn install` command
- uses: borales/[email protected]
name: "build"
name: 'build'
with:
cmd: app:build # will run `yarn app:build` command
- uses: borales/[email protected]
name: "run tests"
name: 'run tests'
with:
cmd: test
cmd: test
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
18 changes: 7 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,22 @@
],
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": true,
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": true,
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.formatOnSave": true
},
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"prettier.eslintIntegration": true,
"javascript.validate.enable": true,
// "diffEditor.ignoreTrimWhitespace": true,
"editor.rulers": [
80,
120
],
"cSpell.words": [
]
}
"editor.rulers": [80, 120],
"cSpell.words": []
}
33 changes: 16 additions & 17 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Contributor Covenant Code of Conduct

## Our Pledge
Expand All @@ -18,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +105,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand All @@ -118,15 +117,15 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][mozilla coc].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
[https://www.contributor-covenant.org/faq][faq]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[mozilla coc]: https://github.com/mozilla/diversity
[faq]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
40 changes: 20 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Contributing


Welcome aboard as an Popcorn developer.

This document will get you up to speed on our expectations for contributing to the codebase. Please read through this and our [code of conduct](./CODE_OF_CONDUCT.md).


## Style guide

If you elect to use VS Code, maintaining a consistent style is easy because of the prettier integration.
Expand All @@ -14,51 +12,53 @@ Regardless, please ensure that you are using 2 space tabs.

## Inclusive language: replacement terms

In an effort to develop software with language free from expressions or words that reflect prejudice the following terminology is recommended instead of blacklist/whitelist and master/slave:
In an effort to develop software with language free from expressions or words that reflect prejudice the following terminology is recommended instead of blacklist/whitelist and master/slave:

Replace blacklist/whitelist with:

```
blocklist / allowlist
exclude list / include list
avoid list / prefer list
```

Replace master/slave with:

```
leading / subordinate
source / replica
```



## Recommended Tools:
- `vscode` - because we are using typescript this is very important to download. It makes the development experience much easier. free download available here: https://code.visualstudio.com/
- recommended plugins:
- gitlens
- Move TS
- ESLint
- Docker
- Prettier
- Todo Tree
- TSLint

- `vscode` - because we are using typescript this is very important to download. It makes the development experience much easier. free download available here: https://code.visualstudio.com/
- recommended plugins:
- gitlens
- Move TS
- ESLint
- Docker
- Prettier
- Todo Tree
- TSLint

## Git flow - submitting features/bugs:

- New features are branched off of `develop`. To create a new feature, create a new branch off of develop with the name: `feature/name-of-feature`
- To submit a bug fix create a new branch off of develop with the name `bugfix/name-of-bug`
- When your feature is ready for QA, create a pull request and share a link to the pull request

## Code standards

- All code is subject to review. If it does not meet quality standards, it may not be merged until the issues are addressed;

### General guidelines:
### General guidelines:

*Function length*: functions should __rarely be greater than 20 lines of code__. Exceptions can be made. Please do not submit a PR unless the code has been refactored in an attempt to meet this standard.
_Function length_: functions should **rarely be greater than 20 lines of code**. Exceptions can be made. Please do not submit a PR unless the code has been refactored in an attempt to meet this standard.

*Declarative vs imperative* - When possible aim to write declarative code. https://tylermcginnis.com/imperative-vs-declarative-programming/
_Declarative vs imperative_ - When possible aim to write declarative code. https://tylermcginnis.com/imperative-vs-declarative-programming/

*Use classes or es6 modules* - Use classes or es6 modules to contain your code - https://exploringjs.com/es6/ch_modules.html#sec_basics-of-es6-modules
_Use classes or es6 modules_ - Use classes or es6 modules to contain your code - https://exploringjs.com/es6/ch_modules.html#sec_basics-of-es6-modules

*const vs let vs var* - Always prefer `let` over `var`. Always prefer `const` to `let` when a variable does not need to be reassigned. Avoid variable reassignment. This makes code easier to understand and less prone to bugs.
_const vs let vs var_ - Always prefer `let` over `var`. Always prefer `const` to `let` when a variable does not need to be reassigned. Avoid variable reassignment. This makes code easier to understand and less prone to bugs.

*any types* - when writing in typescript avoid using `any` types - always create interfaces for the inputs and outputs of your functions. On very rare occassions it is ok to use `any`.
_any types_ - when writing in typescript avoid using `any` types - always create interfaces for the inputs and outputs of your functions. On very rare occassions it is ok to use `any`.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ Deploy from `packages/contracts`:
## Useful Hardhat Commands
| Command | Description |
| -------------------------------------------------------------------------- | -------------------------------- |
| `yarn hardhat dev:deploy` | deploy contracts for development |
| `yarn hardhat elections:refreshElectionState --term 1 --network localhost` | refresh election state |
| `yarn hardhat elections:getElectionMetadata --term 1 --network localhost` | get metadata for election term |
| `yarn lerna run --scope @popcorn/contracts docify` | generate documentation for contracts (found in packages/contracts/docgen/docs)|
| Command | Description |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| `yarn hardhat dev:deploy` | deploy contracts for development |
| `yarn hardhat elections:refreshElectionState --term 1 --network localhost` | refresh election state |
| `yarn hardhat elections:getElectionMetadata --term 1 --network localhost` | get metadata for election term |
| `yarn lerna run --scope @popcorn/contracts docify` | generate documentation for contracts (found in packages/contracts/docgen/docs) |
## Contributing
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
"app:build": "yarn lerna run --scope={@popcorn/app,@popcorn/contracts} build",
"app:start": "yarn lerna run --scope @popcorn/app start",
"start": "yarn lerna run --scope @popcorn/app start",
"pretify": "prettier --write .",
"prettify": "prettier --write .",
"test": "yarn lerna run test",
"test:fork": "yarn lerna run test:fork",
"coverage": "yarn lerna run coverage",
"netlify-build": "lerna run --scope @popcorn/contracts compile; cd packages/app; yarn next build"
"netlify-build": "lerna run --scope @popcorn/contracts compile; cd packages/app; yarn next build",
"prepare": "husky install"
},
"lint-staged": {
"*.{tsx,css,md,json,ts,jsx,js,sol}": "prettier --write"
},
"dependencies": {
"@netlify/plugin-nextjs": "^3.3.1",
Expand All @@ -26,7 +30,9 @@
"@babel/core": "^7.10.3",
"babel-jest": "^26.1.0",
"babel-plugin-module-resolver": "4.0.0",
"husky": "^7.0.0",
"jest": "^26.1.0",
"lint-staged": ">=10",
"prettier": "^2.0.5",
"tsconfig-paths": "3.9.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/app/__test__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import Index from '../pages/index';

describe('Index page', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/Beneficiaries/BeneficiaryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Displays a beneficiary or a preview of a proposal

import { BeneficiaryApplication } from '@popcorn/contracts/adapters';
import BeneficiaryInformation from 'components/CommonComponents/BeneficiaryInformation';
import ImageHeader from 'components/CommonComponents/ImageHeader';
import VideoSideBar from 'components/CommonComponents/VideoSideBar';
import NavBar from 'components/NavBar/NavBar';
import { BeneficiaryApplication } from '@popcorn/contracts/adapters';
import PhotoSideBar from '../CommonComponents/PhotoSideBar';
import TriggerTakedownProposal from '../CommonComponents/TriggerTakedownProposal';

Expand Down
5 changes: 1 addition & 4 deletions packages/app/components/CommonComponents/ImageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ export interface ImageHeaderProps {
title?: string;
}

const ImageHeader: React.FC<ImageHeaderProps> = ({
beneficiary,
title,
}) => {
const ImageHeader: React.FC<ImageHeaderProps> = ({ beneficiary, title }) => {
return (
<div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/Grants/ElectionProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PendingVotes, Vote } from 'pages/grant-elections/[type]';
import { ElectionMetadata } from '@popcorn/contracts/adapters';
import { PendingVotes, Vote } from 'pages/grant-elections/[type]';

export interface ElectionProps {
election: ElectionMetadata;
Expand Down
8 changes: 5 additions & 3 deletions packages/app/components/Grants/GrantRound.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
IpfsClient,
} from '@popcorn/utils';
import { ElectionMetadata, BeneficiaryRegistryAdapter, BeneficiaryApplication } from '@popcorn/contracts/adapters';
BeneficiaryApplication,
BeneficiaryRegistryAdapter,
ElectionMetadata,
} from '@popcorn/contracts/adapters';
import { IpfsClient } from '@popcorn/utils';
import { ContractsContext } from 'context/Web3/contracts';
import { BigNumber, utils } from 'ethers';
import { PendingVotes, Vote, Votes } from 'pages/grant-elections/[type]';
Expand Down
Loading

0 comments on commit d784ebf

Please sign in to comment.