Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expense App #35

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
68 changes: 68 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
env: {
es6: true,
browser: true
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:prettier/recommended',
'plugin:jsx-a11y/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
project: './tsconfig.json',
ecmaVersion: 12,
sourceType: 'module'
},
plugins: ['react', 'react-hooks', '@typescript-eslint', 'jsx-a11y'],
rules: {
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx']
}
],
'react/prop-types': ['off', {}],
'react/react-in-jsx-scope': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'no-console': [
'error',
{
allow: ['warn', 'error']
}
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'spaced-comment': ['error', 'always'],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.ts', '**/*.test.tsx', '**/*.stories.tsx'],
peerDependencies: true
}
],
'import/no-named-as-default': 0,
'import/extensions': [
'warn',
'ignorePackages',
{
js: 'never',
ts: 'never',
jsx: 'never',
tsx: 'never'
}
]
},
settings: {
react: {
version: 'detect'
}
}
};
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Workflow name
name: Deploy Application

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# List of jobs
jobs:
job1:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install Dependenciess
run: npm install
- name: Run Build
run: |
npm run build
- name: deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# dependencies
node_modules

# testing
coverage

# dev
dist

# production
build
storybook-static

# misc
.env
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"

npm run typecheck && npm run lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
22 changes: 22 additions & 0 deletions .jest/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = (path, options) => {
// Call the defaultResolver, so we leverage its cache, error handling, etc.
return options.defaultResolver(path, {
...options,
// Use packageFilter to process parsed `package.json` before
// the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
packageFilter: pkg => {
// jest-environment-jsdom 28+ tries to use browser exports instead of default exports,
// but @hookform/resolvers only offers an ESM browser export and not a CommonJS one. Jest does not yet
// support ESM modules natively, so this causes a Jest error related to trying to parse
// "export" syntax.
//
// This workaround prevents Jest from considering @hookform/resolvers module-based exports at all;
// it falls back to CommonJS+node "main" property.
if (pkg.name === '@hookform/resolvers' || pkg.name === 'uuid') {
delete pkg['exports'];
delete pkg['module'];
}
return pkg;
}
});
};
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"src/**/*.{ts,tsx}": [
"prettier --write",
"eslint --fix"
]
}
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"jsxSingleQuote": false,
"semi": true,
"tabWidth": 2,
"bracketSpacing": true,
"arrowParens": "avoid",
"trailingComma": "none",
"useTabs": false,
"quoteProps": "as-needed"
}
26 changes: 26 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
collectCoverage: true,
silent: true,
coverageDirectory: 'coverage',
testPathIgnorePatterns: ['<rootDir>/dist'],
setupFilesAfterEnv: ['<rootDir>/jestImports.ts'],
modulePathIgnorePatterns: ['<rootDir>/dist/'],
coverageProvider: 'v8',
moduleNameMapper: {
'^.+\\.(css|less|scss)$': 'babel-jest'
},
collectCoverageFrom: ['<rootDir>/src/**/*.{ts,tsx}'],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules',
'<rootDir>/src/store',
'<rootDir>/src/types',
'<rootDir>/src/constants.ts',
'<rootDir>/src/index.ts',
'<rootDir>/src/App.tsx',
'<rootDir>/src/data.ts'
],
// https://github.com/react-hook-form/resolvers/issues/396
resolver: '<rootDir>/.jest/resolver.js'
};
4 changes: 4 additions & 0 deletions jestImports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import '@testing-library/jest-dom';
import { enableFetchMocks } from 'jest-fetch-mock';

enableFetchMocks();
Loading