Skip to content

Commit bb633dd

Browse files
committed
Use reusable frontend lint workflow from armada
Replace the inline frontend_lint_and_test.yml workflow with a caller to the new reusable lint_frontend_package.yml in armada. Align npm scripts (start->dev, serve->preview, add lint), add react-hooks and react-refresh eslint plugins, align eslint config with pointilla_maps, and update all references in docs and Makefile. Rename fetchImageData/fetchAnalysisData/fetchValueData to use the 'use' prefix (useImageData/useAnalysisData/useValueData) since they are custom hooks calling useQuery. React Compiler rules from react-hooks v7 are disabled for now, to be addressed in a follow-up (see #2698).
1 parent 5b725e0 commit bb633dd

11 files changed

Lines changed: 117 additions & 106 deletions

File tree

.github/workflows/frontend_lint_and_test.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Frontend
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint-frontend-package:
14+
uses: equinor/armada/.github/workflows/lint_frontend_package.yml@main
15+
permissions:
16+
contents: read
17+
with:
18+
working-directory: frontend
19+
run-prettier: true
20+
run-eslint: true
21+
run-build: true
22+
run-unused-exports: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Frontend
22
frontend/node_modules/
33
frontend/dist/
4+
frontend/out/
45

56
# Editors
67
.vscode

frontend/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
npm start
2+
npm run dev
33

44
build:
55
npm run build

frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ npm ci
3030
To start the app, run the following command in the root folder:
3131

3232
```
33-
npm start
33+
npm run dev
3434
```
3535

3636
This command runs the app in development mode. Open [http://localhost:3001/robotics-frontend](http://localhost:3001/robotics-frontend) to view it in the browser.

frontend/best_practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ npx prettier --write [path to source]
2929

3030
We also avoid any warnings or errors from ESLint before we merge in any code. These warnings appear
3131
when compiling the code using
32-
npm start
32+
npm run dev
3333
but can also be run with
3434
npx eslint [path to src]
3535

frontend/eslint.config.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1-
import globals from "globals";
2-
import pluginJs from "@eslint/js";
3-
import tseslint from "typescript-eslint";
4-
import pluginReact from "eslint-plugin-react";
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import tseslint from 'typescript-eslint'
4+
import pluginReact from 'eslint-plugin-react'
5+
import reactHooks from 'eslint-plugin-react-hooks'
6+
import reactRefresh from 'eslint-plugin-react-refresh'
57

8+
export default tseslint.config(
9+
{ ignores: ['dist'] },
10+
{
11+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
12+
files: ['**/*.{ts,tsx}'],
13+
languageOptions: {
14+
ecmaVersion: 2024,
15+
globals: globals.browser,
16+
},
17+
plugins: {
18+
react: pluginReact,
19+
'react-hooks': reactHooks,
20+
'react-refresh': reactRefresh,
21+
},
22+
rules: {
23+
...pluginReact.configs.flat.recommended.rules,
624

7-
/** @type {import('eslint').Linter.Config[]} */
8-
export default [
9-
{files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
10-
{languageOptions: { globals: globals.browser }},
11-
pluginJs.configs.recommended,
12-
...tseslint.configs.recommended,
13-
pluginReact.configs.flat.recommended,
14-
{
15-
rules: {
16-
"react/react-in-jsx-scope": "off",
17-
"react/display-name": "off",
18-
"@typescript-eslint/no-explicit-any": "off",
25+
'react/react-in-jsx-scope': 'off',
26+
'react/display-name': 'off',
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'react-hooks/rules-of-hooks': 'error',
29+
'react-hooks/exhaustive-deps': 'warn',
30+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
31+
},
1932
}
20-
}
21-
];
33+
)

frontend/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
You can add webfonts, meta tags, or analytics to this file.
3636
The build step will place the bundled scripts into the <body> tag.
3737
38-
To begin the development, run `npm start` or `yarn start`.
39-
To create a production bundle, use `npm run build` or `yarn build`.
38+
To begin the development, run `npm run dev`.
39+
To create a production bundle, use `npm run build`.
4040
--></body>
4141
</html>

frontend/package-lock.json

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

frontend/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
"vite-plugin-svgr": "^4.5.0"
3535
},
3636
"scripts": {
37-
"start": "vite",
38-
"build": "tsc && vite build",
39-
"serve": "vite preview",
37+
"dev": "vite",
38+
"build": "tsc -b && vite build",
39+
"preview": "vite preview",
4040
"test": "vitest",
41+
"lint": "eslint src",
4142
"prettier_check": "npx prettier --check src"
4243
},
4344
"browserslist": {
@@ -60,6 +61,8 @@
6061
"@types/styled-components": "^5.1.36",
6162
"eslint": "^9.39.3",
6263
"eslint-plugin-react": "^7.37.5",
64+
"eslint-plugin-react-hooks": "^6.0.0",
65+
"eslint-plugin-react-refresh": "^0.4.26",
6366
"globals": "^17.4.0",
6467
"jsdom": "^28.1.0",
6568
"ts-unused-exports": "^11.0.1",

0 commit comments

Comments
 (0)