Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

환경 설정 #1

Open
yoon-junseo opened this issue Dec 24, 2022 · 0 comments
Open

환경 설정 #1

yoon-junseo opened this issue Dec 24, 2022 · 0 comments

Comments

@yoon-junseo
Copy link
Owner

yoon-junseo commented Dec 24, 2022

npm init

npm init -y를 통해 package.json 생성

react, react-dom 설치

npm i -D react react-dom @types/react @types/react-dom

  • 버전에 맞게 peerDependencies 추가
"peerDependencies": {
   "react": "*",
   "react-dom": "*"
}

typescript 설정

npm i -D typescript

  • 프로젝트 최상단에 tsconfig.json을 생성한다.
{
    "include": ["src"],
    "exclude": [
      "dist",
      "node_modules"
    ],
    "compilerOptions": {
      "module": "esnext",
      "lib": ["dom", "esnext"],
      "importHelpers": true,
      "declaration": true,
      "sourceMap": true,
      "rootDir": "./src",
      "outDir": "./dist/esm",
      "strict": true,
      "noImplicitReturns": true,
      "noFallthroughCasesInSwitch": true,
      "noUnusedLocals": true,
      "noUnusedParameters": true,
      "moduleResolution": "node",
      "jsx": "react",
      "esModuleInterop": true,
      "skipLibCheck": true,
      "forceConsistentCasingInFileNames": true,
    }
}

babel 설정

npm i -D @babel/core @babel/preset-react @babel/preset-typescript

// .babelrc.js
module.exports = {
  "presets": ["@babel/preset-react", "@babel/preset-typescript"],
}

eslint 설정

npm i -D eslint eslint-plugin-react eslint-plugin-react-hooks @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-airbnb

// .eslintrc.js
module.exports = {
  root: true,
  extends: [
    'airbnb',
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
  ],
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint', 'react', 'react-hooks'],
  rules: {
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
    'react/jsx-filename-extension': [
      2,
      {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    ],
    '@typescript-eslint/no-non-null-assertion': 'off',
    '@typescript-eslint/ban-ts-comment': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    'import/extensions': 'off',
    'import/order': [
      'error',
      {
        groups: ['external', 'sibling'],
        pathGroups: [
          {
            pattern: 'react',
            group: 'external',
            position: 'before',
          },
        ],
        pathGroupsExcludedImportTypes: ['react'],
        alphabetize: {
          order: 'asc',
          caseInsensitive: true,
        },
        'newlines-between': 'always',
      },
    ],
  },
  settings: {
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx'],
    },
    'import/resolver': {
      node: {
        extensions: ['.js', '.ts', '.jsx', '.tsx', '.json'],
      },
    },
    'import/extensions': ['.js', '.ts', '.mjs', '.jsx', '.tsx'],
  },
  env: {
    browser: true,
    node: true,
  },
  globals: {
    JSX: true,
  },
};
  • .eslintignore 생성
node_modules
dist

prettier 설정

npm i -D eslint-config-prettier eslint-plugin-prettier prettier

  • .prettierrc.js 생성
module.exports = {
  printWidth: 120,
  tabWidth: 2,
  singleQuote: true,
  trailingComma: 'all',
  semi: true,
  useTabs: false,
  endOfLine: 'auto',
  bracketSpacing: true,
  bracketLine: true,
};

roullup 설정

npm i -D rollup rollup-plugin-typescript2 @rollup/plugin-commonjs @rollup/plugin-node-resolve rollup-plugin-peer-deps-external @rollup/plugin-babel @rollup/plugin-image

storybook 설정

npx storybook init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant