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

indent does not work well with eslint-plugin-mdx #215

Closed
3 of 5 tasks
JounQin opened this issue Dec 8, 2023 · 11 comments
Closed
3 of 5 tasks

indent does not work well with eslint-plugin-mdx #215

JounQin opened this issue Dec 8, 2023 · 11 comments

Comments

@JounQin
Copy link

JounQin commented Dec 8, 2023

Validations

Describe the bug

From antfu/eslint-config#347 and https://github.com/antfu/eslint-config/pull/353/files#r1420692632

image

Reproduction

https://github.com/antfu/eslint-config

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@antfu
Copy link
Member

antfu commented Dec 11, 2023

Trying to dig a little bit, it seems that the indent rules reads all tokens:

const tokens = sourceCode.tokensAndComments
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]

While eslint-mdx produces program.body that only contains JS statements, some markdown notes are presented in the tokens:

image

I wonder if those tokens are used somewhere, is it possible to filter them out, or provide an options to omit them?

@JounQin
Copy link
Author

JounQin commented Dec 11, 2023

I wonder if those tokens are used somewhere, is it possible to filter them out, or provide an options to omit them?

The tokens are there because they should? Maybe indent is not meant to be used on .mdx, so then feel free to close. If it wants to support other files, then that's indent rule's mission.

@antfu
Copy link
Member

antfu commented Dec 11, 2023

It basically means that the source.ast.body and source.ast.tokens are misaligned in the past produced to by eslint-mdx. If eslint-mdx trying to produce an AST compatible with the ESTree that can be handled by other rules, I believe this is not expected.

And for the record, this is how indent rule works in ESLint core. We haven't changed anything about it.

@JounQin
Copy link
Author

JounQin commented Dec 11, 2023

And for the record, this is how indent rule works in ESLint core. We haven't changed anything about it.

Yes, because it's not meant to be run on .mdx files.

@antfu
Copy link
Member

antfu commented Dec 11, 2023

Well, if you say so, good luck then.

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@JounQin
Copy link
Author

JounQin commented Dec 11, 2023

I'm also trying to add more ESTree compatible MDX related node types start from mdx-js/eslint-mdx#489

@JounQin
Copy link
Author

JounQin commented Dec 27, 2023

I'm also trying to add more ESTree compatible MDX related node types start from mdx-js/eslint-mdx#489

@antfu Can you reopen this issue and assign it me?

@antfu
Copy link
Member

antfu commented Dec 27, 2023

What's your plan for fixing it? I would think it's better to fix it on MDX side, unless it's very easy to fix here.

@JounQin
Copy link
Author

JounQin commented Dec 27, 2023

I'm planning to fix it it eslint-mdx.


Besides, I'm one of the maintainer of eslint-config-prettier now, and I want to support @eslint-stylistic in the long term, see also prettier/eslint-config-prettier#276 (comment), it would be nice if I can join this organization, and also so that I can transfer this issue to https://github.com/mdx-js/eslint-mdx instead.

@antfu
Copy link
Member

antfu commented Dec 27, 2023

Not that I do not trust you, but I don't think it's a good reason to join an org just to transfer away an issue. Why not just create another issue on mdx and link to this one?

@JounQin
Copy link
Author

JounQin commented Dec 27, 2023

@antfu

Why not just create another issue on mdx and link to this one?

It's not the reason, it's the benefit effect if I joined.

I want to support @eslint-stylistic in the long term


Of course, that's totally OK if you don't accept 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

2 participants