-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding detailed README and cleanup (#12)
- Loading branch information
1 parent
7c0e118
commit 154cd87
Showing
12 changed files
with
182 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
ignore = E501,E731,W503 | ||
exclude = | ||
.chalice | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
frontend: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
python-version: ['3.11'] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Node ${{ matrix.node-version }}.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Check if package-lock.json is up to date | ||
run: | | ||
npx --yes [email protected] | ||
- name: Lint frontend code with ESLint | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
npm ci | ||
npm run lint-frontend | ||
backend: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
python-version: ['3.11'] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Node ${{ matrix.node-version }}.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Check if package-lock.json is up to date | ||
run: | | ||
npx --yes [email protected] | ||
- name: Lint backend code with Flake8 | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
npm ci | ||
npm run lint-backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"eslint.enable": true, | ||
"eslint.format.enable": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"editor.formatOnSave": true, | ||
"python.analysis.typeCheckingMode": "off", | ||
"python.formatting.provider": "black", | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,51 @@ | ||
# React + TypeScript + Vite | ||
# TransitMatters Shutdown Tracker | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
This is the repository for the TransitMatters Shutdown Tracker. Client code is written in Typescript with React and vite, and the minimal backend is written in Python with Chalice. | ||
|
||
Currently, two official plugins are available: | ||
## Requirements to develop locally | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
- node 20.x and npm 10+ required | ||
- With `nvm` installed, use `nvm install && nvm use` | ||
- verify with `node -v` | ||
- Python 3.11 with recent poetry (1.6.0 or later) | ||
- Verify with `python --version && poetry --version` | ||
- `poetry self update` to update poetry | ||
- If using `pyenv`, `pyenv install 3.11.7` | ||
|
||
## Expanding the ESLint configuration | ||
## Development Instructions | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
1. In the root directory, run `npm install` to install all frontend and backend dependencies | ||
2. Run `npm start` to start both the Vite development server and the Python backend at the same time. | ||
1. `npm run dev` to just run the Vite development server | ||
2. `npm run start-python` to just run the Chalice backend server | ||
3. Navigate to [http://localhost:3000](http://localhost:3000) (or the url provided after running `npm start`) | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
## Deployment Instructions | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
``` | ||
1. Configure AWS CLI 1.x or 2.x with your AWS access key ID and secret under the profile name `transitmatters`. | ||
2. Configure shell environment variables for AWS ACM domain certificates. | ||
- `TM_LABS_WILDCARD_CERT_ARN` | ||
- (You may also need to set `AWS_DEFAULT_REGION` in your shell to `us-east-1`. Maybe not! We're not sure.) | ||
- `DD_API_KEY` (Datadog API key, needed to deploy to TransitMatters stack in prod) | ||
3. Execute `./deploy.sh`. | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list | ||
#### Additional notes: | ||
|
||
- If you're on a platform with a non-GNU `sed`, deploy.sh might fail. On macOS, this is fixed by `brew install gnu-sed` and adding it to your PATH. | ||
- If you get an unexplained error, check the CloudFormation stack status in AWS Console. Good luck! | ||
|
||
### Linting | ||
|
||
To lint frontend and backend code, run `npm run lint` in the root directory | ||
|
||
To lint just frontend code, run `npm run lint-frontend` | ||
|
||
To lint just backend code, run `npm run lint-backend` | ||
|
||
#### VSCode | ||
|
||
If you're using VSCode, `.vscode` contains a based default workspace setup. It also includes recommended extentions that will improve the dev experience. This config is meant to be as small as possible to enable an "out of the box" easy experience for handling eslint. | ||
|
||
## Support TransitMatters | ||
|
||
If you've found this app helpful or interesting, please consider [donating](https://transitmatters.org/donate) to TransitMatters to help support our mission to provide data-driven advocacy for a more reliable, sustainable, and equitable transit system in Metropolitan Boston. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.