hi i have a react project i create it with vite and i before remove eslint from it for…
- User
hi i have a react project i create it with vite and i before remove eslint from it for typescript but now i want to return back those type safety settings, i install eslint again but know i want when i declare a variable like this
const x; // or const x: any;its give me error during build and development so this is my tsconfig.json file:
{ "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ] }this is my tsconfig.app.json file:
{ "compilerOptions": { "composite": true, "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "noImplicitThis": true, "noImplicitAny": true, "baseUrl": ".", "paths": { "@src/*": ["src/*"], "@assets": ["src/assets"], "@common": ["src/common"], "@components": ["src/components"], "@constants": ["src/constants"], "@context": ["src/context"], "@hooks": ["src/hooks"], "@imports": ["src/imports"], "@layout": ["src/layout"], "@pages": ["src/pages"], "@services": ["src/services"], "@styles": ["src/styles"], "@theme": ["src/theme"], "@utils": ["src/utils"], "@public": ["public"] }, "allowJs": true }, "include": ["src/**/*", "public/**/*"], "exclude": ["node_modules"] }this is my tsconfig.node.json file:
{ "compilerOptions": { "composite": true, "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", "skipLibCheck": true, "module": "ESNext", "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "strict": true, "noEmit": true }, "include": ["vite.config.ts"] }this is my eslint.config file:
import globals from "globals"; import pluginJs from "@eslint/js"; import tseslint from "@typescript-eslint/eslint-plugin"; // Corrected import import pluginReact from "eslint-plugin-react"; /** @type {import('eslint').Linter.Config[]} */ export default [ { files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"], languageOptions: { globals: { ...globals.browser, // Spread the globals without leading/trailing whitespace }, parser: "@typescript-eslint/parser", // Specify the TypeScript parser parserOptions: { ecmaVersion: 2020, sourceType: "module", }, }, rules: { "@typescript-eslint/no-explicit-any": "error", // Disallow the use of 'any' // Add other rules as needed }, }, pluginJs.configs.recommended, tseslint.configs.recommended, // Use this directly instead of spreading pluginReact.configs.recommended, // Use the correct recommended config ]; - Assistant
- User
Invalid option '--ext' - perhaps you meant '-c'? You're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.
- Assistant
- User
PS D:\New folder (2)\admin-control-panel> npm run lint
admin-control-panel@0.0.0 lint eslint . --fix
Oops! Something went wrong! :(
ESLint: 8.57.1
ConfigError: Config (unnamed): Key "languageOptions": Key "globals": Global "AudioWorkletGlobalScope " has leading or trailing whitespace. at rethrowConfigError (D:\New folder (2)\admin-control-panel\node_modules@humanwhocodes\config-array\api.js:230:8) at D:\New folder (2)\admin-control-panel\node_modules@humanwhocodes\config-array\api.js:1032:5 at Array.reduce () at FlatConfigArray.getConfig (D:\New folder (2)\admin-control-panel\node_modules@humanwhocodes\config-array\api.js:1028:39) at FlatConfigArray.isFileIgnored (D:\New folder (2)\admin-control-panel\node_modules@humanwhocodes\config-array\api.js:1060:15) at D:\New folder (2)\admin-control-panel\node_modules\eslint\lib\eslint\eslint-helpers.js:336:57 at Array.reduce () at D:\New folder (2)\admin-control-panel\node_modules\eslint\lib\eslint\eslint-helpers.js:323:36 at D:\New folder (2)\admin-control-panel\node_modules\eslint\lib\eslint\eslint-helpers.js:286:32 at Object.isAppliedFilter (D:\New folder (2)\admin-control-panel\node_modules@nodelib\fs.walk\out\readers\common.js:12:31)
- Assistant