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

typescript-parser is not changed in flat config #95

Open
2 tasks done
appano1 opened this issue Mar 8, 2024 · 3 comments
Open
2 tasks done

typescript-parser is not changed in flat config #95

appano1 opened this issue Mar 8, 2024 · 3 comments

Comments

@appano1
Copy link
Contributor

appano1 commented Mar 8, 2024

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.

What version of ESLint are you using?

8.57.0

What version of typescript-eslint-parser-for-extra-files are you using?

  • typescript-eslint-parser-for-extra-files@0.6.0

What did you do?

Configuration
<!-- Paste your configuration here -->
import tsParser from "typescript-eslint-parser-for-extra-files";
import vueParser from "vue-eslint-parser";

[
  ...tseslint.configs.recommended,
  {
    languageOptions: {
      parser: tsParser,
    },
  },
  {
    files: ["**/*.vue"],
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        parser: tsParser,
      },
    },
  },
]

What did you expect to happen?

When I set the config with flat config with typescript-eslint, I expected that typescript eslint will uses typescript-eslint-parser-for-extra-files.

What actually happened?

But actually, it seems that tyepscript-eslint uses it's own parser. I don't know why the following configs don't override parser.

https://github.com/typescript-eslint/typescript-eslint/blob/6e29721d699f8c62e23f39b9f07cf928108adfac/packages/typescript-eslint/src/index.ts#L31-L45

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/appano1/parser-in-flat-config

Additional comments

I think some limitations need to be added in README.md or creating a configuration builder need to be added

@appano1
Copy link
Contributor Author

appano1 commented Mar 11, 2024

Oh sorry my link was wrong. I've edited the link now.

@pboling
Copy link

pboling commented Apr 3, 2024

I am having the same or similar issue with flat config. Does this project work with flat config? All the docs use legacy cofnig.

@n0099
Copy link
Contributor

n0099 commented Jun 5, 2024

When using flat config, packages @typescript-eslint/{parser,eslint-plugin} should be replaced by the merged typescript-eslint since they only provide flat .configs in that package: typescript-eslint/typescript-eslint#7935

But typescript-eslint-parser-for-extra-files is still using @typescript-eslint/{parser,eslint-plugin} when the user only have typescript-eslint leading to cannot resolve these packages.

So currently we may only use @eslint/eslintrc: https://eslint.org/blog/2024/05/eslint-compatibility-utilities/

import { FlatCompat } from '@eslint/eslintrc';

const compat = new FlatCompat();

export default [
    ...compat.extends( // https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files/issues/95
        'plugin:@typescript-eslint/strict-type-checked',
        'plugin:@typescript-eslint/stylistic-type-checked',
    ),
    {
        files: ['**/*.ts'],
        languageOptions: { parser: typescriptESLintParserForExtraFiles },
    },
    {
        files: ['**/*.vue'],
        languageOptions: {
            parser: vueESLintParser,
            parserOptions: {
                parser: typescriptESLintParserForExtraFiles,
                project: ['./tsconfig.json', './tsconfig.node.json'],
                tsconfigRootDir: import.meta.dirname,
            },
        },
    },
];

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

3 participants