mizdra / eslint-interactive

The CLI tool to fix huge number of ESLint errors
MIT License
363 stars 9 forks source link

Fix `Config (unnamed): Key "language"` in ESLint@9.5.0+ #362

Closed mizdra closed 1 month ago

mizdra commented 1 month ago

close: #360

mizdra commented 1 month ago

It seems that language property has been added to the object returned by ESLint.prototype.calculateConfigForFile(filePath) since ESLint v9.5.0.

Example:

{
  linterOptions: { reportUnusedDisableDirectives: 'off' },
  language: {
    fileType: 'text',
    lineStart: 1,
    columnStart: 0,
    nodeTypeKey: 'type',
    visitorKeys: [Object],
    validateLanguageOptions: [Function: validateLanguageOptions],
    matchesSelectorClass: [Function: matchesSelectorClass],
    parse: [Function: parse],
    createSourceCode: [Function: createSourceCode]
  },
  languageOptions: {
    sourceType: 'module',
    ecmaVersion: 'latest',
    parser: [Object],
    parserOptions: {}
  },
  plugins: { '@': [Object], '@typescript-eslint': [Object] },
  rules: { '@typescript-eslint/no-explicit-any': [Array] },
  files: [ '**/*.*', '**/*' ]
}

The new ESLint supports the feature of adding languages via plugins, and the language property is supposed to be for that purpose.

mizdra commented 1 month ago

The config returned from ESLint.prototype.calculateConfigForFile(filePath) is passed to Linter.prototype.verify(text, config, filePath).

https://github.com/mizdra/eslint-interactive/blob/1a62bd2ec5401ab0cb9f1b58766415fafdb58739/src/eslint/linter.ts#L52-L53

However, Linter.prototype.verify does not seem to support language properties for some reason.