From a5ed79b4b034894c2765880efae11e38b630150a Mon Sep 17 00:00:00 2001 From: Joo-Byungho Date: Wed, 31 Jul 2024 15:20:57 +0900 Subject: [PATCH] Feat: Update config of eslint version to 9 --- .eslintrc.js | 34 ------------------------------ eslint.config.mjs | 53 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++++ tsconfig.json | 12 +++-------- yarn.lock | 7 ++++++- 5 files changed, 66 insertions(+), 44 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 2954c03..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - }, - 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', - '@typescript-eslint/no-unused-vars': 'warn', - }, - overrides: [ - { - parser: '@babel/eslint-parser', - files: ['*.mjs'], - parserOptions: { - sourceType: 'module', - }, - }, - ], -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..923a1c8 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,53 @@ +import { FlatCompat } from '@eslint/eslintrc'; +import js from '@eslint/js'; +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import tsParser from '@typescript-eslint/parser'; +import globals from 'globals'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + { + ignores: ['**/.eslintrc.js'], + }, + ...compat.extends( + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ), + { + plugins: { + '@typescript-eslint': typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.node, + ...globals.jest, + }, + + parser: tsParser, + ecmaVersion: 5, + sourceType: 'module', + + parserOptions: { + project: 'tsconfig.json', + tsconfigRootDir: __dirname, + }, + }, + + 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', + }, + }, +]; diff --git a/package.json b/package.json index 55d1121..1d46098 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "", "private": true, "license": "MIT", + "type": "commonjs", "lint-staged": { "**/*": "prettier --write --ignore-unknown" }, @@ -65,6 +66,8 @@ "uuid": "^10.0.0" }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.8.0", "@nestjs/cli": "^10.4.2", "@nestjs/schematics": "^10.1.3", "@nestjs/testing": "^10.3.10", @@ -87,6 +90,7 @@ "eslint": "^9.8.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", + "globals": "^15.8.0", "husky": "^9.1.4", "jest": "^29.7.0", "pg-mem": "^2.8.1", diff --git a/tsconfig.json b/tsconfig.json index 9541def..0e41c90 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,12 +18,6 @@ "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false }, - "include": [ - "additional.d.ts", - "**/*.ts", - "**/*.tsx", - ], - "exclude": [ - "node_modules" - ], -} \ No newline at end of file + "include": ["additional.d.ts", "**/*.ts", "**/*.tsx", "**/*.mjs"], + "exclude": ["node_modules"] +} diff --git a/yarn.lock b/yarn.lock index 975818c..087e5d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1293,7 +1293,7 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.8.0": +"@eslint/js@9.8.0", "@eslint/js@^9.8.0": version "9.8.0" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.8.0.tgz#ae9bc14bb839713c5056f5018bcefa955556d3a4" integrity sha512-MfluB7EUfxXtv3i/++oh89uzAr4PDI4nn201hsp+qaXqsjAWzinlZEHEfPgAX4doIlKvPG/i0A9dpKxOLII8yA== @@ -5526,6 +5526,11 @@ globals@^14.0.0: resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== +globals@^15.8.0: + version "15.8.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-15.8.0.tgz#e64bb47b619dd8cbf32b3c1a0a61714e33cbbb41" + integrity sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw== + globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"