11// eslint.config.js
22import js from '@eslint/js' ;
33import globals from 'globals' ;
4- import react from 'eslint-plugin-react' ; // For general React rules
5- import reactHooks from 'eslint-plugin-react-hooks' ;
6- import reactRefresh from 'eslint-plugin-react-refresh' ;
74import tseslint from 'typescript-eslint' ;
85import prettierConfig from 'eslint-config-prettier' ;
96import { defineConfig } from 'eslint/config' ;
@@ -94,59 +91,4 @@ export default defineConfig([
9491 } ,
9592 } ,
9693
97- // --- 4. Configuration for Webview UI (React/TypeScript) ---
98- {
99- files : [ 'webview-ui/src/**/*.{ts,tsx}' ] , // Only apply to your React webview files
100- // Specific language options for the React part of the project
101- languageOptions : {
102- ecmaVersion : 2020 , // Or 2021/2022 if your target environment supports it
103- sourceType : 'module' ,
104- // Define global variables for the browser environment
105- globals : {
106- ...globals . browser ,
107- } ,
108- // Specify the TypeScript parser for these files
109- parser : tseslint . parser ,
110- // Configuration for the TypeScript parser, including JSX support
111- parserOptions : {
112- // project: ['./webview-ui/tsconfig.json'], // Path to your webview's tsconfig.json
113- tsconfigRootDir : import . meta. dirname ,
114- ecmaFeatures : {
115- jsx : true , // Enable JSX parsing
116- } ,
117- } ,
118- } ,
119- // Define plugins specific to the React environment
120- plugins : {
121- react, // General React rules
122- 'react-hooks' : reactHooks , // Rules for React Hooks
123- 'react-refresh' : reactRefresh , // Rules for React Fast Refresh
124- } ,
125- // Specific rules for your React/TypeScript files
126- rules : {
127- // General React rules (e.g., props validation, accessibility)
128- ...react . configs . recommended . rules ,
129- ...react . configs [ 'jsx-runtime' ] . rules , // Use this for React 17+ with new JSX transform
130-
131- // React Hooks specific rules
132- ...reactHooks . configs . recommended . rules ,
133-
134- // React Refresh specific rule
135- 'react-refresh/only-export-components' : [
136- 'warn' ,
137- { allowConstantExport : true } ,
138- ] ,
139-
140- // Override or add other React/TypeScript specific rules
141- 'react/prop-types' : 'off' , // Often not needed with TypeScript
142- 'react/react-in-jsx-scope' : 'off' , // Not needed for React 17+ with new JSX transform
143- '@typescript-eslint/explicit-function-return-type' : 'off' , // Often too verbose in React components
144- 'semi' : 'off' , // Let Prettier handle semicolons
145- } ,
146- settings : {
147- react : {
148- version : 'detect' , // Automatically detect the React version
149- } ,
150- } ,
151- } ,
15294] ) ;
0 commit comments