-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace CRA with ViteJS and improve dev setup (#119)
- Replace react-scripts with vite for better build and live reload speed - Set up vitest for unit testing - Updated dependencies to latest - Setup ESLint as per vite - Set up prettier for consistent code formatting - Refactor for better readability and maintainability - Fix lint issues - Fix cypress test - Execute ci in pull requests and add linting to ci --------- Co-authored-by: Lucas Koehler <[email protected]>
- Loading branch information
1 parent
dbbd4d9
commit e99d3bf
Showing
27 changed files
with
5,027 additions
and
20,368 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,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
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,14 +1,23 @@ | ||
name: Build & Test | ||
on: push | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
main: | ||
name: Main | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '10.x' | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npm run lint | ||
- run: npm run build | ||
- run: npm run cypress:ci |
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 @@ | ||
package-lock.json |
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 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"arrowParens": "avoid", | ||
"jsxBracketSameLine": true, | ||
"bracketSameLine": true | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"prettier.jsxSingleQuote": true, | ||
"prettier.singleQuote": true | ||
} | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"prettier.jsxSingleQuote": true, | ||
"prettier.singleQuote": true | ||
} |
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,12 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
// We've imported your old cypress plugins here. | ||
// You may want to clean this up later by importing these. | ||
setupNodeEvents(on, config) { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
return require('./cypress/plugins/index.js')(on, config); | ||
}, | ||
}, | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// <reference types="Cypress" /> | ||
|
||
context('Form', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:3000/'); | ||
}); | ||
|
||
it('should change input values', () => { | ||
const nameText = 'John Deer'; | ||
const descText = 'This is a desc test'; | ||
const recurrenceIntervalText = 10; | ||
const dateText = '2001-03-15'; | ||
|
||
cy.get('[id="#/properties/name-input"]').clear().type(nameText); | ||
cy.get('[id="#/properties/description-input"]').clear().type(descText); | ||
cy.get('[id="#/properties/done-input"]').uncheck(); | ||
cy.get('[id="#/properties/recurrence"]').parent().click(); | ||
cy.get('[id="#/properties/recurrence-option-3"]').click(); // Monthly | ||
cy.get('[id="#/properties/recurrence_interval-input"]') | ||
.clear() | ||
.type(recurrenceIntervalText); | ||
cy.get('[id="#/properties/due_date-input"]').clear().type(dateText); | ||
cy.get('[id="#/properties/rating"] span:last').click(); | ||
cy.get('[id="boundData"]') | ||
.invoke('text') | ||
.then(content => { | ||
const data = JSON.parse(content); | ||
|
||
expect(data.name).to.equal(nameText); | ||
cy.get('[id="#/properties/name"] p').should('be.empty'); | ||
|
||
cy.get('[id="#/properties/recurrence_interval"]').should('exist'); | ||
|
||
expect(data.description).to.equal(descText); | ||
expect(data.done).to.equal(false); | ||
expect(data.recurrence).to.equal('Monthly'); | ||
expect(data.recurrence_interval).to.equal(recurrenceIntervalText); | ||
expect(data.due_date).to.equal(dateText); | ||
expect(data.rating).to.equal(5); | ||
}); | ||
}); | ||
|
||
it('should show errors', () => { | ||
cy.get('[id="#/properties/name-input"]').clear(); | ||
|
||
cy.get('[id="#/properties/name"] p:first-child').should('not.be.empty'); | ||
|
||
cy.get('[id="#/properties/due_date-input"]').clear().type('351'); | ||
|
||
cy.get('[id="#/properties/due_date"] p:first-child').should('not.be.empty'); | ||
|
||
cy.get('[id="#/properties/recurrence"]').parent().click(); | ||
cy.get('[id="#/properties/recurrence-option-0"]').click(); // Never | ||
|
||
cy.get('[id="#/properties/recurrence_interval"]').should('not.exist'); | ||
|
||
cy.get('[id="boundData"]') | ||
.invoke('text') | ||
.then(content => { | ||
const data = JSON.parse(content); | ||
|
||
// expect(data.due_date).to.equal('Invalid date'); <- Mui doesn't allow setting invalid date | ||
expect(data.due_date).to.equal(undefined); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>JSONForms React Starter</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.