From d7314598a5ce9623130daf9b4a76abd37b0f0f6e Mon Sep 17 00:00:00 2001 From: saddam-satria Date: Wed, 17 Jan 2024 18:25:13 +0700 Subject: [PATCH] fix eslint rule --- .eslintrc.js | 5 +++++ src/commons/constant.ts | 2 +- src/commons/routes.tsx | 16 +++++++-------- src/components/hello.tsx | 36 +++++++++++++++------------------ src/index.tsx | 6 ++---- src/pages/Homepage.tsx | 14 ++++++------- src/pkg/axios.ts | 6 +++--- src/redux/reducers/example.ts | 38 +++++++++++++++++------------------ src/redux/store.ts | 13 ++++++------ 9 files changed, 66 insertions(+), 70 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ff43a47..7d41f61 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -73,6 +73,11 @@ module.exports = { 'no-underscore-dangle': 'off', 'default-param-last': 'off', radix: 'off', + "import/extensions" :"off", + "import/no-unresolved": "off", + "react/react-in-jsx-scope": "off", + "no-param-reassign": "off", + "react-hooks/exhaustive-deps": "warn" }, settings: { react: { diff --git a/src/commons/constant.ts b/src/commons/constant.ts index e101ae6..93d1222 100644 --- a/src/commons/constant.ts +++ b/src/commons/constant.ts @@ -1 +1 @@ -export const API_URL : string = process.env.API_URL || "http://localhost:5000" \ No newline at end of file +export const API_URL: string = process.env.API_URL || "http://localhost:5000"; diff --git a/src/commons/routes.tsx b/src/commons/routes.tsx index 11923b3..8c24868 100644 --- a/src/commons/routes.tsx +++ b/src/commons/routes.tsx @@ -1,13 +1,13 @@ -import { createBrowserRouter } from "react-router-dom" -import Homepage from "../pages/Homepage" +import { createBrowserRouter } from "react-router-dom"; +import Homepage from "../pages/Homepage"; const routes = [ { - path: "/", - element: , - }, -] + path: "/", + element: , + }, +]; -const routeBrowser = createBrowserRouter(routes) +const routeBrowser = createBrowserRouter(routes); -export default routeBrowser \ No newline at end of file +export default routeBrowser; diff --git a/src/components/hello.tsx b/src/components/hello.tsx index dc15da3..ff5c84c 100644 --- a/src/components/hello.tsx +++ b/src/components/hello.tsx @@ -1,23 +1,19 @@ -import { useDispatch, useSelector } from "react-redux" -import { exampleAction, exampleState } from "../redux/reducers/example" -import { useEffect } from "react" +import { useEffect } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { exampleAction, exampleState } from "../redux/reducers/example"; -const Hello =() =>{ - const helloState = useSelector(exampleState) - const dispatch = useDispatch() - useEffect(() => { +const Hello = () => { + const helloState = useSelector(exampleState); + const dispatch = useDispatch(); + useEffect(() => { + dispatch(exampleAction.setName({ name: "React Boilerplate TS By Saddam" })); + }, []); - dispatch(exampleAction.setName({name:"React Boilerplate TS By Saddam"})) + return ( +
+

{helloState.name}

+
+ ); +}; - },[]) - - return( -
-

- {helloState.name} -

-
- ) -} - -export default Hello \ No newline at end of file +export default Hello; diff --git a/src/index.tsx b/src/index.tsx index 9c5e524..522d80e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,17 +1,15 @@ import React from "react"; import ReactDOM from "react-dom/client"; import "./index.css"; +import { Provider } from "react-redux"; import { RouterProvider } from "react-router-dom"; import routes from "./commons/routes"; -import { Provider } from "react-redux"; import store from "./redux/store"; ReactDOM.createRoot(document.getElementById("root")!).render( - - + - , ); diff --git a/src/pages/Homepage.tsx b/src/pages/Homepage.tsx index d9c7eba..9a12ec0 100644 --- a/src/pages/Homepage.tsx +++ b/src/pages/Homepage.tsx @@ -1,11 +1,9 @@ -import Hello from "../components/hello" +import Hello from "../components/hello"; const Homepage = () => { - return ( - <> - - - ) -} + return ( + + ); +}; -export default Homepage \ No newline at end of file +export default Homepage; diff --git a/src/pkg/axios.ts b/src/pkg/axios.ts index f3fc989..4b98c2f 100644 --- a/src/pkg/axios.ts +++ b/src/pkg/axios.ts @@ -1,6 +1,6 @@ -import axios from 'axios'; -import { API_URL } from '../commons/constant'; +import axios from "axios"; +import { API_URL } from "../commons/constant"; export default axios.create({ baseURL: API_URL, -}); \ No newline at end of file +}); diff --git a/src/redux/reducers/example.ts b/src/redux/reducers/example.ts index cdd98cc..24781ae 100644 --- a/src/redux/reducers/example.ts +++ b/src/redux/reducers/example.ts @@ -1,27 +1,27 @@ -import { PayloadAction, createSlice } from "@reduxjs/toolkit" -import store from "../store" +import { PayloadAction, createSlice } from "@reduxjs/toolkit"; +import store from "../store"; -interface IExample{ - name: string +interface IExample { + name: string; } -const initialExample : IExample = { - name: "" -} +const initialExample: IExample = { + name: "", +}; const exampleSlicer = createSlice({ - name: "example", - initialState: initialExample, - reducers:{ - setName: (state: IExample, action : PayloadAction)=>{ - state.name = action.payload.name - } - } -}) + name: "example", + initialState: initialExample, + reducers: { + setName: (state: IExample, action: PayloadAction) => { + state.name = action.payload.name; + }, + }, +}); -const exampleReducer = exampleSlicer.reducer -export const exampleAction = exampleSlicer.actions +const exampleReducer = exampleSlicer.reducer; +export const exampleAction = exampleSlicer.actions; -export const exampleState = (state: store) => state.posts +export const exampleState = (state: store) => state.posts; -export default exampleReducer \ No newline at end of file +export default exampleReducer; diff --git a/src/redux/store.ts b/src/redux/store.ts index 7824a2c..38d7132 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -1,14 +1,13 @@ -import { configureStore } from '@reduxjs/toolkit' -import exampleReducer from './reducers/example' +import { configureStore } from "@reduxjs/toolkit"; +import exampleReducer from "./reducers/example"; export const store = configureStore({ reducer: { posts: exampleReducer, }, -}) +}); -export type store = ReturnType -export type AppDispatch = typeof store.dispatch +export type store = ReturnType; +export type AppDispatch = typeof store.dispatch; - -export default store \ No newline at end of file +export default store;