NestJS를 설치하면 프로젝트 루트에 .eslintrc.js 파일이 생성됩니다. 이 파일은 ESLint의 설정을 정의하며, 코드의 품질과 일관성을 유지하는 데 중요한 역할을 합니다.
.eslintrc.js 파일이란?ESLint는 JavaScript와 TypeScript 코드에서 잠재적인 문제를 찾아내고 코드 스타일을 강제하는 도구입니다. .eslintrc.js 파일은 ESLint의 설정을 지정하는 파일로, 프로젝트 내에서 코드 규칙을 정의하고 적용할 수 있습니다.
.eslintrc.js 내용module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
parser: '@typescript-eslint/parser'@typescript-eslint/parser를 사용합니다.project: 'tsconfig.json'tsconfigRootDir: __dirnametsconfig.json의 루트 디렉토리를 현재 디렉토리로 설정합니다.sourceType: 'module'plugins: ['@typescript-eslint/eslint-plugin']@typescript-eslint/eslint-plugin을 추가합니다.'plugin:@typescript-eslint/recommended''plugin:prettier/recommended'root: truenode: truejest: trueignorePatterns: ['.eslintrc.js'].eslintrc.js 파일은 ESLint의 검사 대상에서 제외합니다.'@typescript-eslint/interface-name-prefix': 'off'I 등)를 강제하지 않습니다.'@typescript-eslint/explicit-function-return-type': 'off''@typescript-eslint/explicit-module-boundary-types': 'off''@typescript-eslint/no-explicit-any': 'off'any 타입의 사용을 허용합니다.'eslint-plugin-import''eslint-plugin-jsx-a11y''eslint:recommended''plugin:react/recommended''semi': ['error', 'always']'quotes': ['error', 'single']overrides: [
{
files: ['*.test.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
],