import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{ ignores: ['dist/**', 'node_modules/**', 'src/server/resources/gradio-widget-content.ts'] },
// Server-side TypeScript files - use strict config
{
files: ['src/server/**/*.ts', 'src/shared/**/*.ts'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: globals.node,
},
rules: {
// Strict TypeScript rules (syntax-based only)
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
// Relaxed rules for certain patterns
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
// General ESLint rules
'no-constant-condition': 'off',
},
},
// Client-side React/TypeScript files
{
files: ['src/web/**/*.{ts,tsx}'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
// Relaxed TypeScript rules for React components
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/consistent-type-imports': 'error',
},
},
// Vite config files
{
files: ['vite.config.ts'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
languageOptions: {
globals: globals.node,
},
}
);