From b03bbe962432f49cb08dc94a684d552f8ba067ac Mon Sep 17 00:00:00 2001 From: AlenaAlyona Date: Thu, 23 Mar 2023 14:34:03 +0100 Subject: [PATCH 1/3] fix: remove unused waitFor method from the imports --- src/hooks/useHasFocus/useHasFocus.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useHasFocus/useHasFocus.test.tsx b/src/hooks/useHasFocus/useHasFocus.test.tsx index f5bfed7..d780188 100644 --- a/src/hooks/useHasFocus/useHasFocus.test.tsx +++ b/src/hooks/useHasFocus/useHasFocus.test.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-no-literals */ /* eslint-disable react/no-multi-comp */ -import { act, render, waitFor } from '@testing-library/react'; +import { act, render } from '@testing-library/react'; import { useRef, type ReactElement } from 'react'; import { useHasFocus } from './useHasFocus.js'; From 169ac4814b75ccb65b25aaa305a9bb4ffbd03a53 Mon Sep 17 00:00:00 2001 From: AlenaAlyona Date: Thu, 23 Mar 2023 14:36:42 +0100 Subject: [PATCH 2/3] fix: plop template stories file --- plop-templates/hook/{{camelCase hookName}}.stories.tsx.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plop-templates/hook/{{camelCase hookName}}.stories.tsx.hbs b/plop-templates/hook/{{camelCase hookName}}.stories.tsx.hbs index fabe08f..24fca5f 100644 --- a/plop-templates/hook/{{camelCase hookName}}.stories.tsx.hbs +++ b/plop-templates/hook/{{camelCase hookName}}.stories.tsx.hbs @@ -1,11 +1,12 @@ import type { StoryObj } from '@storybook/react'; +import type { ReactElement } from 'react'; import { {{camelCase hookName}} } from './{{camelCase hookName}}.js'; export default { title: 'hooks/{{camelCase hookName}}', }; -function DemoComponent() { +function DemoComponent(): ReactElement { {{camelCase hookName}}(); return ( From 3fcbf83bb22fc0f56b2840f555c6d8c65de1df61 Mon Sep 17 00:00:00 2001 From: Arjan van Wijk Date: Mon, 20 Mar 2023 17:24:27 +0100 Subject: [PATCH 3/3] Fix and update plop files - should output correctly in hooks folder - was breaking because of missing `}` - was missing `.js` extension when added in `src/index.ts` --- plop-templates/hook/{{camelCase hookName}}.test.tsx.hbs | 2 +- plopfile.cjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plop-templates/hook/{{camelCase hookName}}.test.tsx.hbs b/plop-templates/hook/{{camelCase hookName}}.test.tsx.hbs index da44699..b7874a2 100644 --- a/plop-templates/hook/{{camelCase hookName}}.test.tsx.hbs +++ b/plop-templates/hook/{{camelCase hookName}}.test.tsx.hbs @@ -1,5 +1,5 @@ import { renderHook } from '@testing-library/react'; -import { {{camelCase hookName}} } from './{{camelCase hookName}.js'; +import { {{camelCase hookName}} } from './{{camelCase hookName}}.js'; describe('{{camelCase hookName}}', () => { it('should not crash', async () => { diff --git a/plopfile.cjs b/plopfile.cjs index c500004..bbeadcc 100644 --- a/plopfile.cjs +++ b/plopfile.cjs @@ -23,13 +23,13 @@ module.exports = function (plop) { type: 'addMany', base: 'plop-templates/hook', templateFiles: 'plop-templates/hook/*.*', - destination: `src/{{camelCase hookName}}/`, + destination: `src/hooks/{{camelCase hookName}}/`, }, { type: 'append', path: 'src/index.ts', pattern: /(\/\* PLOP_ADD_EXPORT \*\/)/gi, - template: `export * from './{{camelCase hookName}}/{{camelCase hookName}}';`, + template: `export * from './hooks/{{camelCase hookName}}/{{camelCase hookName}}.js';`, }, ]; },