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

Bug: Cannot lint both inside and outside code blocks #297

Closed
1 task
ehmicky opened this issue Oct 30, 2024 · 4 comments
Closed
1 task

Bug: Cannot lint both inside and outside code blocks #297

ehmicky opened this issue Oct 30, 2024 · 4 comments
Labels
bug repro:needed This issue should include a reproducible example

Comments

@ehmicky
Copy link

ehmicky commented Oct 30, 2024

Environment

ESLint version: 9.13.0
@eslint/markdown version: 6.2.1
Node version: 23.1.0
npm version: 10.9.0
Operating System: Ubuntu 24.04

Which language are you using?

commonmark

What did you do?

Configuration

// eslint.config.js
import markdown from '@eslint/markdown'

export default [
  {
    plugins: {
      markdown,
    },
  },
  {
    files: ['**/*.md'],
    processor: 'markdown/markdown',
    language: 'markdown/commonmark',
    rules: {
      'markdown/no-duplicate-headings': 'error',
    }
  },
  {
    files: ['**/*.md/*.js'],
    rules: {
      'no-undef': 'error',
    },
  },
]

Markdown file

This is test.md

# Title

# Title

```js
test
```

Actual behavior

$ ls
eslint.config.js  node_modules  package.json  package-lock.json  test.md
$ eslint

/home/ether/Desktop/try_eslint/test.md
  6:1  error  'test' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)

If I comment out the processor: 'markdown/markdown' line in my eslint.config.js, I get this instead:

$ eslint

/home/ether/Desktop/try_eslint/test.md
  3:1  error  Duplicate heading "Title" found  markdown/no-duplicate-headings

✖ 1 problem (1 error, 0 warnings)

What did you expect to happen?

I expect to get both linting errors at the same time.

What actually happened?

I either get linting applied to the contents outside of the code blocks, or inside of the code blocks, depending on whether processor is specified in my eslint.config.js.

Link to Minimal Reproducible Example

https://github.com/ehmicky/eslint-markdown-bug

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@ehmicky ehmicky added bug repro:needed This issue should include a reproducible example labels Oct 30, 2024
@nzakas
Copy link
Member

nzakas commented Oct 30, 2024

This is a limitation of ESLint itself, not with this plugin. We're working on it:
eslint/eslint#14745

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2024
@ehmicky
Copy link
Author

ehmicky commented Oct 30, 2024

Hi @nzakas,

Thanks and sorry as I am realizing this is a duplicate of #276.

It seems like the above issue might take a little time to resolve. Are there any known workarounds in the meantime?

@nzakas
Copy link
Member

nzakas commented Oct 30, 2024

The only workaround is to run ESLint twice, one with each configuration. That's what this repo does.

@ehmicky
Copy link
Author

ehmicky commented Oct 31, 2024

Thanks for your answer @nzakas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug repro:needed This issue should include a reproducible example
Projects
Status: Complete
Development

No branches or pull requests

2 participants