Skip to content

Commit 8a5ddb4

Browse files
authored
1351 implement cda gui code formatter (#1460)
Adds Husky/Prettier to `cda-gui` following behind Groundwork and Groundwork-Water's formatting setups. @jbkolze, you might see if i've missed anything? Files of interest: - cda-gui/.husky/pre-commit - cda-gui/.prettierrc - cda-gui/README.md - cda-gui/package.json Via: - a72ea0d - 7953176 - 697ae6b
1 parent b1f67bf commit 8a5ddb4

46 files changed

Lines changed: 1679 additions & 1165 deletions

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ jobs:
3232
distribution: 'temurin'
3333
java-version: ${{matrix.jdk}}
3434
cache: 'gradle'
35-
- name: install node for cda-gui audit
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: '22'
39-
cache: 'npm'
40-
cache-dependency-path: cda-gui/package-lock.json
41-
42-
- name: run cda-gui audit for high CVE
43-
working-directory: ./cda-gui
44-
run: |
45-
npm install --package-lock-only
46-
npm audit --audit-level=high
4735
- name: build and test
4836
id: thebuild
4937
run: ./gradlew build --info --init-script init.gradle
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CDA Web GUI NPM Audit (CVE)
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
branches:
9+
- develop
10+
# Only run when relevant files change (i.e. packages are bumped into new NPM versions)
11+
paths:
12+
- "cda-gui/**"
13+
- ".github/workflows/web-gui-*.yml"
14+
15+
# Allow running audits adhoc via "run task" in the UI
16+
workflow_dispatch:
17+
18+
jobs:
19+
audit:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: install node for cda-gui audit
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '22'
29+
cache: 'npm'
30+
cache-dependency-path: cda-gui/package-lock.json
31+
32+
- name: run cda-gui audit for critical CVE
33+
working-directory: ./cda-gui
34+
# disable husky git hooks during CI runs
35+
run: |
36+
HUSKY=0 npm ci
37+
npm audit --audit-level=critical

cda-gui/.eslintrc.cjs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ module.exports = {
22
root: true,
33
env: { browser: true, es2020: true },
44
extends: [
5-
'eslint:recommended',
6-
'plugin:react/recommended',
7-
'plugin:react/jsx-runtime',
8-
'plugin:react-hooks/recommended',
5+
"eslint:recommended",
6+
"plugin:react/recommended",
7+
"plugin:react/jsx-runtime",
8+
"plugin:react-hooks/recommended",
99
],
10-
ignorePatterns: ['dist', '.eslintrc.cjs'],
11-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
12-
settings: { react: { version: '18.2' } },
13-
plugins: ['react-refresh'],
10+
ignorePatterns: ["dist", ".eslintrc.cjs"],
11+
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
12+
settings: { react: { version: "18.2" } },
13+
plugins: ["react-refresh"],
1414
rules: {
15-
'react/jsx-no-target-blank': 'off',
16-
'react-refresh/only-export-components': [
17-
'warn',
18-
{ allowConstantExport: true },
19-
],
15+
"react/jsx-no-target-blank": "off",
16+
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
2017
},
21-
}
18+
};

cda-gui/.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd cda-gui
2+
npx lint-staged

cda-gui/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 88,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"jsxSingleQuote": false,
6+
"singleQuote": false
7+
}

cda-gui/README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
# CDA Landing Page Source
22

3-
*The React+Vite project for CDA*
3+
_The React+Vite project for CDA_
44

5+
## Setup
6+
Setup the project by running:
7+
1. `cd cda-gui`
8+
2. `npm install` (With nodejs installed)
9+
10+
## Development
511

612
To run the project in dev:
713
`npm run dev`
814

15+
## Production Files
916
To build the project:
1017
`npm run build`
11-
*NOTE*: Building the project will also deploy it to the required tomcat webapps directory `webapp`
1218

13-
To see the available scripts for this project, including how to run and deploy, look at the `package.json` file.
19+
To see the available scripts for this project, including how to run and deploy, look at the `package.json` file.
20+
21+
22+
## Formatting
23+
24+
Formatting is done with [husky](https://typicode.github.io/husky/) and styled using [prettier](https://prettier.io/docs/). Husky requires a minimum Git version of 2.9
25+
26+
When you commit, after running the install command above, husky will format files for you! But you can also run the formatter with:
27+
`npx prettier --write myfile.html` or `npm run prepare`
28+
29+
Or check files with:
30+
`format:check`

cda-gui/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="UTF-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>CDA - CWMS Data API</title>
88
<meta name="Description" content="CDA CWMS Data API" />
99
</head>

0 commit comments

Comments
 (0)