ESLint 9 Flat Config Migration Rehberi: Tüm Hataların Çözümü (2026)

15.01.2026 20:48 Haber

ESLint 9'a geçiş yaparken "extends" key not supported veya "plugins array format" hatası mı alıyorsunuz? Alesta Web olarak ESLint 9 flat config migration sürecinde karşılaşılan tüm hataları ve çözümlerini bu kapsamlı rehberde topladık. eslintrc formatından flat config'e geçiş artık çok kolay!

Flat Config Nedir? (What is Flat Config?)

Alesta Web ekibi olarak ESLint 9'un en büyük değişikliğini açıklayalım: Flat Config!

ESLint 9.0.0 ile birlikte eski .eslintrc.js formatı deprecated (kullanımdan kaldırıldı) oldu. Yerine eslint.config.js adlı yeni flat config formatı geldi.

Eski Format vs Yeni Format

Eski Format (.eslintrc.js) - ESLint 8 ve öncesi

// .eslintrc.js (DEPRECATED!)
module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
  ],
  plugins: ['react', 'import'],
  rules: {
    'no-unused-vars': 'warn',
  },
}

Yeni Format (eslint.config.js) - ESLint 9+

// eslint.config.js (NEW!)
import js from '@eslint/js'
import react from 'eslint-plugin-react'

export default [
  js.configs.recommended,
  {
    files: ['**/*.{js,jsx}'],
    plugins: {
      react: react,
    },
    languageOptions: {
      ecmaVersion: 2024,
      sourceType: 'module',
      globals: {
        window: 'readonly',
        document: 'readonly',
      },
    },
    rules: {
      'no-unused-vars': 'warn',
    },
  },
]
? Bilgi / Info:

Flat config'in en büyük avantajı: daha explicit (açık), daha predictable (öngörülebilir) ve cascade inheritance sorunlarından arınmış olması. Alesta Web olarak yeni projelerde flat config kullanmanızı öneriyoruz.

Yaygın Migration Hataları (Common Migration Errors)

ESLint 9'a geçerken Alesta Web ekibi olarak en sık karşılaştığımız hatalar:

Hata / Error Nedeni / Cause
extends key not supported Flat config'de extends kullanılamaz
plugins array format Plugins artık object olmalı, array değil
context.getScope is not a function Plugin ESLint 9 ile uyumsuz
Class extends value undefined typescript-eslint paketleri eski
env is not supported env yerine globals kullanılmalı

extends Key Hatası Çözümü (Fix extends Error)

En yaygın hata: "A config object is using the 'extends' key, which is not supported in flat config system."

Hata Mesajı / Error Message

ESLintError: A config object is using the "extends" key,
which is not supported in flat config system.

Instead of "extends", you can include config objects that
you'd like to extend from directly in the flat config array.

Çözüm 1: Config'leri Direkt Import Et

Doğru Kullanım (Correct Usage)

// eslint.config.js
import js from '@eslint/js'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'

export default [
  // extends yerine direkt config array'e ekle
  js.configs.recommended,

  // React plugin config
  {
    files: ['**/*.{js,jsx,ts,tsx}'],
    plugins: {
      react: reactPlugin,
      'react-hooks': reactHooksPlugin,
    },
    rules: {
      ...reactPlugin.configs.recommended.rules,
      'react-hooks/rules-of-hooks': 'error',
      'react-hooks/exhaustive-deps': 'warn',
    },
    settings: {
      react: {
        version: 'detect',
      },
    },
  },
]

Çözüm 2: defineConfig() Kullan (ESLint 9.5+)

ESLint 9.5'ten itibaren defineConfig() fonksiyonu ile extends tekrar kullanılabilir!

defineConfig ile extends (ESLint 9.5+)

// eslint.config.js
import { defineConfig } from 'eslint/config'
import js from '@eslint/js'
import react from 'eslint-plugin-react'

export default defineConfig([
  {
    // defineConfig içinde extends kullanılabilir!
    extends: [js.configs.recommended],
    files: ['**/*.{js,jsx}'],
    plugins: {
      react,
    },
    rules: {
      'no-unused-vars': 'warn',
    },
  },
])
✅ Alesta Web İpucu / Tip:

defineConfig() fonksiyonu ESLint 9.5+ ile geldi. Eski projelerde extends kullanmak istiyorsanız ESLint'i en son sürüme güncelleyin.

Plugins Array Format Hatası (Plugins Format Error)

İkinci en yaygın hata: "Key 'plugins': This appears to be in eslintrc format (array of strings) rather than flat config format (object)."

Hatalı Kullanım / Wrong Usage

// ❌ YANLIŞ - eslintrc formatı
export default [
  {
    plugins: ['react', 'import'],  // Array of strings = HATA!
    rules: { ... }
  }
]

