From 9dc0d6b657b78ed0fe6811952885fc72588d2b05 Mon Sep 17 00:00:00 2001 From: Jiuzhen Pan <2216991777@qq.com> Date: Fri, 23 Dec 2022 20:00:12 -0800 Subject: [PATCH] fix: eslint fix --- .eslintrc.js | 5 +++-- .prettierrc.js | 31 +++++++++++++++++++++++++- src/components/form/SelectExamples.tsx | 1 + src/components/framework/Search.tsx | 4 +++- tsconfig.json | 11 ++++++--- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4fb7511..5f14338 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,7 @@ module.exports = { 'warn', { props: 'never', children: 'never' }, ], - + "@typescript-eslint/ban-ts-comment": "off", //#region //*=========== Import Sort =========== 'simple-import-sort/exports': 'warn', 'simple-import-sort/imports': [ @@ -67,5 +67,6 @@ module.exports = { React: true, JSX: true, }, - ignorePatterns: ["ThemeContext.tsx", "./src/lib/useScrolled.tsx", "./**/Search.tsx"], + ignorePatterns: ["ThemeContext.tsx", "useScrolled.tsx", "./**/Search.tsx"], + }; diff --git a/.prettierrc.js b/.prettierrc.js index 68ff0f7..8a76ad1 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -4,7 +4,36 @@ module.exports = { jsxSingleQuote: true, tabWidth: 2, semi: true, - importOrder: ["^@/(.*)$", "^~/(.*)$", "^[./]"], + importOrder: [ + // ext library & side effect imports + ['^@?\\w', '^\\u0000'], + // {s}css files + ['^.+\\.s?css$'], + // Lib and hooks + ['^@/lib', '^@/hooks'], + // static data + ['^@/data'], + // components + ['^@/components', '^@/container'], + // zustand store + ['^@/store'], + // Other imports + ['^@/'], + // relative paths up until 3 level + [ + '^\\./?$', + '^\\.(?!/?$)', + '^\\.\\./?$', + '^\\.\\.(?!/?$)', + '^\\.\\./\\.\\./?$', + '^\\.\\./\\.\\.(?!/?$)', + '^\\.\\./\\.\\./\\.\\./?$', + '^\\.\\./\\.\\./\\.\\.(?!/?$)', + ], + ['^@/types'], + // other that didnt fit in + ['^'], + ], importOrderSeparation: true, importOrderSortSpecifiers: true }; \ No newline at end of file diff --git a/src/components/form/SelectExamples.tsx b/src/components/form/SelectExamples.tsx index 118d344..f767707 100644 --- a/src/components/form/SelectExamples.tsx +++ b/src/components/form/SelectExamples.tsx @@ -89,6 +89,7 @@ const CustomSelect = ({ className = '' }) => { label="What's on the menu?" placeholder='Select as many as you like' multiple + // eslint-disable-next-line @typescript-eslint/ban-ts-comment /* @ts-ignore */ selectedItemsClassName='flex flex-wrap p-2 gap-2' rednerOptionItem={({ item, Option }) => ( diff --git a/src/components/framework/Search.tsx b/src/components/framework/Search.tsx index bc94695..5f17d77 100644 --- a/src/components/framework/Search.tsx +++ b/src/components/framework/Search.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck import { createAutocomplete } from '@algolia/autocomplete-core'; import { getAlgoliaResults } from '@algolia/autocomplete-preset-algolia'; @@ -6,8 +8,8 @@ import algoliasearch from 'algoliasearch/lite'; import clsx from 'clsx'; import { useRouter } from 'next/router'; import { - Fragment, forwardRef, + Fragment, useEffect, useId, useRef, diff --git a/tsconfig.json b/tsconfig.json index 3b5ce39..026798c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "target": "ES5", + "jsx": "preserve", + "target": "ESNext", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -13,12 +14,16 @@ "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", "baseUrl": ".", "paths": { "@/*": ["./src/*"], "~/*": ["./public/*"] - } + }, + "plugins": [ + { + "name": "next" + } + ] }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.mdx"], "exclude": ["node_modules"],