Skip to content

πŸ‘©β€πŸ’» Coding Convention

Jongeun Kim edited this page Nov 18, 2020 · 4 revisions

μ½”λ”© μ»¨λ²€μ…˜

import κ·œμΉ™

  • μ™ΈλΆ€ λͺ¨λ“ˆκ³Ό λ‚΄λΆ€λͺ¨λ“ˆμ„ κ΅¬λΆ„ν•˜μ—¬ μ‚¬μš©ν•œλ‹€. μ™ΈλΆ€λͺ¨λ“ˆκ³Ό λ‚΄λΆ€λͺ¨λ“ˆ μ„ μ–Έμ‹œ 곡백으둜 κ΅¬λΆ„ν•œλ‹€. λ‚΄λΆ€λͺ¨λ“ˆμ˜ 경우 μ ˆλŒ€ 경둜λ₯Ό μ‚¬μš©ν•˜λŠ” λͺ¨λ“ˆκ³Ό μƒλŒ€ 경둜λ₯Ό μ‚¬μš©ν•˜λŠ” λͺ¨λ“ˆμ„ μΆ”κ°€λ‘œ κ΅¬λΆ„ν•œλ‹€.
import axios from 'axios'; 

import router from '@service/router'

import util from './util'

λ³€μˆ˜, ν•¨μˆ˜, 클래슀 λͺ…λͺ… κ·œμΉ™

  • νŒŒμΌλ„€μ΄λ°

    • μ»΄ν¬λ„ŒνŠΈ β†’ PascalCase
    • μ™Έ β†’ cammelCase
  • μƒμˆ˜ β†’ SNAKE_CASE

  • ν•¨μˆ˜ 및 λ³€μˆ˜ β†’ cammelCase

  • μ»΄ν¬λ„ŒνŠΈ β†’ PascalCase

  • 창의적인 단어 쓰지 μ•ŠκΈ° 😁 (제일 λ– μ˜€λ₯΄κΈ° 쉽고 기본적인 단어)

  • λ³€μˆ˜λŠ” λͺ…μ‚¬ν˜•μœΌλ‘œ μž‘μ„±

  • ν•¨μˆ˜λŠ” μ„œμˆ ν˜•μœΌλ‘œ μž‘μ„±

기타 μ½”λ”© κ·œμΉ™

  • htmlνƒœκ·Έ μ„ μ–Έ μ‹œ μ΅œλŒ€ν•œ μ‹œλ©˜ν‹±ν•œ νƒœκ·Έ μ‚¬μš©
  • λͺ¨λ‘κ°€ approve ν•œ 후에 merge ν•  수 μžˆλ‹€
  • μ½”λ“œ λ¦¬λ·°λŠ” ν•„μˆ˜! κΌ­ ν™•μΈν•˜κΈ°! 😠
  • html id + className은 snake_case둜 ν•œλ‹€.

eslint & prettier

  • 기본적으둜 eslint airbnbλ₯Ό λ”°λ₯Έλ‹€
  • μΆ”κ°€ν•˜κ³  싢은 룰이 μžˆμ„ 경우 μ˜κ²¬μ„ μ œμ‹œν•΄μ„œ λ…Όμ˜ 후에 반영 ν•  수 μžˆλ‹€

eslint

module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  extends: [
    'airbnb-base',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:prettier/recommended',
    'plugin:@typescript-eslint/recommended',
  ],
  rules: {
    'linebreak-style': 0,
    'import/prefer-default-export': 0,
    'prettier/prettier': 0,
  },
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
      alias: {
        map: [
          ['@api', './src/api'],
          ['@auth', './src/auth'],
          ['@config', './src/config'],
          ['@models', './src/models'],
          ['@util', './src/util/*'],
          ['@', './src'],
        ],
      },
    },
  },
};

prettier

{
  "singleQuote": true,
  "parser": "typescript",
  "semi": true,
  "useTabs": false,
  "tabWidth": 2,
  "trailingComma": "all",
  "printWidth": 100,
  "arrowParens": "always"
}

tsconfig

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["es2015", "es2016", "es2017", "es2018", "es2019", "es2020"],

    // sourceMap
    "sourceMap": true,

    // module
    "module": "commonjs",
    "moduleResolution": "node",
    "esModuleInterop": true,

    // lint
    "strict": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noFallthroughCasesInSwitch": true,

    // more spec
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "baseUrl": ".",
    "paths": {
      "@api/*": ["src/api/*"],
      "@auth/*": ["src/auth/*"],
      "@config/*": ["src/config/*"],
      "@models/*": ["src/models/*"],
      "@util/*": ["src/util/*"],
      "@/*": ["src/*"]
    }
  }
}