From cb500dd023cccab57fd01244f1fba4d466c1dee1 Mon Sep 17 00:00:00 2001 From: tosaken1116 Date: Wed, 8 Nov 2023 13:50:11 +0900 Subject: [PATCH 1/3] chore: add import strict path rule --- .eslintrc.json | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4b738c4..9d897e4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -77,17 +77,28 @@ // modelコンポーネントにおいて、pageのimportを禁止する { "target": "./src/components/model", - "from": ["./src/components/page"] + "from": [ + "./src/components/page", + "./node_modules/@radix-ui/", + "./node_modules/react-error-boundary" + ] }, // pageコンポーネントにおいて、他のpageコンポーネントからのimportを禁止する { "target": "./src/components/page/**/index.tsx", - "from": ["./src/components/page/**/index.tsx"] + "from": [ + "./src/components/page/**/index.tsx", + "./node_modules/@radix-ui/" + ] }, // appディレクトリ配下においてmodel,uiのimportを禁止する { "target": "./src/app/**/page.tsx", - "from": ["./src/components/model", "./src/components/ui"] + "from": [ + "./src/components/model", + "./src/components/ui", + "./node_modules/@radix-ui/" + ] } ] } From 25e365860f2a1ea8f76e429593b0918bacfe91f2 Mon Sep 17 00:00:00 2001 From: tosaken1116 Date: Wed, 8 Nov 2023 20:27:17 +0900 Subject: [PATCH 2/3] chore: add rule of divide import --- .eslintrc.json | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9d897e4..ddf3f86 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,13 @@ "parserOptions": { "project": "./tsconfig.json" }, - "plugins": ["react", "import", "unused-imports", "jsx-a11y"], + "plugins": [ + "react", + "import", + "unused-imports", + "jsx-a11y", + "@typescript-eslint" + ], "rules": { // 関数の戻り値の型を明示的に指定する "@typescript-eslint/explicit-function-return-type": "error", @@ -189,8 +195,13 @@ "@typescript-eslint/consistent-type-imports": [ "error", { - "prefer": "type-imports" + "prefer": "type-imports", + "disallowTypeAnnotations": false, + "fixStyle": "inline-type-imports" } - ] + ], + "import/consistent-type-specifier-style": ["error", "prefer-top-level"], + + "@typescript-eslint/no-import-type-side-effects": ["error"] } } From 9ca9ecbb0fc8e08e496634b67435dad775e44291 Mon Sep 17 00:00:00 2001 From: tosaken1116 Date: Wed, 8 Nov 2023 20:34:11 +0900 Subject: [PATCH 3/3] chore: fix code with rule change --- src/components/ui/Tag/index.tsx | 3 ++- src/libs/utils.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/ui/Tag/index.tsx b/src/components/ui/Tag/index.tsx index ab74890..75f2494 100644 --- a/src/components/ui/Tag/index.tsx +++ b/src/components/ui/Tag/index.tsx @@ -1,8 +1,9 @@ import type { FC, HTMLAttributes, ReactNode } from 'react'; -import { cva, type VariantProps } from 'class-variance-authority'; +import { cva } from 'class-variance-authority'; import Link from 'next/link'; +import type { VariantProps } from 'class-variance-authority'; import type { LinkProps as NextLinkProps } from 'next/link'; import { cn } from '@/libs/utils'; diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 1659b5e..9d7383e 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -1,4 +1,6 @@ -import { type ClassValue, clsx } from 'clsx'; +import { clsx } from 'clsx'; import { twMerge } from 'tailwind-merge'; +import type { ClassValue } from 'clsx'; + export const cn = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));