From da4018df104f65a4be09679c116253fd5705b93f Mon Sep 17 00:00:00 2001 From: Aozaki Kuro Date: Sun, 11 Aug 2024 13:05:34 +0800 Subject: [PATCH] try: migrate to eslint 9 --- .eslintrc.js | 46 ---------------------------------------------- eslint.config.mjs | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 21 --------------------- postcss.config.js | 6 ------ postcss.config.mjs | 9 +++++++++ 5 files changed, 47 insertions(+), 73 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs delete mode 100644 postcss.config.js create mode 100644 postcss.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index a97e5f8..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,46 +0,0 @@ -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - env: { - es2021: true, - browser: true, - node: true, - }, - reportUnusedDisableDirectives: true, - parser: '@typescript-eslint/parser', - extends: [ - 'next/core-web-vitals', - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - // 'plugin:tailwindcss/recommended', - 'plugin:prettier/recommended', - ], - settings: { - react: { - pragma: 'React', - version: 'detect', - }, - 'import/resolver': { - node: { - extensions: ['.ts', '.tsx'], - }, - }, - }, - parserOptions: { - ecmaVersion: 'esnext', - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - plugins: ['@typescript-eslint'], - rules: { - '@next/next/no-img-element': 'off', - 'prefer-const': 'error', - - // TypeScript - '@typescript-eslint/ban-ts-comment': 0, - '@typescript-eslint/no-var-requires': 0, - '@typescript-eslint/no-explicit-any': 0, - }, -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..5e1c179 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,38 @@ +// @ts-check +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import js from '@eslint/js' + +import { FlatCompat } from '@eslint/eslintrc' +import { fixupConfigRules } from '@eslint/compat' + +import ts from 'typescript-eslint' +import prettierConfigRecommended from 'eslint-plugin-prettier/recommended' + +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, +}) + +const patchedConfig = fixupConfigRules([...compat.extends('next/core-web-vitals')]) + +const config = [ + ...patchedConfig, + ...ts.configs.recommended, + prettierConfigRecommended, + { + ignores: ['**/.next/**', '**/_next/**', '**/dist/**', '**/out/**'], + rules: { + '@next/next/no-img-element': 'off', + 'prefer-const': 'error', + '@typescript-eslint/ban-ts-comment': 0, + '@typescript-eslint/no-var-requires': 0, + '@typescript-eslint/no-explicit-any': 0, + }, + }, +] + +export default config diff --git a/package.json b/package.json index 8c58dc4..55aee8c 100644 --- a/package.json +++ b/package.json @@ -58,26 +58,5 @@ "*.{json,css,md,mdx}": [ "prettier --write" ] - }, - "pnpm": { - "overrides": { - "array-includes": "npm:@nolyfill/array-includes@latest", - "array.prototype.findlastindex": "npm:@nolyfill/array.prototype.findlastindex@latest", - "array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest", - "array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest", - "array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@latest", - "es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@latest", - "has": "npm:@nolyfill/has@latest", - "object.assign": "npm:@nolyfill/object.assign@latest", - "object.entries": "npm:@nolyfill/object.entries@latest", - "object.fromentries": "npm:@nolyfill/object.fromentries@latest", - "object.groupby": "npm:@nolyfill/object.groupby@latest", - "object.hasown": "npm:@nolyfill/object.hasown@latest", - "object.values": "npm:@nolyfill/object.values@latest", - "string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest", - "hasown": "npm:@nolyfill/hasown@latest", - "array.prototype.findlast": "npm:@nolyfill/array.prototype.findlast@latest", - "array.prototype.toreversed": "npm:@nolyfill/array.prototype.toreversed@latest" - } } } diff --git a/postcss.config.js b/postcss.config.js deleted file mode 100644 index 33ad091..0000000 --- a/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} diff --git a/postcss.config.mjs b/postcss.config.mjs new file mode 100644 index 0000000..d0c615b --- /dev/null +++ b/postcss.config.mjs @@ -0,0 +1,9 @@ +/** @type {import('postcss-load-config').Config} */ +const config = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} + +export default config