Skip to content

The Open Standard for Generative UI

Cleanup stuff and integrate eslint/prettier

Rabi Shanker Guha4d68c746e0aa
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d0a89862a..4f9ef73ae 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,7 +9,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
-
+ defaults:
+ run:
+ working-directory: frontend-sdk
steps:
- uses: actions/checkout@v4
with:
@@ -27,7 +29,7 @@ jobs:
run: pnpm install --frozen-lockfile
- name: Build affected projects
- run: pnpm --filter "...[origin/main]" build
+ run: pnpm -r build
- name: Check affected projects
- run: pnpm --filter "...[origin/main]" ci
+ run: pnpm -r run ci
diff --git a/frontend-sdk/eslint.cjs b/frontend-sdk/eslint.cjs
deleted file mode 100644
index 7a4893755..000000000
--- a/frontend-sdk/eslint.cjs
+++ /dev/null
@@ -1,47 +0,0 @@
-/** @type {import("eslint").ESLint.ConfigData} */
-module.exports = {
- parser: "@typescript-eslint/parser",
- parserOptions: {
- project: "tsconfig.json",
- sourceType: "module",
- },
- plugins: ["@typescript-eslint/eslint-plugin", "unused-imports"],
- extends: [
- "eslint:recommended",
- "plugin:@typescript-eslint/recommended",
- "plugin:prettier/recommended",
- ],
- root: true,
- env: {
- node: true,
- jest: true,
- },
- ignorePatterns: [".eslintrc.cjs"],
- rules: {
- "@typescript-eslint/interface-name-prefix": "off",
- "@typescript-eslint/explicit-function-return-type": "off",
- "@typescript-eslint/explicit-module-boundary-types": "off",
- "@typescript-eslint/no-explicit-any": "off",
- "no-undefined": "off",
- "@typescript-eslint/no-unused-vars": [
- "error",
- {
- vars: "all",
- varsIgnorePattern: "^_",
- args: "after-used",
- argsIgnorePattern: "^_",
- },
- ],
- "@typescript-eslint/no-use-before-define": [
- "error",
- {
- functions: false,
- classes: false,
- variables: true,
- },
- ],
- "unused-imports/no-unused-imports": "error",
- "no-console": "error",
- "prettier/prettier": ["warn"],
- },
-};
\ No newline at end of file
diff --git a/frontend-sdk/eslint.config.cjs b/frontend-sdk/eslint.config.cjs
new file mode 100644
index 000000000..6f13a3191
--- /dev/null
+++ b/frontend-sdk/eslint.config.cjs
@@ -0,0 +1,58 @@
+const eslint = require('@eslint/js');
+const tseslint = require('@typescript-eslint/eslint-plugin');
+const typescript = require('@typescript-eslint/parser');
+const prettier = require('eslint-config-prettier');
+const unusedImports = require('eslint-plugin-unused-imports');
+const eslintPluginPrettier = require('eslint-plugin-prettier');
+
+module.exports = [
+ {
+ files: ['**/*.{ts,tsx}'],
+ ignores: ['**/*.stories.tsx'],
+ languageOptions: {
+ parser: typescript,
+ parserOptions: {
+ project: './tsconfig.json',
+ sourceType: 'module',
+ },
+ },
+ plugins: {
+ '@typescript-eslint': tseslint,
+ 'unused-imports': unusedImports,
+ 'prettier': eslintPluginPrettier,
+ },
+ rules: {
+ '@typescript-eslint/interface-name-prefix': 'off',
+ '@typescript-eslint/explicit-function-return-type': 'off',
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ '@typescript-eslint/no-explicit-any': 'off',
+ 'no-undefined': 'off',
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ {
+ vars: 'all',
+ varsIgnorePattern: '^_',
+ args: 'after-used',
+ argsIgnorePattern: '^_',
+ },
+ ],
+ '@typescript-eslint/no-use-before-define': [
+ 'error',
+ {
+ functions: false,
+ classes: false,
+ variables: true,
+ },
+ ],
+ 'unused-imports/no-unused-imports': 'error',
+ 'no-console': [
+ 'error',
+ {
+ allow: ['error', 'warn', 'info'],
+ },
+ ],
+ ...eslintPluginPrettier.configs.recommended.rules,
+ },
+ },
+ prettier,
+];
diff --git a/frontend-sdk/package.json b/frontend-sdk/package.json
index e23f5aa03..787988c19 100644
--- a/frontend-sdk/package.json
+++ b/frontend-sdk/package.json
@@ -6,6 +6,18 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
+ "devDependencies": {
+ "@typescript-eslint/eslint-plugin": "^8.21.0",
+ "eslint": "^9.19.0",
+ "eslint-config-prettier": "^9.1.0",
+ "eslint-plugin-prettier": "^5.1.3",
+ "eslint-plugin-react-hooks": "^5.1.0",
+ "eslint-plugin-react-refresh": "^0.4.18",
+ "eslint-plugin-storybook": "^0.11.2",
+ "eslint-plugin-unused-imports": "^3.2.0",
+ "prettier": "^3.2.5",
+ "prettier-plugin-organize-imports": "^3.2.4"
+ },
"keywords": [],
"author": "",
"license": "ISC",
diff --git a/frontend-sdk/packages/react-core/package.json b/frontend-sdk/packages/react-core/package.json
index 2e71d63fe..21e320352 100644
--- a/frontend-sdk/packages/react-core/package.json
+++ b/frontend-sdk/packages/react-core/package.json
@@ -10,9 +10,12 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc -p .",
- "lint": "eslint src --ext .ts,.tsx",
- "format": "prettier --write src",
- "prepare": "pnpm run build"
+ "lint:check": "eslint ./src",
+ "lint:fix": "eslint ./src --fix",
+ "format:fix": "prettier --write ./src",
+ "format:check": "prettier --check ./src",
+ "prepare": "pnpm run build",
+ "ci": "pnpm run lint:check && pnpm run format:check"
},
"peerDependencies": {
"ai": "^4.0.3",
diff --git a/frontend-sdk/packages/react-core/src/eslint.cjs b/frontend-sdk/packages/react-core/src/eslint.cjs
index 2fc6818c8..bc805cbeb 100644
--- a/frontend-sdk/packages/react-core/src/eslint.cjs
+++ b/frontend-sdk/packages/react-core/src/eslint.cjs
@@ -1,4 +1,4 @@
/** @type {import("eslint").ESLint.ConfigData} */
module.exports = {
- extends: ["../../eslint.cjs"]
-};
\ No newline at end of file
+ extends: ["../../eslint.cjs"],
+};
diff --git a/frontend-sdk/packages/react-core/src/internal/ChatContext.ts b/frontend-sdk/packages/react-core/src/internal/ChatContext.ts
index 6de67a572..d270eec25 100644
--- a/frontend-sdk/packages/react-core/src/internal/ChatContext.ts
+++ b/frontend-sdk/packages/react-core/src/internal/ChatContext.ts
@@ -1,7 +1,7 @@
import { createContext, useContext } from "react";
-import { ThreadListManager, ThreadManager } from "../types";
-import { StoreApi } from "zustand";
import invariant from "tiny-invariant";
+import { StoreApi } from "zustand";
+import { ThreadListManager, ThreadManager } from "../types";
export const ChatContext = createContext<{
threadListManager: StoreApi<ThreadListManager>;
diff --git a/frontend-sdk/packages/react-core/tsconfig.json b/frontend-sdk/packages/react-core/tsconfig.json
index 1be5dacbc..5ffddea97 100644
--- a/frontend-sdk/packages/react-core/tsconfig.json
+++ b/frontend-sdk/packages/react-core/tsconfig.json
@@ -4,6 +4,6 @@
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
- "declaration": true,
+ "declaration": true
}
}
diff --git a/frontend-sdk/packages/react-ui/eslint.cjs b/frontend-sdk/packages/react-ui/eslint.cjs
deleted file mode 100644
index 2fc6818c8..000000000
--- a/frontend-sdk/packages/react-ui/eslint.cjs
+++ /dev/null
@@ -1,4 +0,0 @@
-/** @type {import("eslint").ESLint.ConfigData} */
-module.exports = {
- extends: ["../../eslint.cjs"]
-};
\ No newline at end of file
diff --git a/frontend-sdk/packages/react-ui/package.json b/frontend-sdk/packages/react-ui/package.json
index 6a1c32627..1547ad83f 100644
--- a/frontend-sdk/packages/react-ui/package.json
+++ b/frontend-sdk/packages/react-ui/package.json
@@ -21,11 +21,15 @@
"build": "pnpm run build:tsc && pnpm run build:scss && pnpm run copy-css",
"build:tsc": "tsc -p .",
"build:scss": "sass src:dist --style compressed --no-source-map",
- "lint": "eslint src --ext .ts,.tsx",
- "format": "prettier --write src",
"storybook": "storybook dev -p 6006",
"copy-css": "node cp-css.js",
- "watch": "concurrently \"pnpm run build:ts -- --watch\" \"pnpm run build:scss -- --watch\""
+ "watch": "concurrently \"pnpm run build:ts -- --watch\" \"pnpm run build:scss -- --watch\"",
+ "lint:check": "eslint ./src",
+ "lint:fix": "eslint ./src --fix",
+ "format:fix": "prettier --write ./src",
+ "format:check": "prettier --check ./src",
+ "prepare": "pnpm run build",
+ "ci": "pnpm run lint:check && pnpm run format:check"
},
"peerDependencies": {
"@crayonai/react-core": "workspace:*",
@@ -60,15 +64,6 @@
"@storybook/react-vite": "^8.5.2",
"@storybook/test": "^8.5.2",
"@types/react": "^19.0.8",
- "@typescript-eslint/eslint-plugin": "^8.21.0",
- "eslint": "^9.19.0",
- "eslint-config-prettier": "^9.1.0",
- "eslint-plugin-prettier": "^5.2.3",
- "eslint-plugin-react-hooks": "^5.1.0",
- "eslint-plugin-react-refresh": "^0.4.18",
- "eslint-plugin-storybook": "^0.11.2",
- "eslint-plugin-unused-imports": "^3.2.0",
- "prettier-plugin-organize-imports": "^3.2.4",
"prop-types": "^15.8.1",
"storybook": "^8.5.2"
},
diff --git a/frontend-sdk/pnpm-lock.yaml b/frontend-sdk/pnpm-lock.yaml
index 57741dda9..d179935bb 100644
--- a/frontend-sdk/pnpm-lock.yaml
+++ b/frontend-sdk/pnpm-lock.yaml
@@ -6,7 +6,38 @@ settings:
importers:
- .: {}
+ .:
+ devDependencies:
+ '@typescript-eslint/eslint-plugin':
+ specifier: ^8.21.0
+ eslint:
+ specifier: ^9.19.0
+ version: 9.19.0([email protected])
+ eslint-config-prettier:
+ specifier: ^9.1.0
+ eslint-plugin-prettier:
+ specifier: ^5.1.3
+ eslint-plugin-react-hooks:
+ specifier: ^5.1.0
+ eslint-plugin-react-refresh:
+ specifier: ^0.4.18
+ eslint-plugin-storybook:
+ specifier: ^0.11.2
+ eslint-plugin-unused-imports:
+ specifier: ^3.2.0
+ prettier:
+ specifier: ^3.2.5
+ version: 3.4.2
+ prettier-plugin-organize-imports:
+ specifier: ^3.2.4
packages/react-core:
dependencies:
@@ -150,33 +181,6 @@ importers:
'@types/react':
specifier: ^19.0.8
version: 19.0.8
- '@typescript-eslint/eslint-plugin':
- specifier: ^8.21.0
- eslint:
- specifier: ^9.19.0
- version: 9.19.0([email protected])
- eslint-config-prettier:
- specifier: ^9.1.0
- eslint-plugin-prettier:
- specifier: ^5.2.3
- eslint-plugin-react-hooks:
- specifier: ^5.1.0
- eslint-plugin-react-refresh:
- specifier: ^0.4.18
- eslint-plugin-storybook:
- specifier: ^0.11.2
- eslint-plugin-unused-imports:
- specifier: ^3.2.0
- prettier-plugin-organize-imports:
- specifier: ^3.2.4
prop-types:
specifier: ^15.8.1
version: 15.8.1