From e0c72adbc1d523d06c101e9f8818e7bcfc882faa Mon Sep 17 00:00:00 2001 From: Loxeris Date: Wed, 17 Jul 2024 10:11:20 +0200 Subject: [PATCH] fix: husky hooks and lint-staged + delete useless jest dependencies --- .../diracx-web/.husky => .husky}/pre-commit | 2 +- package-lock.json | 9 +++------ package.json | 4 +++- packages/diracx-web-components/package.json | 7 +++++++ packages/diracx-web/.husky/.gitignore | 1 - packages/diracx-web/jest.config.mjs | 17 ----------------- packages/diracx-web/jest.setup.ts | 1 - packages/diracx-web/package.json | 9 +-------- 8 files changed, 15 insertions(+), 35 deletions(-) rename {packages/diracx-web/.husky => .husky}/pre-commit (56%) delete mode 100644 packages/diracx-web/.husky/.gitignore delete mode 100644 packages/diracx-web/jest.config.mjs delete mode 100644 packages/diracx-web/jest.setup.ts diff --git a/packages/diracx-web/.husky/pre-commit b/.husky/pre-commit similarity index 56% rename from packages/diracx-web/.husky/pre-commit rename to .husky/pre-commit index c37466e2..a741d54d 100644 --- a/packages/diracx-web/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npx lint-staged \ No newline at end of file +npx lerna exec -- npx lint-staged \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9ecc0fe0..508e49c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "packages/diracx-web" ], "devDependencies": { + "husky": "^9.0.11", "lerna": "^8.1.3" } }, @@ -29082,21 +29083,15 @@ "devDependencies": { "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", - "@testing-library/jest-dom": "^6.4.6", "@testing-library/react": "^16.0.0", "@testing-library/user-event": "^14.5.1", - "@types/jest": "^29.5.12", "cypress": "^13.12.0", "eslint": "^8.56.0", "eslint-config-next": "^14.2.3", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.29.1", - "husky": "^9.0.11", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", "lint-staged": "^15.2.2", "prettier": "^3.2.5", - "ts-jest": "^29.1.5", "tsc-files": "^1.1.4", "typescript": "5.4.5" } @@ -29146,10 +29141,12 @@ "eslint-plugin-storybook": "^0.8.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "lint-staged": "^15.2.2", "next": "^14.2.3", "prettier": "^3.2.5", "storybook": "^8.2.1", "ts-jest": "^29.1.2", + "tsc-files": "^1.1.4", "tsup": "^8.0.2", "typescript": "^5.4.5" } diff --git a/package.json b/package.json index 5a696231..f58075ce 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "packages/diracx-web" ], "devDependencies": { + "husky": "^9.0.11", "lerna": "^8.1.3" }, "scripts": { @@ -15,6 +16,7 @@ "build": "lerna run build", "build-lib": "lerna run build --scope @dirac-grid/diracx-web-components", "lint": "lerna run lint", - "ts-lint": "lerna run ts-lint" + "ts-lint": "lerna run ts-lint", + "prepare": "husky" } } diff --git a/packages/diracx-web-components/package.json b/packages/diracx-web-components/package.json index 0e39bd4a..e9865667 100644 --- a/packages/diracx-web-components/package.json +++ b/packages/diracx-web-components/package.json @@ -59,10 +59,12 @@ "eslint-plugin-storybook": "^0.8.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "lint-staged": "^15.2.2", "next": "^14.2.3", "prettier": "^3.2.5", "storybook": "^8.2.1", "ts-jest": "^29.1.2", + "tsc-files": "^1.1.4", "tsup": "^8.0.2", "typescript": "^5.4.5" }, @@ -105,5 +107,10 @@ "workerDirectory": [ "public" ] + }, + "lint-staged": { + "*.{js,ts,jsx,tsx}": "eslint --cache --fix", + "*.{js,ts,jsx,tsx,css,md}": "prettier --write", + "src/**/*.{ts,tsx}": "tsc-files --noEmit" } } diff --git a/packages/diracx-web/.husky/.gitignore b/packages/diracx-web/.husky/.gitignore deleted file mode 100644 index 31354ec1..00000000 --- a/packages/diracx-web/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/packages/diracx-web/jest.config.mjs b/packages/diracx-web/jest.config.mjs deleted file mode 100644 index 4e1133f1..00000000 --- a/packages/diracx-web/jest.config.mjs +++ /dev/null @@ -1,17 +0,0 @@ -import nextJest from 'next/jest.js' - -const createJestConfig = nextJest({ - // Provide the path to your Next.js app to load next.config.js and .env files in your test environment - dir: './', -}) - -// Add any custom config to be passed to Jest -/** @type {import('jest').Config} */ -const config = { - // Add more setup options before each test is run - setupFilesAfterEnv: ['/jest.setup.ts'], - testEnvironment: 'jest-environment-jsdom', -} - -// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async -export default createJestConfig(config) diff --git a/packages/diracx-web/jest.setup.ts b/packages/diracx-web/jest.setup.ts deleted file mode 100644 index d0de870d..00000000 --- a/packages/diracx-web/jest.setup.ts +++ /dev/null @@ -1 +0,0 @@ -import "@testing-library/jest-dom"; diff --git a/packages/diracx-web/package.json b/packages/diracx-web/package.json index 3dffca0e..08f1d7c6 100644 --- a/packages/diracx-web/package.json +++ b/packages/diracx-web/package.json @@ -8,8 +8,7 @@ "start": "next start", "lint": "next lint", "ts-lint": "tsc -noEmit -incremental", - "postinstall": "node ../../node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public", - "prepare": "husky" + "postinstall": "node ../../node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public" }, "dependencies": { "@axa-fr/react-oidc": "^7.22.6", @@ -33,21 +32,15 @@ "devDependencies": { "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", - "@testing-library/jest-dom": "^6.4.6", "@testing-library/react": "^16.0.0", "@testing-library/user-event": "^14.5.1", - "@types/jest": "^29.5.12", "cypress": "^13.12.0", "eslint": "^8.56.0", "eslint-config-next": "^14.2.3", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.29.1", - "husky": "^9.0.11", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", "lint-staged": "^15.2.2", "prettier": "^3.2.5", - "ts-jest": "^29.1.5", "tsc-files": "^1.1.4", "typescript": "5.4.5" },