Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chore: Improve pre-commit (#7818)

sp.wackd114c45135ce
diff --git a/frontend/.eslintrc b/frontend/.eslintrc
index 03d7498d3a..7bf4b7541c 100644
--- a/frontend/.eslintrc
+++ b/frontend/.eslintrc
@@ -1,7 +1,7 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
- "project": "./tsconfig.json"
+ "project": "./tsconfig.json",
},
"extends": [
"airbnb",
@@ -11,15 +11,12 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
- "plugin:@tanstack/query/recommended"
- ],
- "plugins": [
- "prettier"
+ "plugin:@tanstack/query/recommended",
],
+ "plugins": ["prettier", "unused-imports"],
"rules": {
- "prettier/prettier": [
- "error"
- ],
+ "unused-imports/no-unused-imports": "error",
+ "prettier/prettier": ["error"],
// Resolves https://stackoverflow.com/questions/59265981/typescript-eslint-missing-file-extension-ts-import-extensions/59268871#59268871
"import/extensions": [
"error",
@@ -27,32 +24,26 @@
{
"": "never",
"ts": "never",
- "tsx": "never"
- }
- ]
+ "tsx": "never",
+ },
+ ],
},
"settings": {
"react": {
- "version": "detect"
- }
+ "version": "detect",
+ },
},
"overrides": [
{
- "files": [
- "*.ts",
- "*.tsx"
- ],
+ "files": ["*.ts", "*.tsx"],
"rules": {
// Allow state modification in reduce and Redux reducers
"no-param-reassign": [
"error",
{
"props": true,
- "ignorePropertyModificationsFor": [
- "acc",
- "state"
- ]
- }
+ "ignorePropertyModificationsFor": ["acc", "state"],
+ },
],
// For https://stackoverflow.com/questions/55844608/stuck-with-eslint-error-i-e-separately-loops-should-be-avoided-in-favor-of-arra
"no-restricted-syntax": "off",
@@ -66,24 +57,19 @@
2,
{
"required": {
- "some": [
- "nesting",
- "id"
- ]
- }
- }
+ "some": ["nesting", "id"],
+ },
+ },
],
"react/prop-types": "off",
"react/no-array-index-key": "off",
"react-hooks/exhaustive-deps": "off",
"import/no-extraneous-dependencies": "off",
- "react/react-in-jsx-scope": "off"
+ "react/react-in-jsx-scope": "off",
},
"parserOptions": {
- "project": [
- "**/tsconfig.json"
- ]
- }
- }
- ]
+ "project": ["**/tsconfig.json"],
+ },
+ },
+ ],
}
diff --git a/frontend/.husky/pre-commit b/frontend/.husky/pre-commit
index 9613d11baa..89779658ae 100755
--- a/frontend/.husky/pre-commit
+++ b/frontend/.husky/pre-commit
@@ -1,4 +1,3 @@
cd frontend
npm run check-unlocalized-strings
npx lint-staged
-npm test
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index d631b860ff..bb6ec7270b 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -83,6 +83,7 @@
"eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^4.6.2",
+ "eslint-plugin-unused-imports": "^4.1.4",
"husky": "^9.1.7",
"jsdom": "^26.0.0",
"lint-staged": "^15.5.0",
@@ -9173,6 +9174,22 @@
"semver": "bin/semver.js"
}
},
+ "node_modules/eslint-plugin-unused-imports": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz",
+ "integrity": "sha512-YptD6IzQjDardkl0POxnnRBhU1OEePMV0nd6siHaRBbd+lyh6NAhFEobiznKU7kTsSsDeSD62Pe7kAM1b7dAZQ==",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0",
+ "eslint": "^9.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@typescript-eslint/eslint-plugin": {
+ "optional": true
+ }
+ }
+ },
"node_modules/eslint-scope": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 1d36a5ee4f..e18ce2b0a3 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -107,6 +107,7 @@
"eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^4.6.2",
+ "eslint-plugin-unused-imports": "^4.1.4",
"husky": "^9.1.7",
"jsdom": "^26.0.0",
"lint-staged": "^15.5.0",