Skip to content

Commit a8d6608

Browse files
authored
Vite migration from CRA (#8)
* vite migration * workflow for deploy upon merge and other action enhancements * tests * npm updated * update for new vite versions
1 parent ec58601 commit a8d6608

20 files changed

Lines changed: 8854 additions & 24653 deletions

.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
["@babel/preset-react", { "runtime": "automatic" }]
5+
]
6+
}

.eslint.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"jest": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:prettier/recommended",
10+
"plugin:react/recommended",
11+
"plugin:cypress/recommended"
12+
],
13+
"parserOptions": {
14+
"ecmaFeatures": {
15+
"jsx": true
16+
},
17+
"ecmaVersion": "latest",
18+
"sourceType": "module"
19+
},
20+
"plugins": ["prettier", "react", "react-hooks", "import"],
21+
"rules": {
22+
"no-restricted-globals": "off",
23+
"prettier/prettier": [
24+
"error",
25+
{
26+
"endOfLine": "auto"
27+
}
28+
],
29+
"jsx-quotes": ["error", "prefer-double"],
30+
"quotes": [
31+
"error",
32+
"single",
33+
{
34+
"avoidEscape": true
35+
}
36+
],
37+
"object-shorthand": ["warn", "always"],
38+
"react/display-name": "warn",
39+
"react/jsx-no-useless-fragment": [
40+
"warn",
41+
{
42+
"allowExpressions": true
43+
}
44+
],
45+
"react/prop-types": "warn",
46+
"react/jsx-uses-react": "off",
47+
"react/react-in-jsx-scope": "off",
48+
"react/self-closing-comp": "warn",
49+
"react/jsx-curly-brace-presence": [
50+
"warn",
51+
{
52+
"props": "never",
53+
"children": "ignore",
54+
"propElementValues": "always"
55+
}
56+
],
57+
"react-hooks/rules-of-hooks": "warn",
58+
"react-hooks/exhaustive-deps": "warn",
59+
"sort-imports": [
60+
"error",
61+
{
62+
"ignoreCase": false,
63+
"ignoreDeclarationSort": true
64+
}
65+
],
66+
"import/order": [
67+
1,
68+
{
69+
"groups": [
70+
"external",
71+
"builtin",
72+
"internal",
73+
"sibling",
74+
"parent",
75+
"index"
76+
],
77+
"alphabetize": {
78+
"order": "asc",
79+
"caseInsensitive": true
80+
}
81+
}
82+
],
83+
"import/no-duplicates": "warn"
84+
},
85+
"settings": {
86+
"react": {
87+
"version": "detect"
88+
},
89+
"import/resolver": {
90+
"node": {
91+
"paths": ["**/src"],
92+
"extensions": [".js", ".jsx"]
93+
}
94+
}
95+
}
96+
}

.eslintrc.cjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:react/recommended',
7+
'plugin:react/jsx-runtime',
8+
'plugin:react-hooks/recommended',
9+
],
10+
ignorePatterns: ['dist', '.eslintrc.cjs'],
11+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
12+
settings: { react: { version: '18.2' } },
13+
plugins: ['react-refresh'],
14+
rules: {
15+
'react-refresh/only-export-components': [
16+
'warn',
17+
{ allowConstantExport: true },
18+
],
19+
},
20+
}

.github/dependabot.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: 'monthly'
12+
groups:
13+
jest:
14+
patterns:
15+
- 'jest*'
16+
eslint:
17+
patterns:
18+
- 'eslint*'
19+
20+
- package-ecosystem: github-actions
21+
directory: /
22+
schedule:
23+
interval: 'monthly'
24+
groups:
25+
artifact-actions:
26+
patterns:
27+
- 'actions/*-artifact*' # Upload/Download usually need to be updated together

.github/workflows/deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths: 'src/**'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Setup Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 20
18+
cache: 'npm'
19+
cache-dependency-path: './package-lock.json'
20+
- run: npm ci
21+
- run: npm run build --if-present
22+
- name: Deploy
23+
uses: crazy-max/ghaction-github-pages@v3
24+
with:
25+
target_branch: gh-pages
26+
build_dir: dist
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/node.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,12 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
- name: Use Node.js ${{ matrix.node-version }}
17+
- name: Setup Node
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: 16
20+
node-version: 20
2121
cache: 'npm'
2222
cache-dependency-path: './package-lock.json'
2323
- run: npm ci
2424
- run: npm run build --if-present
25-
- run: npm test
26-
- name: Deploy
27-
uses: crazy-max/ghaction-github-pages@v3
28-
with:
29-
target_branch: gh-pages
30-
build_dir: build
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- run: npm run test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/coverage
1010

1111
# production
12-
/build
12+
/dist
1313

1414
# misc
1515
.DS_Store

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"diffEditor.codeLens": true,
33
"editor.codeActionsOnSave": {
4-
"source.fixAll.eslint": true
4+
"source.fixAll.eslint": "explicit"
55
},
66
"editor.formatOnSave": true,
77
"eslint.format.enable": true,

index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="icon"
7+
type="image/svg+xml"
8+
href="/vite.svg" />
9+
<meta name="viewport"
10+
content="width=device-width, initial-scale=1.0" />
11+
<title>Timer</title>
12+
</head>
13+
14+
<body>
15+
<div id="root"></div>
16+
<script type="module"
17+
src="/src/main.jsx"></script>
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)