Skip to content

Commit 491558a

Browse files
committed
Merge branch 'chore/787-ui-lint-leaks-type-drift' into 'master'
Lint every UI package, fix log socket leaks and CloneDto drift Closes #787 See merge request postgres-ai/database-lab!1203
2 parents 4880d70 + 5419992 commit 491558a

62 files changed

Lines changed: 905 additions & 305 deletions

Some content is hidden

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

‎ui/.gitlab-ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ check-code-style:
3434

3535
script:
3636
- pnpm --dir ui/ i
37-
- pnpm --dir ui/ --filter @postgres.ai/ce lint
37+
- pnpm --dir ui/ -r run lint
3838
interruptible: true
3939
cache:
4040
<<: *cache
@@ -46,7 +46,7 @@ check-code-style:
4646
- export PNPM_HOME=/usr/local/bin
4747
- pnpm config set store-dir /builds/postgres-ai/database-lab/.pnpm-store/
4848

49-
ce-unit-tests:
49+
ui-unit-tests:
5050
<<: *ui_checks
5151
<<: *ui_cache
5252
stage: test
@@ -55,7 +55,7 @@ ce-unit-tests:
5555
before_script: *ui_pnpm_setup
5656
script:
5757
- pnpm --dir ui/ install --frozen-lockfile
58-
- pnpm --dir ui/ --filter @postgres.ai/ce test
58+
- pnpm --dir ui/ -r run test
5959
interruptible: true
6060

6161
# The result depends on the advisory database at run time, not on the commit,

‎ui/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ Set the `VITE_DEV_PROXY_TARGET` environment variable to override the proxy targe
4646
- `pnpm install` – install dependencies for all packages (run once).
4747
- `pnpm --filter @postgres.ai/ce build` – build the Community Edition UI.
4848

49+
### How to lint and test
50+
51+
- `cd ui`
52+
- `pnpm -r run lint` – lint every package that defines a `lint` script. `@postgres.ai/shared` runs
53+
ESLint over the whole package; `@postgres.ai/ce` runs it over `src/` plus stylelint and cspell.
54+
- `pnpm -r run test` – run the Vitest suite of every package that defines a `test` script.
55+
56+
Packages share the flat ESLint base in `ui/eslint.config.base.mjs`. A package config spreads it
57+
and appends only its own overrides, so a rule change lands everywhere at once.
58+
4959
### CI pipelines for UI code
5060

5161
To deploy UI changes, tag the commit with a `ui/` prefix and push it. For example:

‎ui/eslint.config.base.mjs‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import js from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
3+
import reactPlugin from 'eslint-plugin-react'
4+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
5+
import globals from 'globals'
6+
7+
// Flat-config base every package in the UI workspace shares. Package configs spread it and
8+
// append their own overrides; the plugins it imports resolve from the workspace root, so a
9+
// package only declares the plugins its own overrides use.
10+
export const baseConfig = tseslint.config(
11+
js.configs.recommended,
12+
...tseslint.configs.recommended,
13+
{
14+
files: ['**/*.{ts,tsx}'],
15+
plugins: {
16+
react: reactPlugin,
17+
'react-hooks': reactHooksPlugin,
18+
},
19+
languageOptions: {
20+
globals: {
21+
...globals.browser,
22+
...globals.es2020,
23+
},
24+
parserOptions: {
25+
ecmaFeatures: { jsx: true },
26+
},
27+
},
28+
settings: {
29+
react: { version: 'detect' },
30+
},
31+
rules: {
32+
...reactPlugin.configs.recommended.rules,
33+
...reactHooksPlugin.configs.recommended.rules,
34+
'react/react-in-jsx-scope': 'off',
35+
'react/prop-types': 'off',
36+
'@typescript-eslint/no-explicit-any': 'error',
37+
// A suppression has to state which error it silences and stop applying once that error
38+
// is gone, so `@ts-ignore` is never the right form.
39+
'@typescript-eslint/ban-ts-comment': [
40+
'error',
41+
{ 'ts-ignore': true, 'ts-expect-error': 'allow-with-description' },
42+
],
43+
'@typescript-eslint/no-unused-vars': [
44+
'error',
45+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
46+
],
47+
},
48+
},
49+
{
50+
// Triple-slash references are the only way an ambient declaration file can pull in
51+
// another set of typings.
52+
files: ['**/*.d.ts'],
53+
rules: {
54+
'@typescript-eslint/triple-slash-reference': 'off',
55+
},
56+
},
57+
{
58+
ignores: ['build/', 'dist/', 'node_modules/'],
59+
},
60+
)
61+
62+
export default baseConfig

‎ui/package.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
},
88
"scripts": {
99
"preinstall": "npx only-allow pnpm",
10-
"start:ce": "pnpm --filter @postgres.ai/ce start"
10+
"start:ce": "pnpm --filter @postgres.ai/ce start",
11+
"lint": "pnpm -r lint",
12+
"test": "pnpm -r test"
13+
},
14+
"devDependencies": {
15+
"@eslint/js": "^9.27.0",
16+
"eslint": "^9.27.0",
17+
"eslint-plugin-react": "^7.37.5",
18+
"eslint-plugin-react-hooks": "^5.2.0",
19+
"globals": "^16.2.0",
20+
"typescript-eslint": "^8.32.1"
1121
},
1222
"pnpm": {
1323
"overrides": {

‎ui/packages/ce/eslint.config.js‎

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
1-
import js from '@eslint/js'
2-
import tseslint from 'typescript-eslint'
3-
import reactPlugin from 'eslint-plugin-react'
4-
import reactHooksPlugin from 'eslint-plugin-react-hooks'
51
import cypressPlugin from 'eslint-plugin-cypress'
6-
import globals from 'globals'
72

8-
export default tseslint.config(
9-
js.configs.recommended,
10-
...tseslint.configs.recommended,
11-
{
12-
files: ['**/*.{ts,tsx}'],
13-
plugins: {
14-
react: reactPlugin,
15-
'react-hooks': reactHooksPlugin,
16-
},
17-
languageOptions: {
18-
globals: {
19-
...globals.browser,
20-
...globals.es2020,
21-
},
22-
parserOptions: {
23-
ecmaFeatures: { jsx: true },
24-
},
25-
},
26-
settings: {
27-
react: { version: 'detect' },
28-
},
29-
rules: {
30-
...reactPlugin.configs.recommended.rules,
31-
...reactHooksPlugin.configs.recommended.rules,
32-
'react/react-in-jsx-scope': 'off',
33-
'react/prop-types': 'off',
34-
'@typescript-eslint/no-explicit-any': 'error',
35-
'@typescript-eslint/no-unused-vars': [
36-
'error',
37-
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
38-
],
39-
},
40-
},
3+
import { baseConfig } from '../../eslint.config.base.mjs'
4+
5+
export default [
6+
...baseConfig,
417
{
428
files: ['cypress/**/*.{ts,tsx}'],
439
plugins: {
@@ -47,7 +13,4 @@ export default tseslint.config(
4713
...cypressPlugin.configs.recommended.rules,
4814
},
4915
},
50-
{
51-
ignores: ['build/', 'node_modules/'],
52-
},
53-
)
16+
]

‎ui/packages/ce/package.json‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
"cypress": "^15.21.1",
7474
"eslint": "^9.27.0",
7575
"eslint-plugin-cypress": "^6.2.2",
76-
"eslint-plugin-react": "^7.37.5",
77-
"eslint-plugin-react-hooks": "^5.2.0",
78-
"globals": "^16.2.0",
7976
"happy-dom": "^20.9.0",
8077
"monaco-editor": "^0.55.0",
8178
"postcss": "8.5.23",
@@ -84,7 +81,6 @@
8481
"stylelint": "^14.0.1",
8582
"stylelint-config-standard-scss": "^2.0.1",
8683
"stylelint-prettier": "^2.0.0",
87-
"typescript-eslint": "^8.32.1",
8884
"vite": "6.4.3",
8985
"vite-plugin-checker": "^0.9.1",
9086
"vite-tsconfig-paths": "^5.1.4",

‎ui/packages/ce/src/api/configs/getFullConfig.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export const getFullConfig = async () => {
99

1010
return {
1111
response: response ? response : null,
12-
error: response && null,
12+
error: null,
1313
}
1414
}

‎ui/packages/ce/src/index.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import ReactDOM from 'react-dom'
33
import { ThemeProvider } from '@material-ui/core'
44

5+
import { ErrorBoundary } from '@postgres.ai/shared/components/ErrorBoundary'
56
import { theme } from '@postgres.ai/shared/styles/theme'
67

78
import './index.scss'
@@ -11,7 +12,9 @@ import { App } from './App'
1112
ReactDOM.render(
1213
<React.StrictMode>
1314
<ThemeProvider theme={theme}>
14-
<App />
15+
<ErrorBoundary>
16+
<App />
17+
</ErrorBoundary>
1518
</ThemeProvider>
1619
</React.StrictMode>,
1720
document.getElementById('root'),

‎ui/packages/shared/components/Button/index.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ export const Button = forwardRef(
7777
)
7878
},
7979
)
80+
81+
Button.displayName = 'Button'

‎ui/packages/shared/components/Button2/index.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ export const Button = React.forwardRef<HTMLButtonElement, Props>(
4141
)
4242
},
4343
)
44+
45+
Button.displayName = 'Button2'

0 commit comments

Comments
 (0)