• 티스토리 홈
  • 프로필사진
    슬용이
  • 방명록
  • 글 작성
슬용이
  • 프로필사진
    슬용이
    • 분류 전체보기 (43)
      • 생각한 것 (1)
      • 참여한 것 (2)
      • 읽은 것 (0)
      • Side Project (0)
      • Code Practice (4)
      • JavaScript (8)
      • HTML & CSS (12)
      • React (8)
      • 그 외 (8)
  • 방문자 수
    • 전체:
    • 오늘:
    • 어제:
# Home
# 공지사항
#
# 태그
# 검색결과
# 방명록
  • import order convention
    2022년 05월 29일
    • 슬용이
    • 작성자
    • 2022.05.29.:58

    코딩에서 사용되는 컨벤션Convention의 뜻은 '협업을 위한 규칙 or 표준 작성 기준'으로 보면 된다.

    react를 사용하다 보면 import를 많이 쓰게 되는데, import 순서에도 컨벤션이 있다고 한다.

    1번이 가장 위쪽에 입력되고 8번이 가장 아래쪽에 입력되는 순서이다.

     

     

    1. 노드 빌트인 모듈

    1. node "builtin" modules

    import fs from 'fs';
    import path from 'path';

     

    2. 외부 모듈

    2. "external" modules

    import _ from 'lodash';
    import chalk from 'chalk';

     

    3. 내부 모듈 (내부 경로를 다루기 위해 웹팩이나 경로를 따로 설정한 경우)

    3. "internal" modules (if you have configured your path or webpack to handle your internal paths differently)

    import foo from 'src/foo';

     

    4. 부모 디렉토리의 모듈

    4. modules from a "parent" directory

    import foo from '../foo';
    import qux from '../../foo/qux';

     

    5. 같거나 형제 경로에 있는 형제 모듈

    5. "sibling" modules from the same or a sibling's directory

    import bar from './bar';
    import baz from './bar/baz';

     

    6. 현재 디렉토리의 index

    6. "index" of the current directory

    import main from './';

     

     


     

     

     

    참조 :

    https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md

     

    GitHub - import-js/eslint-plugin-import: ESLint plugin with rules that help validate proper imports.

    ESLint plugin with rules that help validate proper imports. - GitHub - import-js/eslint-plugin-import: ESLint plugin with rules that help validate proper imports.

    github.com

     

    'React' 카테고리의 다른 글

    useParams와 useLocation을 이용한 페이지 이동 (1)  (0) 2022.06.05
    Comment component  (0) 2022.05.30
    input과 type으로 알아보는 useState ⚛️  (0) 2022.05.21
    [TIL] React Intro  (0) 2022.05.09
    React & JSX 기초  (0) 2022.05.08
    다음글
    다음 글이 없습니다.
    이전글
    이전 글이 없습니다.
    댓글
조회된 결과가 없습니다.
스킨 업데이트 안내
현재 이용하고 계신 스킨의 버전보다 더 높은 최신 버전이 감지 되었습니다. 최신버전 스킨 파일을 다운로드 받을 수 있는 페이지로 이동하시겠습니까?
("아니오" 를 선택할 시 30일 동안 최신 버전이 감지되어도 모달 창이 표시되지 않습니다.)
목차
표시할 목차가 없습니다.
    • 안녕하세요
    • 감사해요
    • 잘있어요

    티스토리툴바