From 06d731511f09694f305137b4dfb7bc0fa5ee2bb7 Mon Sep 17 00:00:00 2001 From: nico1988 <410827024@qq.com> Date: Sat, 11 Feb 2023 18:25:54 +0800 Subject: [PATCH] fix: eslint rules --- .eslintrc.json | 13 +++++++++++-- app/layout.tsx | 2 +- app/page.tsx | 10 ++-------- components/Buttons.tsx | 8 +++----- components/Dark.tsx | 14 +++++++------- next.config.js | 6 ++++++ package.json | 2 +- pages/_app.tsx | 6 ++---- 8 files changed, 33 insertions(+), 28 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3be4086..03b99fd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,7 +15,6 @@ "plugin:jest-dom/recommended", "plugin:testing-library/react" ], - "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaFeatures": { "jsx": true @@ -47,6 +46,16 @@ "no-undef": "off", "react/react-in-jsx-scope": "off", "react/prop-types": "off", - "react/jsx-props-no-spreading": "off" + "react/jsx-props-no-spreading": "off", + "react/jsx-filename-extension": [ + 1, + { + "extensions": [ + ".tsx", + ".js", + ".jsx" + ] + } + ] } } \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index 6b6e9ea..d0775f5 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,7 +6,7 @@ export default function RootLayout({ children: React.ReactNode; }) { return ( - + {children} diff --git a/app/page.tsx b/app/page.tsx index 41f5098..8e84885 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,15 +1,9 @@ -import { ThemeProvider } from 'next-themes'; - function Index() { return ( -
- - -
- 222 -
); } diff --git a/components/Buttons.tsx b/components/Buttons.tsx index 7b84268..46023c8 100644 --- a/components/Buttons.tsx +++ b/components/Buttons.tsx @@ -1,7 +1,5 @@ import React from 'react'; -const Buttons = () => { - return ; -}; - -export default Buttons; +export default function Buttons() { + return ; +} diff --git a/components/Dark.tsx b/components/Dark.tsx index 3bd5451..ad83963 100644 --- a/components/Dark.tsx +++ b/components/Dark.tsx @@ -1,16 +1,16 @@ // pages/index.tsx -import { useTheme } from "next-themes"; - +import { useTheme } from 'next-themes'; export default function IndexPage() { const { theme, setTheme } = useTheme(); - const toggleTheme = () => - setTheme(theme === "light" ? "dark" : "light"); + const toggleTheme = () => setTheme(theme === 'light' ? 'dark' : 'light'); return (
-

The current theme is {theme === "dark" ? "dark" : "light"}

- +

The current theme is {theme === 'dark' ? 'dark' : 'light'}

+
); -} \ No newline at end of file +} diff --git a/next.config.js b/next.config.js index e5957bb..637ea9f 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,11 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + env: { + customKey: 'my-value', + }, + eslint: { + ignoreDuringBuilds: true, + }, reactStrictMode: true, experimental: { appDir: true, diff --git a/package.json b/package.json index d477c61..b386040 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ }, "dependencies": { "next": "13.0.2", + "next-themes": "0.2.0", "react": "18.2.0", "react-dom": "18.2.0" }, @@ -55,7 +56,6 @@ "jest": "^29.3.1", "jest-environment-jsdom": "^29.3.1", "lint-staged": "^13.0.3", - "next-themes": "0.2.0", "postcss": "^8.4.18", "prettier": "^2.7.1", "prettier-plugin-tailwindcss": "^0.1.8", diff --git a/pages/_app.tsx b/pages/_app.tsx index e2b693f..adc2702 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,12 +1,10 @@ -import type { AppProps } from "next/app"; +import type { AppProps } from 'next/app'; import { ThemeProvider } from 'next-themes'; -function MyApp({ Component, pageProps }) { +export default function MyApp({ Component, pageProps }) { return ( ; ); } - -export default MyApp;