Skip to content

extends + files causes rules to be dropped #395

@kevva

Description

@kevva

Since v1.39.0 (PR #323), configs with nested array file patterns (AND globs) are skipped by processConfigFiles. While this fixed the invalid config output from #322, it silently drops all rules from any ESLint config that uses extends inside a config object with files because ESLint's defineConfig turns that combination into AND-pattern nested arrays.

This is a very common pattern in ESLint flat configs:

import { defineConfig } from 'eslint/config'
import tseslint from 'typescript-eslint'
import react from 'eslint-plugin-react'

export default defineConfig([
  // Rules from tseslint are silently dropped by migrate
  { files: ['**/*.ts'], extends: [tseslint.configs.recommended] },
  // Rules from react are silently dropped by migrate
  { files: ['**/*.{jsx,tsx}'], extends: [react.configs.flat.recommended] },
])

ESLint's defineConfig resolves extends by creating AND-pattern file arrays (e.g., [["**/*.ts", "**/*.{js,ts}"]]). processConfigFiles filters these out, returning an empty array, and buildConfig then skips the entire config via if (validFiles.length === 0) continue.

Reproduction:

// eslint.config.js
import { defineConfig } from 'eslint/config'
import tseslint from 'typescript-eslint'

export default defineConfig([
  {
    files: ['**/*.ts'],
    extends: [tseslint.configs.recommended],
    rules: { '@typescript-eslint/no-explicit-any': 'error' },
  },
])

Run npx @oxlint/migrate --type-aware eslint.config.js and you'll see that the typescript-eslint rules will be missing from the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions