Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

107 changes: 0 additions & 107 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ storybook-static
terraform

.npmrc
.vs

cypress/screenshots
cypress/videos
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- `useConstructor` hook using state instead of ref for React 19 compatibility.

### Added

- `useConstructor` hook that executes a provided callback only once during the component's lifecycle, similar to a constructor.
8 changes: 6 additions & 2 deletions cypress/component/useConstructor.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe("useConstructor", () => {
cy.get("@initSpy").should("have.been.calledOnce");

// Cause several re-renders
cy.contains("Increment").click().click().click();
cy.contains("Increment").click();
cy.contains("Increment").click();
cy.contains("Increment").click();
cy.get("[data-cy='count']").should("have.text", "3");

cy.get("@initSpy").should("have.been.calledOnce");
Expand All @@ -45,7 +47,9 @@ describe("useConstructor", () => {
};

const Child: React.FC = () => {
useConstructor(() => initSpy());
useConstructor(() => {
initSpy();
});
return <div data-cy="child">Child</div>;
};

Expand Down
56 changes: 0 additions & 56 deletions cypress/component/useHelloWorld.cy.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
54 changes: 54 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import neolutionEslintConfig from "@neolution-ch/eslint-config-neolution";

export default [
{
ignores: ["vite.config.ts"],
},
...neolutionEslintConfig.configs.flat.getConfig({
...neolutionEslintConfig.configs.flat.defaults["react-library"],
cypressRecommended: true,
}),
{
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["src/**"],
message: "Use relative import path instead.",
},
{
group: ["**/../src/**"],
message: "Do not reach the 'src' folder in a relative path.",
},
],
},
],
},
},
{
files: ["**/cypress/**"],
rules: {
"@typescript-eslint/no-namespace": [
"error",
{
allowDeclarations: true,
allowDefinitionFiles: true,
},
],
},
},
{
files: ["eslint.config.ts"],
rules: {
"unicorn/prefer-module": "off",
},
},
{
files: ["**/*.cy.tsx"],
rules: {
"no-restricted-imports": "off",
},
},
];
40 changes: 18 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"types": "./dist/src/index.d.ts",
"import": "./dist/index.modern.js",
"require": "./dist/index.js"
}
Expand All @@ -30,8 +30,8 @@
"dist"
],
"scripts": {
"build": "rollup -c",
"lint": "eslint \"**/*.{ts,tsx}\" --cache --max-warnings 0",
"build": "rollup -c --configPlugin rollup-plugin-typescript2",
"lint": "eslint --cache",
"prepack": "yarn build",
"prepare-pr": "yarn prettier . --write && yarn lint && yarn build && yarn test",
"prettier-check": "prettier --check .",
Expand All @@ -46,38 +46,33 @@
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.21.8",
"@neolution-ch/eslint-config-neolution": "^2.3.0",
"@popperjs/core": "^2.11.7",
"@release-it/keep-a-changelog": "^4.0.0",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.1",
"@types/jest": "^29.5.3",
"@types/node": "^18.16.3",
"@types/react": "^18.3.4",
"@types/node": "^20.11.1",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@types/rollup-plugin-peer-deps-external": "^2.2.6",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@vitejs/plugin-react": "^5.0.2",
"@typescript-eslint/parser": "^8.56.1",
"@vitejs/plugin-react": "^5.1.4",
"concurrently": "^8.0.1",
"cross-env": "^7.0.3",
"cypress": "^15.0.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-jsdoc": "^46.4.4",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-storybook": "^0.6.12",
"eslint": "^9.25.1",
"jest": "^29.6.1",
"jest-localstorage-mock": "^2.4.26",
"jiti": "^2.6.1",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"prettier": "^3.8.1",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"release-it": "^16.1.2",
"rollup": "^3.21.4",
"rollup": "^4.32.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.34.1",
"shx": "^0.3.4",
Expand All @@ -89,7 +84,8 @@
"yalc": "^1.0.0-pre.53"
},
"peerDependencies": {
"react": "^18.0.0"
"react": "^18.2.0 || ^19.2.0",
Comment thread
manni497 marked this conversation as resolved.
"react-dom": "^18.2.0 || ^19.2.0"
},
"engines": {
"node": ">=20"
Expand Down
Loading
Loading