Skip to content

Commit

Permalink
프론트엔드 프로젝트 설정 (#11)
Browse files Browse the repository at this point in the history
* chore: (#6) 프론트엔드 프로젝트 초기 개발 환경 구축
webpack, react, typescript, eslint
절대 경로 설정

* chore: (#6) styled-components 설치 및 global style 세팅

* chore: storybook 설치 및 세팅
styled-component 관련 세팅

* chore: 테스트 환경 구축
모의 테스트(단위 테스트, hook 테스트) 실행
  • Loading branch information
inyeong-kang authored Jul 6, 2023
1 parent 8ab237d commit 204b277
Show file tree
Hide file tree
Showing 25 changed files with 38,034 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
16 changes: 16 additions & 0 deletions frontend/.babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": []
}
99 changes: 99 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"extends": ["react-app", "eslint:recommended"],
"rules": {
"no-var": "error", // var 금지
"no-multiple-empty-lines": "error", // 여러 줄 공백 금지
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
"eqeqeq": "error", // 일치 연산자 사용 필수
"dot-notation": "error", // 가능하다면 dot notation 사용
"no-unused-vars": "error", // 사용하지 않는 변수 금지
"import/order": [
"error",
{
"groups": [
"type",
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"unknown"
],
"newlines-between": "always",
"pathGroups": [
{
"pattern": "react*",
"group": "external",
"position": "before"
},
{
"pattern": "@type/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@hooks/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@atoms/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@selectors/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@routes/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@api/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@pages/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@components/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@contants/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@utils/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@styles/**",
"group": "internal",
"position": "after"
},
{
"pattern": "@assets/**",
"group": "internal",
"position": "after"
}
],
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
"pathGroupsExcludedImportTypes": []
}
]
}
}
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
5 changes: 5 additions & 0 deletions frontend/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
printWidth: 100, // 한줄당 문자 100개로 제한
singleQuote: true, // "" => ''
arrowParens: 'avoid', // arrow function parameter가 하나일 경우 괄호 생략
};
37 changes: 37 additions & 0 deletions frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import path from 'path';
import type { StorybookConfig } from '@storybook/react-webpack5';

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
docs: {
autodocs: 'tag',
},
webpackFinal: async config => {
if (!config.resolve) {
config.resolve = {};
}

if (!config.resolve.plugins) {
config.resolve.plugins = [];
}

config.resolve.plugins.push(
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, '../tsconfig.json'),
})
);
return config;
},
};
export default config;
26 changes: 26 additions & 0 deletions frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Preview } from '@storybook/react';

import { GlobalStyle } from '../src/styles/globalStyle';
import React from 'react';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
decorators: [
Story => (
<>
<GlobalStyle />
<Story />
</>
),
],
};

export default preview;
17 changes: 17 additions & 0 deletions frontend/__test__/hook.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { renderHook, act } from '@testing-library/react';

import { useCount } from '../src/hooks/useCount';

/**
* @jest-environment jsdom
*/

test('useCount hook을 테스트한다.', () => {
const { result } = renderHook(() => useCount());

act(() => {
result.current.increase();
});

expect(result.current.count).toBe(1);
});
5 changes: 5 additions & 0 deletions frontend/__test__/unit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('테스트 설정한다.', () => {
test('1 + 1 = 2', () => {
expect(1 + 1).toBe(2);
});
});
3 changes: 3 additions & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
testEnvironment: 'jsdom',
};
Loading

0 comments on commit 204b277

Please sign in to comment.