VSCode์์ Next.js + Typescript๋ก ๊ฐ์ธ ํ๋ก์ ํธ๋ฅผ ์งํํ๊ณ ์๋ค.
์์ฐ์ฑ์ ๋์ด์ฌ๋ฆฌ๊ธฐ ์ํด์ ํด๋ฆญ ํ ๋ฒ์ผ๋ก ์ ํด์ง ํ ๋ธ๋ฆฟ์ผ๋ก ์๋ 3๊ฐ์ง ํ์ผ์ ์์ฑํ๊ธฐ๋ฅผ ๊ตฌํํด๋ดค๋ค.
Component.tsx
Component.stories.tsx
Component.test.tsx
Folder Templates
์ฌ์ฉํ๊ธฐvscode extension์ธ Folder Templates
๋ฅผ ํ์ฉํ๋ค.
1. ํ๋ก์ ํธ ๋ฃจํธ ํด๋์ .fttemplates
ํด๋๋ฅผ ์์ฑํ๋ค.
2. component template
ํด๋๋ฅผ ์์ฑํ๋ค.
3. component template
ํด๋ ์๋ ๋ค์๊ณผ ๊ฐ์ด ํ์ผ๋ค์ ์์ฑํ๋ค.
.fttemplates/
โโโ component template/
โ โโโ [FTName].tsx
โ โโโ [FTName].stories.tsx
โ โโโ [FTName].test.tsx
โ โโโ index.ts
โ โโโ .ftsettings.json
export type [FTName]Props = {}
// eslint-disable-next-line no-empty-pattern
function [FTName]({}: [FTName]Props) {
return <div data-testid="[FTName]-component"/>
}
export default [FTName];
import type { Meta, StoryObj } from '@storybook/react';
import [FTName] from './[FTName]';
const meta = {
title: 'Component/[FTName]',
component: [FTName],
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: { },
args: { },
} satisfies Meta<typeof [FTName]>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {},
};
import { describe, expect, it } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import [FTName] from './[FTName]';
describe('๐จ [FTName] ์ปดํฌ๋ํธ ํ
์คํธ', () => {
it('๊ธฐ๋ณธ ๋ ๋๋ง ํ
์คํธ', () => {
render(<[FTName] />);
const element = screen.getByTestId('[FTName]-component');
expect(element).toBeInTheDocument();
});
});
[__existingcontent__]
์ ํ์ผ์ ๋ฎ์ด์ฐ๊ธฐํ ๊ฒฝ์ฐ ์ด์ ๋ด์ฉ์ด ์ฌ๊ธฐ ๋ด๊ธด๋ค.```tsx
[__existingcontent__]
export * from './[FTName]';
export { default as [FTName] } from './[FTName]';
```
"overwriteExistingFiles": "always"
: ์ด๋ฏธ ์๋ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ ๋ฎ์ด์์ด๋ค."omitParentDirectory": true
: ํด๋๋ฅผ ์๋ก ์์ฑํ์ง ์๊ณ , ๋ถ๋ชจ ํด๋์ ํ์ผ๋ค์ ์ถ๊ฐํ๋ค.```tsx
{
"name": "๐จ component template",
"overwriteExistingFiles": "always",
"omitParentDirectory": true
}
```
๋๐
์ด ๊ธฐ๋ฅ ๊ตฌํํ๋ ๋ฒ ์์๋ณด๋ฉด์ ์ด์ฉ๋ค ์๊ฒ ๋ extension
https://marketplace.visualstudio.com/items?itemName=antfu.file-nesting
์๋์ฒ๋ผ ๊ด๋ จ ํ์ผ๋ค์ ๋ฌถ์ด์ค๋ค.
๋ฃจํธ ํด๋์ config ํ์ผ๋ค๋ ๋ฌถ์ด์ค์ ๋๊ฒ ํธํ๋ค. settings.json์์ ์ปค์คํ ๋ ๊ฐ๋ฅ ๐