Skip to content

Bug: base config should have TS files. #11291

@kirkwaiblinger

Description

@kirkwaiblinger

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

I expect the following config to work for linting TS files, but, instead, eslint issues an error ("File ignored because no matching configuration was supplied") when linting a TS file. This is due to the fact that eslint requires a file to be included in at least one config object's files field in order to be linted.

import tseslint from 'typescript-eslint';

export default tseslint.config(
    tseslint.configs.base,
    {
        rules: {
            '@typescript-eslint/no-unused-vars': 'error',
        }
    }
);

Right now, the description for the base config (link) says

A minimal ruleset that sets only the required parser and plugin options needed to run typescript-eslint.

Technically, that's true, but it doesn't set all the options required to run typescript-eslint on TS files. Surprisingly, this is only done in the rest of our configs by virtue of the fact that they include the eslint-recommended config, which has files set primarily in order to disable eslint core rules.

To see this, note that the following errors on TS files:

export default tseslint.config(
    (() => {
        const recommendedCopy = [...tseslint.configs.recommended];
        recommendedCopy.splice(1, 1); // remove the eslint-recommended config
        return recommendedCopy;
    })(),
);

I propose - let's add files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'] to the base config so that it enables linting on TS files.

Reproduction Repository Link

https://github.com/kirkwaiblinger/tseslint-base-files-repro/

Repro Steps

  1. clone the repo
  2. npm i
  3. npm test

Versions

all version of eslint 9 and typescript-eslint 8 that I tried

Specifically, repros on latest:

    "eslint": "9.28.0",
    "typescript-eslint": "8.34.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginpackage: typescript-eslintIssues related to the typescript-eslint packagepreset config changeProposal for an addition, removal, or general change to a preset configtriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy