Skip to content

Commit 08b0a84

Browse files
authored
Merge pull request #773 from bcgov/anton/cats-prettier
chore: CATS FE - format with `prettier`, add formatting CI step
2 parents b3e8682 + accf091 commit 08b0a84

File tree

85 files changed

+1877
-1773
lines changed

Some content is hidden

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

85 files changed

+1877
-1773
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Prettier Format
2+
3+
on:
4+
pull_request:
5+
branches: [dev]
6+
7+
jobs:
8+
prettier:
9+
runs-on: ubuntu-latest
10+
defaults:
11+
run:
12+
working-directory: cats-frontend
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
ref: ${{ github.head_ref }}
20+
persist-credentials: false
21+
22+
- name: CATS-Frontend Prettify code
23+
uses: creyD/prettier_action@v4.3
24+
with:
25+
prettier_options: --check ./cats-frontend/src/**/*.{js,ts,jsx,tsx,json,css} --ignore-path ./cats-frontend/.prettierignore --config ./cats-frontend/.prettierrc
26+
only_changed: True
27+
dry: True
28+
29+
- name: Formatting issues found
30+
if: failure()
31+
run: echo "::warning::Code formatting check failed. Try running npm run format in the project that caused the error and commit your changes"

cats-frontend/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/generated.ts

cats-frontend/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"endOfLine": "auto"
5+
}

cats-frontend/babel.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module.exports = {
22
presets: [
3-
"@babel/preset-typescript",
4-
"@babel/preset-env",
5-
["@babel/preset-react", { runtime: "automatic" }],
3+
'@babel/preset-typescript',
4+
'@babel/preset-env',
5+
['@babel/preset-react', { runtime: 'automatic' }],
66
],
77
env: {
88
test: {
9-
plugins: ["babel-plugin-transform-import-meta"],
9+
plugins: ['babel-plugin-transform-import-meta'],
1010
},
1111
},
1212
};

cats-frontend/package-lock.json

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

cats-frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"serve": "vite preview",
5555
"test": "vitest",
5656
"test:cov": "npm test -- --coverage",
57-
"codegen": "graphql-codegen"
57+
"codegen": "graphql-codegen",
58+
"format": "prettier --write \"./src/**/*.{js,ts,jsx,tsx,json,css}\""
5859
},
5960
"eslintConfig": {
6061
"extends": [

cats-frontend/src/App.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
}
4444

4545
* {
46-
font-family: "BC Sans", "Helvetica Neue", Arial, sans-serif;
46+
font-family: 'BC Sans', 'Helvetica Neue', Arial, sans-serif;
4747
}
4848

4949
@media screen and (max-width: 768px) {
@@ -165,8 +165,8 @@
165165
--typography-color-link: #255a90;
166166
--typography-color-disabled: #9f9d9c;
167167

168-
--box-shadow-small: 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.1),
169-
0 3.2px 7.2px 0 rgba(0, 0, 0, 0.13);
168+
--box-shadow-small:
169+
0 0.6px 1.8px 0 rgba(0, 0, 0, 0.1), 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.13);
170170

171171
--map-button-height-large: 64px;
172172
--map-button-height-medium: 40px;

cats-frontend/src/App.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import "./App.css";
2-
import Header from "./app/components/navigation/Header";
3-
import { Outlet } from "react-router-dom";
4-
import { ToastContainer } from "react-toastify";
5-
import SideBar from "./app/components/navigation/SideBar";
6-
import { useState } from "react";
7-
import { useAutoSignin } from "./hooks/useAutoSignIn";
1+
import './App.css';
2+
import Header from './app/components/navigation/Header';
3+
import { Outlet } from 'react-router-dom';
4+
import { ToastContainer } from 'react-toastify';
5+
import SideBar from './app/components/navigation/SideBar';
6+
import { useState } from 'react';
7+
import { useAutoSignin } from './hooks/useAutoSignIn';
88

9-
import "react-toastify/dist/ReactToastify.css";
10-
import "@bcgov/design-tokens/css/variables.css";
11-
import "@bcgov/bc-sans/css/BC_Sans.css";
9+
import 'react-toastify/dist/ReactToastify.css';
10+
import '@bcgov/design-tokens/css/variables.css';
11+
import '@bcgov/bc-sans/css/BC_Sans.css';
1212

1313
function App() {
1414
const [isSidebarExpanded, setIsSidebarExpanded] = useState(false);
@@ -29,14 +29,14 @@ function App() {
2929
<Header />
3030
<div className="container m-0 p-0">
3131
<div
32-
className={`sidebar-container display-from-medium ${isSidebarExpanded ? "expanded" : ""}`}
32+
className={`sidebar-container display-from-medium ${isSidebarExpanded ? 'expanded' : ''}`}
3333
onMouseEnter={handleSidebarToggle}
3434
onMouseLeave={handleSidebarToggle}
3535
>
3636
<SideBar />
3737
</div>
3838
<div
39-
className={`p-0 main-content-container ${isSidebarExpanded ? "shifted" : ""}`}
39+
className={`p-0 main-content-container ${isSidebarExpanded ? 'shifted' : ''}`}
4040
>
4141
<Outlet />
4242
</div>

cats-frontend/src/app/Store.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { configureStore } from "@reduxjs/toolkit";
2-
import commonDataReducer from "./features/common/CommonDataSlice";
3-
import dashboardReducer from "./features/dashboard/DashboardSlice";
4-
import peopleReducer from "./features/people/dto/PeopleSlice";
1+
import { configureStore } from '@reduxjs/toolkit';
2+
import commonDataReducer from './features/common/CommonDataSlice';
3+
import dashboardReducer from './features/dashboard/DashboardSlice';
4+
import peopleReducer from './features/people/dto/PeopleSlice';
55

66
export const store = configureStore({
77
reducer: {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UserManagerSettings } from "oidc-client-ts";
1+
import { UserManagerSettings } from 'oidc-client-ts';
22

33
export function getClientSettings(): UserManagerSettings {
44
return {
@@ -9,8 +9,8 @@ export function getClientSettings(): UserManagerSettings {
99
response_type: import.meta.env.VITE_AUTH_RESPONSE_TYPE,
1010
scope: import.meta.env.VITE_AUTH_SCOPE,
1111
filterProtocolClaims:
12-
import.meta.env.VITE_AUTH_FILTER_PROTOCOL_CLAIMS === "true",
13-
loadUserInfo: import.meta.env.VITE_AUTH_AUTHORITY === "true",
14-
revokeTokensOnSignout: import.meta.env.VITE_AUTH_AUTHORITY === "true",
12+
import.meta.env.VITE_AUTH_FILTER_PROTOCOL_CLAIMS === 'true',
13+
loadUserInfo: import.meta.env.VITE_AUTH_AUTHORITY === 'true',
14+
revokeTokensOnSignout: import.meta.env.VITE_AUTH_AUTHORITY === 'true',
1515
};
1616
}

0 commit comments

Comments
 (0)