Skip to content

Commit

Permalink
chore: prettier & eslint 설정 (#9)
Browse files Browse the repository at this point in the history
* chore: vscode 저장 시 eslint 자동 적용 추가

* chore: 프로젝트별 lint-staged 설정

* chore: .husky pre-push 파일 추가

* chore: .prettierrc 파일 추가

* style: 전체 코드 스타일 적용
  • Loading branch information
eeseung authored Oct 25, 2024
1 parent 64906aa commit 761b7c2
Show file tree
Hide file tree
Showing 25 changed files with 230 additions and 235 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 📝 이슈 개요

## ✅ To-do

- [ ]
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## #️⃣ 관련 이슈

- #

## 💡 작업 내용
Expand Down
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pnpm lint-staged
pnpm build
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm build
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"printWidth": 120,
"arrowParens": "avoid",
"semi": false,
"endOfLine": "lf",
"useTabs": false,
"tabWidth": 2,
"quoteProps": "as-needed",
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"proseWrap": "preserve"
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"eslint.workingDirectories": [{ "mode": "auto" }],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
4 changes: 2 additions & 2 deletions apps/docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["@freemed-kit/eslint-config/storybook.js"],
};
extends: ['@freemed-kit/eslint-config/storybook.js'],
}
41 changes: 0 additions & 41 deletions apps/docs/.storybook/main.js

This file was deleted.

38 changes: 38 additions & 0 deletions apps/docs/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { StorybookConfig } from '@storybook/react-vite'
import { dirname, join, resolve } from 'path'

function getAbsolutePath(value: string) {
return dirname(require.resolve(join(value, 'package.json')))
}

const config: StorybookConfig = {
stories: ['../stories/*.stories.tsx', '../stories/**/*.stories.tsx'],
addons: [getAbsolutePath('@storybook/addon-links'), getAbsolutePath('@storybook/addon-essentials')],
framework: {
name: getAbsolutePath('@storybook/react-vite'),
options: {},
},

core: {},

async viteFinal(config, { configType }) {
// customize the Vite config here
return {
...config,
define: { 'process.env': {} },
resolve: {
alias: [
{
find: 'ui',
replacement: resolve(__dirname, '../../../packages/ui/'),
},
],
},
}
},
docs: {
autodocs: true,
},
}

export default config
2 changes: 1 addition & 1 deletion apps/docs/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import "@freemed-kit/ui/dist/index.css";
import '@freemed-kit/ui/dist/index.css'
6 changes: 6 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@
"typescript": "^5.3.3",
"vite": "^5.1.4",
"vite-tsconfig-paths": "^5.0.1"
},
"lint-staged": {
"stories/*.stories.tsx": [
"prettier --write",
"eslint --fix --max-warnings=0"
]
}
}
69 changes: 31 additions & 38 deletions apps/docs/stories/button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
import type { Meta, StoryObj } from "@storybook/react";
import { Button } from "@freemed-kit/ui";
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from '@freemed-kit/ui'

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof Button> = {
title: "Example/Button",
title: 'Example/Button',
component: Button,
tags: ["autodocs"],
tags: ['autodocs'],
argTypes: {
children: { control: "text", defaultValue: "Button" },
children: { control: 'text', defaultValue: 'Button' },
variant: {
control: "select",
options: [
"primary",
"destructive",
"outline",
"secondary",
"ghost",
"link",
],
control: 'select',
options: ['primary', 'destructive', 'outline', 'secondary', 'ghost', 'link'],
},
size: { control: "radio", options: ["sm", "md", "lg", "icon"] },
asChild: { control: "boolean" },
onClick: { action: "clicked", type: "function" },
size: { control: 'radio', options: ['sm', 'md', 'lg', 'icon'] },
asChild: { control: 'boolean' },
onClick: { action: 'clicked', type: 'function' },
},
};
}

export default meta;
type Story = StoryObj<typeof Button>;
export default meta
type Story = StoryObj<typeof Button>

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default: Story = {
args: {
variant: "default",
children: "Button",
variant: 'default',
children: 'Button',
},
};
}

export const Destructive: Story = {
args: {
variant: "destructive",
children: "Destructive Button",
variant: 'destructive',
children: 'Destructive Button',
},
};
}

export const Outline: Story = {
args: {
variant: "outline",
children: "Outline Button",
variant: 'outline',
children: 'Outline Button',
},
};
}

export const Secondary: Story = {
args: {
variant: "secondary",
children: "Secondary Button",
variant: 'secondary',
children: 'Secondary Button',
},
};
}

export const Ghost: Story = {
args: {
variant: "ghost",
children: "Ghost Button",
variant: 'ghost',
children: 'Ghost Button',
},
};
}

export const Link: Story = {
args: {
variant: "link",
children: "Link Button",
variant: 'link',
children: 'Link Button',
},
};
}
8 changes: 4 additions & 4 deletions apps/docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [react(), tsconfigPaths()],
});
})
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,5 @@
"engines": {
"node": ">=20",
"pnpm": ">=9"
},
"workspaces": [
"apps/*",
"packages/*"
],
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint --fix --max-warnings=0"
]
}
}
17 changes: 7 additions & 10 deletions packages/eslint-config/library.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require("node:path");
const { resolve } = require('node:path')

const project = resolve(process.cwd(), "tsconfig.json");
const project = resolve(process.cwd(), 'tsconfig.json')

/*
* This is a custom ESLint configuration for use with
Expand All @@ -12,24 +12,21 @@ const project = resolve(process.cwd(), "tsconfig.json");
*/

module.exports = {
extends: [
"@vercel/style-guide/eslint/node",
"@vercel/style-guide/eslint/typescript",
].map(require.resolve),
extends: ['@vercel/style-guide/eslint/node', '@vercel/style-guide/eslint/typescript'].map(require.resolve),
parserOptions: {
project,
},
plugins: ["only-warn"],
plugins: ['only-warn'],
globals: {
React: true,
JSX: true,
},
settings: {
"import/resolver": {
'import/resolver': {
typescript: {
project,
},
},
},
ignorePatterns: ["node_modules/", "dist/"],
};
ignorePatterns: ['node_modules/', 'dist/'],
}
21 changes: 10 additions & 11 deletions packages/eslint-config/react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require("node:path");
const { resolve } = require('node:path')

const project = resolve(process.cwd(), "tsconfig.json");
const project = resolve(process.cwd(), 'tsconfig.json')

/*
* This is a custom ESLint configuration for use a library
Expand All @@ -13,27 +13,26 @@ const project = resolve(process.cwd(), "tsconfig.json");

module.exports = {
extends: [
"@vercel/style-guide/eslint/browser",
"@vercel/style-guide/eslint/typescript",
"@vercel/style-guide/eslint/react",
'@vercel/style-guide/eslint/browser',
'@vercel/style-guide/eslint/typescript',
'@vercel/style-guide/eslint/react',
].map(require.resolve),
parserOptions: {
project,
},
plugins: ["only-warn"],
plugins: ['only-warn'],
globals: {
JSX: true,
},
settings: {
"import/resolver": {
'import/resolver': {
typescript: {
project,
},
},
},
ignorePatterns: ["node_modules/", "dist/", ".eslintrc.js", "**/*.css"],
// add rules configurations here
ignorePatterns: ['node_modules/', 'dist/', '.eslintrc.js', '**/*.css'],
rules: {
"import/no-default-export": "off",
'import/no-default-export': 'off',
},
};
}
Loading

0 comments on commit 761b7c2

Please sign in to comment.