Skip to content

Commit

Permalink
Add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
will-molloy committed Jun 24, 2024
1 parent 5a18a61 commit f4c3f48
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended'
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
Expand All @@ -14,5 +15,6 @@ module.exports = {
'warn',
{ allowConstantExport: true },
],
'prettier/prettier': 'error'
},
}
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
name: build
path: ./build

# TODO need to figure this out again
# TODO need to figure this out again - build changed to dist?
deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
publish_branch: gh-pages
publish_dir: ./build

# TODO move to separate workflow, see java-template
# TODO move to separate workflow? see java-template
release:
needs: deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
endOfLine: lf
printWidth: 100
tabWidth: 2
useTabs: false
trailingComma: es5
semi: true
singleQuote: true
jsxSingleQuote: false
arrowParens: always
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ template repo for React projects
- React + Typescript + [Vite](https://vitejs.dev/)
- [pnpm](https://pnpm.io/)
- [GitHub Actions](https://github.com/features/actions) CICD, with deployment to [GitHub Pages](https://pages.github.com/)
- Code linting/formatting via [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/)
- Code linting/formatting via [ESLint](https://eslint.org/), [Prettier](https://prettier.io/) and StyleLint (TODO)
- Test support via [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/react)
- Code coverage reporting via [Codecov](https://codecov.io/)
- Dependency upgrades via [Renovate bot](https://renovatebot.com)
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"prettier": "^3.3.2",
"typescript": "^5.2.2",
"vite": "^5.3.1"
}
Expand Down
82 changes: 82 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useState } from 'react';
import reactLogo from './assets/react.svg';
import viteLogo from '/vite.svg';
import './App.css';

function App() {
const [count, setCount] = useState(0)
const [count, setCount] = useState(0);

return (
<>
Expand All @@ -18,18 +18,14 @@ function App() {
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<button onClick={() => setCount((count) => count + 1)}>count is {count}</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<p className="read-the-docs">Click on the Vite and React logos to learn more</p>
</>
)
);
}

export default App
export default App;
12 changes: 6 additions & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
</React.StrictMode>
);
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
});

0 comments on commit f4c3f48

Please sign in to comment.