Skip to content

Commit 91b4fbd

Browse files
committed
feat: Install and configure prettier for consistant formatting
1 parent 705386e commit 91b4fbd

File tree

9 files changed

+41
-18
lines changed

9 files changed

+41
-18
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 2,
4+
"arrowParens": "avoid",
5+
"jsxBracketSameLine": true,
6+
"bracketSameLine": true
7+
}

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"eslint-plugin-react-hooks": "^4.6.2",
2828
"eslint-plugin-react-refresh": "^0.4.7",
2929
"jsdom": "^24.1.0",
30+
"prettier": "^3.3.1",
3031
"start-server-and-test": "^2.0.4",
3132
"typescript": "~5.4.5",
3233
"vite": "^5.2.12",
@@ -35,6 +36,7 @@
3536
"scripts": {
3637
"dev": "vite --port 3000",
3738
"build": "tsc && vite build",
39+
"format": "prettier --write \"**/*.{ts,tsx,md,css,scss}\"",
3840
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
3941
"preview": "vite preview --port 3000",
4042
"test": "vitest run --coverage",

src/components/Header.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { FC } from 'react';
22

33
export const Header: FC = () => (
4-
<div className='App'>
5-
<header className='App-header'>
6-
<img src='./logo.svg' className='App-logo' alt='logo' />
7-
<h1 className='App-title'>Welcome to JSON Forms with React</h1>
8-
<p className='App-intro'>More Forms. Less Code.</p>
4+
<div className="App">
5+
<header className="App-header">
6+
<img src="./logo.svg" className="App-logo" alt="logo" />
7+
<h1 className="App-title">Welcome to JSON Forms with React</h1>
8+
<p className="App-intro">More Forms. Less Code.</p>
99
</header>
1010
</div>
1111
);

src/components/JsonFormsDemo.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,18 @@ export const JsonFormsDemo: FC = () => {
6464
container
6565
justifyContent={'center'}
6666
spacing={1}
67-
style={classes.container}
68-
>
67+
style={classes.container}>
6968
<Grid item sm={6}>
7069
<Typography variant={'h4'}>Bound data</Typography>
7170
<div style={classes.dataContent}>
72-
<pre id='boundData'>{stringifiedData}</pre>
71+
<pre id="boundData">{stringifiedData}</pre>
7372
</div>
7473
<Button
7574
style={classes.resetButton}
7675
onClick={clearData}
77-
color='primary'
78-
variant='contained'
79-
data-testid='clear-data'
80-
>
76+
color="primary"
77+
variant="contained"
78+
data-testid="clear-data">
8179
Clear data
8280
</Button>
8381
</Grid>

src/components/Rating.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@ export const Rating: FC<RatingProps> = ({ id, value, updateValue }) => {
1111
const [hoverAt, setHoverAt] = useState<number | null>(null);
1212

1313
return (
14-
<div id='#/properties/rating' className='rating'>
14+
<div id="#/properties/rating" className="rating">
1515
<InputLabel shrink style={{ marginTop: '0.8em' }}>
1616
Rating
1717
</InputLabel>
1818
<div style={{ cursor: 'pointer', fontSize: '18px' }}>
19-
{[0, 1, 2, 3, 4].map((i) => {
19+
{[0, 1, 2, 3, 4].map(i => {
2020
const fullStars = hoverAt ?? value;
2121

2222
return (
2323
<span
2424
onMouseOver={() => setHoverAt(i + 1)}
2525
onMouseOut={() => setHoverAt(null)}
2626
onClick={() => updateValue(i + 1)}
27-
key={`${id}_${i}`}
28-
>
27+
key={`${id}_${i}`}>
2928
{i < fullStars ? '\u2605' : '\u2606'}
3029
</span>
3130
);

src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ createRoot(rootEl).render(
2828
<CssBaseline />
2929
<App />
3030
</ThemeProvider>
31-
</StrictMode>
31+
</StrictMode>,
3232
);

src/ratingControlTester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { rankWith, scopeEndsWith } from '@jsonforms/core';
22

33
export default rankWith(
44
3, //increase rank as needed
5-
scopeEndsWith('rating')
5+
scopeEndsWith('rating'),
66
);

0 commit comments

Comments
 (0)