Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
malininss opened this issue Dec 13, 2024 · 0 comments
Open

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

malininss opened this issue Dec 13, 2024 · 0 comments

Comments

@malininss
Copy link

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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant