Skip to content

Commit 325a62e

Browse files
authored
Migrate to using Vite (code4recovery#487)
* vite * use vitest generate lcov set node version Add helper test * Add pettier Add pettier migrate prettier globals rm babel config * add terser * update compiler target, eslint config use iife simplify config * update contributing notes fix doc numbering * add lint action step
1 parent d06d75f commit 325a62e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6966
-15533
lines changed

.eslintrc.js

Lines changed: 0 additions & 91 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,27 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
1515

1616
- name: Setup Node
17-
uses: actions/setup-node@v4
17+
uses: actions/setup-node@v6
1818
with:
1919
node-version: '22'
2020
cache: 'npm'
2121
- run: npm install
22+
23+
- name: Check Prettier formatting
24+
run: npx prettier --check src/
25+
# Let fail for now
26+
continue-on-error: true
27+
28+
- name: Run ESLint
29+
run: npx eslint src/
30+
# Let fail for now
31+
continue-on-error: true
32+
2233
- run: npm run test-coverage
23-
- run: npx mix --production
34+
- run: npm run build
2435

2536
- name: Coveralls
2637
uses: coverallsapp/github-action@master

.prettierrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,14 @@ Contributions are welcome. Ideally, please join [Code for Recovery](https://code
268268
Here are the steps to follow when developing:
269269

270270
1. clone (or, if you are not a member, fork and clone) this repository
271-
1. create a branch for your changes
272-
1. run `npm i` in the project folder (install NPM if it is not installed)
273-
1. run `npm run serve` in one terminal window (or use another solution to serve files locally)
274-
1. run `npx mix watch` in another terminal window (this updates files in development as you change them)
275-
1. confirm your changes at, for example, `http://localhost:3000/tests/aasanjose` (there are a number of examples in that folder)
271+
2. create a branch for your changes
272+
3. run `npm i` in the project folder (install NPM if it is not installed)
273+
4. run `npm run dev` to start the Vite dev server with HMR at `index.html`
274+
5. to test other examples in `public/tests/`, run `npm run preview` after building
276275

277276
When you are ready to make a PR:
278277

279278
1. clean up your diff, try to change as few lines as possible
280-
1. run prettier locally to autoformat your files
281-
1. alphabetize things like component props and CSS rules (if applicable)
282-
1. run `npx mix --production` to minify files
279+
2. run prettier locally to autoformat your files
280+
3. alphabetize things like component props and CSS rules (if applicable)
281+
4. run `npm run build` to create the production bundle

babel.config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

eslint.config.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals'
3+
import ts from 'typescript-eslint';
4+
import reactPlugin from 'eslint-plugin-react';
5+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
6+
import reactRefresh from 'eslint-plugin-react-refresh'
7+
import { defineConfig, globalIgnores } from 'eslint/config';
8+
9+
export default defineConfig([
10+
globalIgnores(['public']),
11+
{
12+
files: ['**/*.{ts,tsx}'],
13+
extends: [
14+
js.configs.recommended,
15+
...ts.configs.recommended,
16+
reactPlugin.configs.flat.recommended,
17+
reactHooksPlugin.configs.flat.recommended,
18+
reactRefresh.configs.vite,
19+
reactPlugin.configs.flat['jsx-runtime'],
20+
],
21+
languageOptions: {
22+
parserOptions: {
23+
ecmaFeatures: {
24+
jsx: true,
25+
},
26+
ecmaVersion: 2020,
27+
sourceType: 'module',
28+
},
29+
globals: {
30+
...globals.browser,
31+
// Custom globals
32+
Lang: 'readonly',
33+
TSMLReactConfig: 'readonly',
34+
Translation: 'readonly',
35+
},
36+
},
37+
settings: {
38+
react: {
39+
version: 'detect',
40+
},
41+
},
42+
rules: {
43+
'react/jsx-uses-react': 'off',
44+
'react/react-in-jsx-scope': 'off',
45+
'react/no-unknown-property': ['error', { ignore: ['css'] }],
46+
'no-unused-vars': [
47+
'error',
48+
{
49+
argsIgnorePattern: '^_',
50+
varsIgnorePattern: '^_',
51+
caughtErrorsIgnorePattern: '^_',
52+
},
53+
],
54+
// Turning these off for now to clean up warnings
55+
'react-refresh/only-export-components': 'off',
56+
'react-hooks/exhaustive-deps': 'off',
57+
'react-hooks/set-state-in-effect': 'off',
58+
'react-hooks/immutability': 'off',
59+
'react-hooks/preserve-manual-memoization': 'off'
60+
},
61+
},
62+
]);

index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>TSML UI - Development</title>
7+
</head>
8+
<body>
9+
<div
10+
id="tsml-ui"
11+
data-src="https://sheets.code4recovery.org/storage/12Ga8uwMG4WJ8pZ_SEU7vNETp_aQZ-2yNVsYDFqIwHyE.json"
12+
data-timezone="America/New_York"
13+
></div>
14+
<script type="module" src="/src/app.tsx"></script>
15+
</body>
16+
</html>

jest.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

jest.setup.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

netlify.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[build]
22
publish = "public/"
3-
command = "npx mix --production"
3+
command = "npm run build"
4+
5+
[build.environment]
6+
NODE_VERSION = "20"
47

0 commit comments

Comments
 (0)