Skip to content

Bug: flat configuration block options are not independent #6778

Closed as not planned
@JP-Ellis

Description

@JP-Ellis

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

First and foremost, this bug relates to the new ESLint flat configuration. I understand that this feature is still in beta and is now in Phase 3 which is to ensure compability with existing plugins. I suspect the error is with the TypeScript parser and not with ESLint.

Expected Behaviour

I should be able to configure options for the TypeScript parser independently when it is used within the TypeScript section of the config, and the Svelte section of the configuration.

Actual Behaviour

The setting of languageOptions in the block of the ESLint config targetting **/*.ts files has side-effects, impacting the use of the TypeScript parser in the Svelte section targettin **/*.svelte files.

In the example repo (below), the ESLint config contains the following segment:

https://github.com/JP-Ellis/eslint-plugin-svelte-mwe/blob/f09107de3dcb59704a4e6d416b26eaa720f25c10/eslint.config.js#L20-L36

I note the following behaviours:

  • When it is commented out, the *.svelte files are parsed and linted correctly. The TypeScript files are not linted, which is expected as non of the configuration blocks in ESLint match *.ts files
  • When the TypeScript configuration block is uncommented, the *.ts files are correctly linted; however, the *.svelte files produce the following error relating to tsconfig.ts:
      0:0  error  Parsing error: ESLint was configured to run on 
    `<tsconfigRootDir>/src/routes/+page.svelte` using `parserOptions.project`: 
    <tsconfigRootDir>/tsconfig.json
    However, that TSConfig does not include this file. Either:
    - Change ESLint's list of included files to not include this file
    - Change that TSConfig to include this file
    - Create a new TSConfig that includes this file and include it in your parserOptions.project
    See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
    
  • Adding extraFileExtensions: [".svelte"] to the languageOptions in the TypeScript block (and having it uncommented) resolves the above issue.

My expectation is that the settings passed in the TypeScript config block should be independent of the settings passed in the Svelte block.

Reproduction Repository Link

https://github.com/JP-Ellis/eslint-plugin-svelte-mwe

Repro Steps

  1. clone the repo
  2. pnpm install
  3. pnpm lint (this should work fine)
  4. Uncomment the TypeScript configuration in eslint.config.js
  5. pnpm lint (this should produce errors)
  6. Add extraFileExtensions: [".svelte"] to the languageOptions in the TypeScript block.
  7. pnpm lint (this should have fixed the previous issue)

Versions

package version
@typescript-eslint/eslint-plugin 5.56.0
@typescript-eslint/parser 5.56.0
TypeScript 5.0.2
ESLint 8.36.0
node 19.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions