Skip to content

Commit c85646f

Browse files
CheyuWumachichima
andauthored
[Feature] Add eslint and Prettier to ray dashboard (#3975)
* style: add / update next js eslint to latest Signed-off-by: Cheyu Wu <[email protected]> * style: add prettier for tsx and js Signed-off-by: Cheyu Wu <[email protected]> * chore: extend the name in .pre-commit-config.yaml Co-authored-by: Nary Yeh <[email protected]> Signed-off-by: Cheyu Wu <[email protected]> * chore: mv yarn lock check to CI and keep only lint in pre-commit Signed-off-by: Cheyu Wu <[email protected]> * fix: pipeline err Signed-off-by: Cheyu Wu <[email protected]> --------- Signed-off-by: Cheyu Wu <[email protected]> Signed-off-by: Cheyu Wu <[email protected]> Co-authored-by: Nary Yeh <[email protected]>
1 parent 38a07e9 commit c85646f

39 files changed

+619
-522
lines changed

.github/workflows/test-job.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919
- uses: actions/setup-python@v3
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: lts/*
23+
cache: yarn
24+
cache-dependency-path: dashboard/yarn.lock
25+
- name: Check Yarn lock consistency
26+
run: |
27+
cd dashboard
28+
yarn install --immutable
29+
yarn dedupe --check
2030
- uses: pre-commit/[email protected]
2131

2232
build_apiserver:

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ repos:
6565
pass_filenames: false
6666
additional_dependencies:
6767
- github.com/yannh/kubeconform/cmd/[email protected]
68+
- id: eslint
69+
name: ESLint TypeScript/JavaScript check
70+
entry: ./scripts/dashboard-lint.sh
71+
language: node
72+
require_serial: true
73+
pass_filenames: true
74+
files: .*\.(js|jsx|ts|tsx|cjs|mjs)$
75+
6876

6977
- repo: https://github.com/igorshubovych/markdownlint-cli
7078
rev: v0.44.0

dashboard/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
.next
5+
*.json

dashboard/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

dashboard/eslint.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineConfig } from "eslint/config";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import js from "@eslint/js";
5+
import { FlatCompat } from "@eslint/eslintrc";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
const compat = new FlatCompat({
10+
baseDirectory: __dirname,
11+
recommendedConfig: js.configs.recommended,
12+
allConfig: js.configs.all,
13+
});
14+
15+
export default defineConfig([
16+
{
17+
extends: compat.extends("next/core-web-vitals", "next/typescript"),
18+
rules: {
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/no-unused-vars": "off",
21+
"@typescript-eslint/ban-ts-comment": "off",
22+
},
23+
},
24+
]);

dashboard/next.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
output: "standalone",
3+
output: "standalone",
44
};
55

66
export default nextConfig;

dashboard/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "ray-frontend",
33
"version": "0.1.0",
4-
"private": true,
4+
"type": "module",
55
"scripts": {
66
"dev": "next dev --turbo",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint --max-warnings 0 && prettier . --check && tsc --noEmit",
10+
"fix": "next lint --fix --max-warnings 0 && prettier . --write && tsc --noEmit"
1011
},
1112
"dependencies": {
1213
"@emotion/react": "^11.11.4",
@@ -21,13 +22,15 @@
2122
"swr": "^2.2.5"
2223
},
2324
"devDependencies": {
25+
"@eslint/js": "^9.33.0",
2426
"@types/node": "^20",
2527
"@types/react": "^18",
2628
"@types/react-dom": "^18",
2729
"autoprefixer": "^10.0.1",
28-
"eslint": "^8",
29-
"eslint-config-next": "14.1.3",
30+
"eslint": "^9.33.0",
31+
"eslint-config-next": "^15.4.6",
3032
"postcss": "^8",
33+
"prettier": "3.6.2",
3134
"tailwindcss": "^3.3.0",
3235
"typescript": "^5"
3336
},
File renamed without changes.

dashboard/src/app/api/config/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { NextResponse } from 'next/server';
1+
import { NextResponse } from "next/server";
22

33
export async function GET() {
44
const config = {
5-
apiUrl: process.env.NEXT_PUBLIC_API_URL || process.env.API_URL || "http://localhost:31888/apis/v1",
5+
apiUrl:
6+
process.env.NEXT_PUBLIC_API_URL ||
7+
process.env.API_URL ||
8+
"http://localhost:31888/apis/v1",
69
};
710

811
return NextResponse.json(config);

dashboard/src/app/clusters/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { useEffect } from "react";
1010
import { useFirstVisit } from "@/components/FirstVisitContext";
1111

1212
export default function ClustersPage() {
13-
const { firstVisit, setFirstVisit} = useFirstVisit();
13+
const { firstVisit, setFirstVisit } = useFirstVisit();
1414
useEffect(() => {
1515
if (firstVisit) {
1616
setFirstVisit(false);
1717
}
18-
}, [])
18+
}, [firstVisit, setFirstVisit]);
1919
return (
2020
<>
2121
<Box

0 commit comments

Comments
 (0)