Skip to content

project: './tsconfig.json' in config for .svelte files #954

Open
@malininss

Description

@malininss

I have a big Svelte project with a lot of heavy ESLint rules. This is my original .eslintrc.cjs config:

module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:svelte/recommended',
  ],
  plugins: ['@typescript-eslint'],
  parserOptions: {
    ecmaVersion: 2022,
    sourceType: 'module',
    project: './tsconfig.json',
    extraFileExtensions: ['.svelte'],
  },
  overrides: [
    {
      files: ['*.svelte'],
      parser: 'svelte-eslint-parser',
      parserOptions: {
        parser: '@typescript-eslint/parser',
      },
    },
  ],
  rules: {
    ...complex rules
  },
}

With this setup, linting the whole project takes a LONG time (about 4 minutes on a MacBook Pro M2).
I checked the latest Svelte demo project and saw this ESLint config:

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  ...svelte.configs['flat/recommended'],
  prettier,
  ...svelte.configs['flat/prettier'],
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
      },
    },
  },
  {
    files: ['**/*.svelte'],
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser,
      },
    },
  },
  {
    ignores: ['build/', '.svelte-kit/', 'dist/'],
  }
);

I noticed that it doesn’t include project: './tsconfig.json'. I removed project: './tsconfig.json' from my config for .svelte files (but kept it for .ts files), and now linting only takes 50 seconds.

And everything still works in .svelte files — all the rules and checks are applied, as if it still knows about tsconfig.json.

My Questions:

  • Why does ESLint still work in .svelte files without project: './tsconfig.json'?
  • Did I do the right thing by removing it? If yes, should the documentation mention this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions