Skip to content

monorepo, eslint 설정

OriginJang edited this page Nov 12, 2019 · 7 revisions

monorepo 설정

yarn 설치

npm install yarn --global

yarn workspace 설정

  1. root에서 yarn init 실행

yarn init

  1. monorepo 디렉토리 생성

mkdir server client

  1. monorepo init(server 디렉토리만)
cd server
yarn init
  1. root 디렉토리의 package.js 수정
{
  ...
  workspaces: [server, client],
  private: true,
  ...
}

eslint(vscode) 설정

vscode ESLint

  1. vscode extensions에서 ESLint 설치

  2. elint package 설치

root 디렉토리
yarn workspace server add eslint --dev
  1. .eslintrc.json
cd server
  • command + shift + p 로 팔레트를 실행한 다음 create ESLINT Configuration 입력
  • options
    • How would you like to use ESLint? To check syntax, find problems, and enforce code style
    • What type of modules does your project use? CommonJS (require/exports)
    • Which framework does your project use? None of these
    • Does your project use TypeScript? No
    • Where does your code run? Node
    • How would you like to define a style for your project? Use a popular style guide
    • Which style guide do you want to follow? Airbnb (https://github.com/airbnb/javascript)
    • What format do you want your config file to be in? JSON
    • Would you like to install them now with npm? Yes

monorepo + eslint 적용

각각의 monorepo에 맞는 옵션을 적용한 eslint를 실행하기 위해서는 working directories에 repo를 설정해줘야한다.

./.vscode
{
  "eslint.workingDirectories": ["server", "client"],
}
directory
root
|-.vscode
|   |-settings.json
|
|-client
|   |-.eslintrc.json
|
|-server
|   |-.eslintrc.json
Clone this wiki locally