Skip to content

Commit

Permalink
refactor(*): eslint, typescript config 분리 (#37)
Browse files Browse the repository at this point in the history
* refactor: config 분리

* chore: eslint conflict

* feat: emotion 세팅

* chore: remove only-warn

* chore: 리뷰 반영
  • Loading branch information
Andrevile authored Jul 4, 2024
1 parent dd87ce2 commit 3bed7fc
Show file tree
Hide file tree
Showing 26 changed files with 259 additions and 231 deletions.
4 changes: 2 additions & 2 deletions apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@sambad/config/eslint/next.js'],
extends: ['@sambad/eslint-config/next.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
};
6 changes: 5 additions & 1 deletion apps/web/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
compiler: {
emotion: true,
},
};

export default nextConfig;
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"next": "14.2.4"
},
"devDependencies": {
"@sambad/config": "workspace:*",
"@sambad/eslint-config": "workspace:*",
"@sambad/typescript-config": "workspace:*",
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"extends": "@sambad/config/typescript/nextjs.json",
"extends": "@sambad/typescript-config/nextjs.json",
"compilerOptions": {
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "app/B.js", "app/A.js"],
"include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
},
"dependencies": {
"@emotion/react": "^11.11.4"
},
"devDependencies": {
"next": "14.2.4",
"prettier": "^3.2.5",
"turbo": "^2.0.4",
"typescript": "^5.4.5",
"next": "14.2.4"
"typescript": "^5.4.5"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
54 changes: 0 additions & 54 deletions packages/core/config/eslint/library.js

This file was deleted.

57 changes: 0 additions & 57 deletions packages/core/config/eslint/next.js

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ const project = resolve(process.cwd(), 'tsconfig.json');

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier', 'turbo'],
plugins: ['@typescript-eslint', 'only-warn', 'import'],
plugins: ['@typescript-eslint', 'import'],
globals: {
React: true,
JSX: true,
},
env: {
browser: true,
},
settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
'import/resolver': {
Expand All @@ -21,12 +17,11 @@ module.exports = {
},
},
},
ignorePatterns: ['.*.js', 'node_modules/', 'dist/'],
rules: {
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'object', 'type'],
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
alphabetize: {
order: 'asc',
caseInsensitive: true,
Expand All @@ -45,6 +40,7 @@ module.exports = {
'no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
'@typescript-eslint/consistent-type-imports': 'warn',
'react/no-unknown-property': ['error', { ignore: ['css'] }],
},
overrides: [{ files: ['*.js?(x)', '*.ts?(x)'] }],
};
11 changes: 11 additions & 0 deletions packages/core/eslint-config/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const base_eslint_config = require('./base.js');

/** @type {import("eslint").Linter.Config} */
module.exports = {
...base_eslint_config,
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier', 'turbo'],
env: {
node: true,
},
ignorePatterns: ['.*.js', 'node_modules/', 'dist/'],
};
18 changes: 18 additions & 0 deletions packages/core/eslint-config/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const base_eslint_config = require('./base.js');

/** @type {import("eslint").Linter.Config} */
module.exports = {
...base_eslint_config,
extends: [
'eslint:recommended',
'plugin:react/recommended',
'prettier',
require.resolve('@vercel/style-guide/eslint/next'),
'turbo',
],
env: {
node: true,
browser: true,
},
ignorePatterns: ['.*.js', 'node_modules/'],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@sambad/config",
"name": "@sambad/eslint-config",
"version": "0.0.0",
"private": true,
"files": [
Expand All @@ -14,7 +14,6 @@
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.34.3",
"typescript": "^5.3.3"
}
Expand Down
11 changes: 11 additions & 0 deletions packages/core/eslint-config/react-internal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const base_eslint_config = require('./base.js');

/** @type {import("eslint").Linter.Config} */
module.exports = {
...base_eslint_config,
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier', 'turbo'],
env: {
browser: true,
},
ignorePatterns: ['.*.js', 'node_modules/', 'dist/'],
};
3 changes: 1 addition & 2 deletions packages/core/sds/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@repo/config/eslint/react-internal.js'],
extends: ['@sambad/eslint-config/react-internal.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.lint.json',
tsconfigRootDir: __dirname,
},
};
3 changes: 2 additions & 1 deletion packages/core/sds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint": "eslint . --max-warnings 0"
},
"devDependencies": {
"@sambad/config": "workspace:*",
"@sambad/eslint-config": "workspace:*",
"@sambad/typescript-config": "workspace:*",
"@turbo/gen": "^1.12.4",
"@types/node": "^20.11.24",
"@types/eslint": "^8.56.5",
Expand Down
13 changes: 11 additions & 2 deletions packages/core/sds/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use client';

import { HTMLAttributes, ReactNode } from 'react';
import { css } from '@emotion/react';

import type { HTMLAttributes, ReactNode } from 'react';

interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
children: ReactNode;
Expand All @@ -10,7 +12,14 @@ interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {

export const Button = ({ children, className, appName, ...rest }: ButtonProps) => {
return (
<button className={className} onClick={() => alert(`Hello from your ${appName} app!`)} {...rest}>
<button
css={css`
background: red;
`}
className={className}
onClick={() => alert(`Hello from your ${appName} app!`)}
{...rest}
>
{children}
</button>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/sds/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@sambad/config/typescript/react-library.json",
"extends": "@sambad/typescript-config/react-library.json",
"compilerOptions": {
"outDir": "dist"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ES2022"
"target": "ES2022",
"types": ["@emotion/react/types/css-prop"]
}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/core/typescript-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@sambad/typescript-config",
"version": "0.0.0",
"private": true
}
3 changes: 1 addition & 2 deletions packages/web-domains/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@sambad/config/eslint/react-internal.js'],
extends: ['@sambad/eslint-config/react-internal.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.lint.json',
tsconfigRootDir: __dirname,
},
};
3 changes: 2 additions & 1 deletion packages/web-domains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"dependencies": {},
"devDependencies": {
"@sambad/sds": "workspace:*",
"@sambad/config": "workspace:*",
"@sambad/eslint-config": "workspace:*",
"@sambad/typescript-config": "workspace:*",
"@types/node": "^20.11.24",
"@types/eslint": "^8.56.5",
"@types/react": "^18.2.61",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-domains/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@sambad/config/typescript/react-library.json",
"extends": "@sambad/typescript-config/react-library.json",
"compilerOptions": {
"outDir": "dist"
},
Expand Down
Loading

0 comments on commit 3bed7fc

Please sign in to comment.