TypeScript/TypeScript - 기초부터 실전까지

17. tsconfig.json, .eslintrc.js 설정

DEV-Front 2023. 10. 14. 16:19
반응형

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "target": "es5",
    "lib": ["es2015", "dom", "dom.iterable"],
    "noImplicitAny": false,
    "strict": true,
    "strictFunctionTypes": true
  },
  "include": ["./src/**/*"]
}

noImplicitAny 

- 암묵적으로 any를 추론하게 하지말고 Type에 any라도 무조건적으로 명시하도록 설정

 

strict

- strict플래그는 광범위한 유형 검사 동작을 활성화하여 프로그램 정확성을 더욱 강력하게 보장합니다. 

- 이 기능을 켜는 것은 아래에 설명된 모든 엄격 모드 제품군 옵션을 활성화하는 것과 같습니다 .

- 그런 다음 필요에 따라 개별 엄격 모드 제품군 검사를 끌 수 있습니다.

 

strictFunctionTypes

- 이 플래그를 활성화하면 함수 매개변수가 더 정확하게 확인됩니다.

 

참고 - Typescript 공식 TSCofing Reference

 

https://www.typescriptlang.org/tsconfig#strictFunctionTypes

 

TSConfig Reference - Docs on every TSConfig option

From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.

www.typescriptlang.org


.eslintrc.js

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
    jest: true,
  },
  extends: [
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
  ],
  plugins: ['prettier', '@typescript-eslint'],
  rules: {
    'prettier/prettier': [
      'error',
      {
        singleQuote: true,
        semi: true,
        useTabs: false,
        tabWidth: 2,
        printWidth: 80,
        bracketSpacing: true,
        arrowParens: 'avoid',
      },
    ],
    // '@typescript-eslint/no-explicit-any': 'off',
    // "@typescript-eslint/explicit-function-return-type": 'off',
    'prefer-const': 'off',
  },
  parserOptions: {
    parser: '@typescript-eslint/parser',
  },
};
반응형