From 1e9bab5d079c7b76b5ea107783a47040b7f7fb89 Mon Sep 17 00:00:00 2001 From: tuanOts Date: Sun, 25 May 2025 02:15:41 +0700 Subject: [PATCH] Fix ESLint configuration and parsing errors - Fix .eslintrc.json format (remove comments and invalid JSON syntax) - Simplify environment.jsx to fix parsing error - Add proper ESLint rules for React project - Enable react-hooks plugin and configure settings --- .eslintrc.json | 65 +++++++++++++++------------------------------ src/environment.jsx | 3 +-- 2 files changed, 22 insertions(+), 46 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 7ba10e0..e9d276b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,52 +1,29 @@ -// module.exports = { -// "env": { -// "browser": true, -// "es2021": true, -// "jest": true -// }, -// "extends": [ -// "eslint:recommended", -// "plugin:react/recommended" -// ], -// "overrides": [ -// { -// "env": { -// "node": true -// }, -// "files": [ -// ".eslintrc.{js,cjs,jsx}" -// ], -// "parserOptions": { -// "sourceType": "script" -// } -// } -// ], -// "parserOptions": { -// "ecmaVersion": "latest", -// "sourceType": "module" -// }, -// "plugins": [ -// "react" -// ], -// "rules": { -// "react/react-in-jsx-scope": "off" -// } -// } { "env": { - "browser": true, - "es2021": true + "browser": true, + "es2021": true, + "jest": true }, - "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"], + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended" + ], "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module", - "ecmaFeatures": { - "jsx": true - } + "ecmaVersion": 12, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } }, - // "plugins": ["react", "react-hooks"], + "plugins": ["react", "react-hooks"], "rules": { - //add customize rules here as per your project's needs + "react/react-in-jsx-scope": "off", + "react/prop-types": "off" + }, + "settings": { + "react": { + "version": "detect" + } } } \ No newline at end of file diff --git a/src/environment.jsx b/src/environment.jsx index 89f76ce..ffb399d 100644 --- a/src/environment.jsx +++ b/src/environment.jsx @@ -1,6 +1,5 @@ // For development environment -const publicUrl = process.env.PUBLIC_URL || "/"; -export const base_path = publicUrl.endsWith('/') ? publicUrl : publicUrl + '/'; +export const base_path = process.env.PUBLIC_URL || "/"; // For production with a subdirectory (uncomment and modify as needed) // export const base_path = "/react/";