diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..583c539 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +pnpm lint +pnpm dlx lint-staged diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..5b3a720 --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +@nciocpl:registry=https://npm.pkg.github.com +engine-strict=true +legacy-peer-deps=true \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..673b075 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,11 @@ +import js from "@eslint/js"; +import globals from "globals"; +import tseslint from "typescript-eslint"; +import pluginReact from "eslint-plugin-react"; +import { defineConfig } from "eslint/config"; + +export default defineConfig([ + { files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } }, + tseslint.configs.recommended, + pluginReact.configs.flat.recommended, +]); diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 0000000..5403e0d --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,10 @@ +export default { + // Lint & Prettify TS and JS files + '*.{ts,tsx,js,jsx}': (filenames) => [ + `eslint --fix ${filenames.join(' ')}`, + `prettier --write ${filenames.join(' ')}`, + ], + // Prettify only Markdown and JSON files + '*.{md,json,css,scss}': (filenames) => + `prettier --write ${filenames.join(' ')}`, +}; diff --git a/package.json b/package.json index 3333f91..fb6a68a 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "format:check": "prettier --check 'src/**/*.{ts,tsx,scss,css,md}'", "storybook:build": "storybook build", "typecheck": "tsc --noEmit", - "prepublishOnly": "npm run build" + "prepare": "husky", + "prepublishOnly": "pnpm build" }, "repository": { "type": "git", @@ -73,6 +74,8 @@ }, "devDependencies": { "@changesets/cli": "^2.27.0", + "@eslint/js": "^9.39.2", + "@nciocpl/eslint-config-react": "^1.1.0-alpha.1", "@rollup/plugin-commonjs": "^28.0.0", "@rollup/plugin-node-resolve": "^16.0.0", "@rollup/plugin-typescript": "^12.1.0", @@ -85,25 +88,31 @@ "@types/jest": "^29.5.0", "@types/react": "^18.3.0", "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^8.16.0", - "@typescript-eslint/parser": "^8.16.0", - "eslint": "^8.57.0", + "@typescript-eslint/eslint-plugin": "^8.54.0", + "@typescript-eslint/parser": "^8.54.0", + "eslint": "^9.39.2", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-react": "^7.37.0", - "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-hooks": "^7.0.1", + "eslint-plugin-simple-import-sort": "^12.1.1", + "globals": "^17.3.0", + "husky": "^9.1.7", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "lint-staged": "^16.2.7", + "postcss-modules": "^6.0.0", "prettier": "^3.4.0", "react": "^18.3.0", "react-dom": "^18.3.0", "rollup": "^4.28.0", "rollup-plugin-dts": "^6.1.0", "rollup-plugin-scss": "^4.0.0", - "postcss-modules": "^6.0.0", "sass": "^1.82.0", "storybook": "^8.4.0", "ts-jest": "^29.2.0", - "typescript": "^5.7.0" + "typescript": "^5.7.0", + "typescript-eslint": "^8.54.0" }, "engines": { "node": ">=18.0.0"