Doğru Kullanım / Correct Usage

// ✅ DOĞRU - flat config formatı
import react from 'eslint-plugin-react'
import importPlugin from 'eslint-plugin-import'

export default [
  {
    plugins: {
      react: react,           // Object format
      import: importPlugin,   // Key: plugin instance
    },
    rules: {
      'react/jsx-uses-react': 'error',
      'import/no-unresolved': 'error',
    }
  }
]
⚠️ Dikkat / Warning:

Flat config'de plugin'ler import edilmeli ve object olarak tanımlanmalı. String array formatı artık çalışmıyor!

TypeScript Uyumluluk Sorunları (TypeScript Compatibility)

TypeScript projelerinde "TypeError: Class extends value undefined is not a constructor or null" hatası alabilirsiniz.

Çözüm: typescript-eslint Güncelle

# Eski paketleri kaldır
npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser

# Yeni birleşik paketi yükle
npm install typescript-eslint --save-dev

TypeScript için Flat Config

// eslint.config.js
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  {
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
      parserOptions: {
        project: './tsconfig.json',
      },
    },
    rules: {
      '@typescript-eslint/no-unused-vars': 'warn',
      '@typescript-eslint/explicit-function-return-type': 'off',
    },
  },
)
? Alesta Web Notu / Note:

typescript-eslint paketi v7+ sürümünden itibaren ESLint 9 ile tam uyumlu. Eski @typescript-eslint/ paketleri yerine yeni birleşik paketi kullanın.

Next.js Projelerde ESLint 9 Yapılandırması

Next.js projelerinde ESLint 9 flat config kullanmak için özel yapılandırma gerekiyor. Alesta Web olarak çalışan bir örnek paylaşıyoruz:

Next.js + ESLint 9 Flat Config

// eslint.config.mjs
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended,
})

export default [
  ...compat.extends('next/core-web-vitals'),
  {
    files: ['**/*.{js,jsx,ts,tsx}'],
    rules: {
      'react/no-unescaped-entities': 'off',
      '@next/next/no-img-element': 'warn',
    },
  },
  {
    ignores: ['.next/*', 'node_modules/*'],
  },
]

Gerekli Paketler / Required Packages

npm install eslint@9 @eslint/eslintrc @eslint/js eslint-config-next --save-dev
⚠️ Next.js Uyarısı / Next.js Warning:

Next.js 15+ sürümlerinde next lint komutu deprecation warning verebilir. eslint . komutunu direkt kullanmanızı öneriyoruz.

Otomatik Migration Tool (ESLint Configuration Migrator)

ESLint ekibi, eski config'leri otomatik olarak flat config'e çeviren bir tool sağlıyor:

Migration Tool Kullanımı

# Otomatik migration çalıştır
npx @eslint/migrate-config .eslintrc.json

# Veya .eslintrc.js için
npx @eslint/migrate-config .eslintrc.js

# Çıktı: eslint.config.mjs dosyası oluşturulur

Geçici Workaround (Acil Durumlar İçin)

# Eğer hala eslintrc formatı kullanmanız gerekiyorsa
# (önerilmez, sadece geçici çözüm!)

# Environment variable ile eski format aktif et
ESLINT_USE_FLAT_CONFIG=false npx eslint .

# package.json'da script olarak
{
  "scripts": {
    "lint": "ESLINT_USE_FLAT_CONFIG=false eslint ."
  }
}
✅ Migration Checklist:
  • npx @eslint/migrate-config çalıştırıldı
  • ☐ eslint.config.js oluşturuldu
  • ☐ Eski .eslintrc.* dosyaları silindi
  • ☐ .eslintignore → ignores array'e taşındı
  • ☐ Plugin'ler import edildi ve object formatına çevrildi
  • ☐ env → globals'a dönüştürüldü
  • npm run lint başarılı

? Kaynaklar ve Referanslar / Sources and References

Alesta Web olarak tüm çözümleri test ettik ve production projelerinde kullandık.

✅ ESLint 9 Migration Tamamlandı! (Migration Complete!)

ESLint 9 flat config migration artık tamamlandı! Alesta Web olarak en yaygın hataları ve çözümlerini bu rehberde topladık.

Hızlı Özet / Quick Summary:

  • ✅ Flat config = yeni standart (eslint.config.js)
  • ✅ extends → direkt import veya defineConfig() kullan
  • ✅ plugins: array → object formatına çevir
  • ✅ env → globals'a dönüştür
  • ✅ typescript-eslint paketini güncelle
  • ✅ Migration tool: npx @eslint/migrate-config

Faydalı Linkler / Useful Links:

© 2026 AlestaWeb - Tüm hakları saklıdır. | alestaweb.com

WM Tools
💫

WebMaster Tools

15 Profesyonel Araç