feat: setup eslint with typescript and react rules, add unused imports plugin

This commit is contained in:
Haileyesus
2026-03-05 17:04:51 +03:00
parent 7802eb0cac
commit 525c9f72ca
3 changed files with 1318 additions and 3 deletions

50
eslint.config.js Normal file
View File

@@ -0,0 +1,50 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import reactHooks from "eslint-plugin-react-hooks";
import unusedImports from "eslint-plugin-unused-imports";
import globals from "globals";
export default tseslint.config(
{
ignores: ["dist/**", "node_modules/**", "public/**"],
},
{
files: ["src/**/*.{ts,tsx,js,jsx}"],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
plugins: {
"react-hooks": reactHooks,
"unused-imports": unusedImports,
},
languageOptions: {
globals: {
...globals.browser,
},
},
rules: {
// Remove unused imports automatically
"unused-imports/no-unused-imports": "warn",
// Flag unused variables (ignoring those prefixed with _)
"unused-imports/no-unused-vars": [
"warn",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
// Disable the base rules so they don't conflict
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
// Disable rules the user didn't ask for
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": "off",
"no-case-declarations": "off",
"no-control-regex": "off",
"no-useless-escape": "off",
},
}
);

1263
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -30,6 +30,8 @@
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"typecheck": "tsc --noEmit -p tsconfig.json", "typecheck": "tsc --noEmit -p tsconfig.json",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix",
"start": "npm run build && npm run server", "start": "npm run build && npm run server",
"release": "./release.sh", "release": "./release.sh",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build",
@@ -103,6 +105,7 @@
"ws": "^8.14.2" "ws": "^8.14.2"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.3",
"@release-it/conventional-changelog": "^10.0.5", "@release-it/conventional-changelog": "^10.0.5",
"@types/node": "^22.19.7", "@types/node": "^22.19.7",
"@types/react": "^18.2.43", "@types/react": "^18.2.43",
@@ -111,12 +114,17 @@
"auto-changelog": "^2.5.0", "auto-changelog": "^2.5.0",
"autoprefixer": "^10.4.16", "autoprefixer": "^10.4.16",
"concurrently": "^8.2.2", "concurrently": "^8.2.2",
"eslint": "^9.39.3",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-unused-imports": "^4.4.1",
"globals": "^17.4.0",
"node-gyp": "^10.0.0", "node-gyp": "^10.0.0",
"postcss": "^8.4.32", "postcss": "^8.4.32",
"release-it": "^19.0.5", "release-it": "^19.0.5",
"sharp": "^0.34.2", "sharp": "^0.34.2",
"tailwindcss": "^3.4.0", "tailwindcss": "^3.4.0",
"typescript": "^5.9.3", "typescript": "^5.9.3",
"typescript-eslint": "^8.56.1",
"vite": "^7.0.4" "vite": "^7.0.4"
} }
} }