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

Fix: use blocksCache instead of single blocks instance (fixes #181) #183

Merged
merged 6 commits into from Apr 5, 2021
Merged

Fix: use blocksCache instead of single blocks instance (fixes #181) #183

merged 6 commits into from Apr 5, 2021

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Mar 18, 2021

pass through lint messages from other plugins

close #181


split part of #178

@btmills

@JounQin
Copy link
Contributor Author

JounQin commented Mar 18, 2021

This issue will only occur when integrating with other plugins like eslint-plugin-mdx which will lint original .md files by preprocess too.

Here is the fake version for testing.

https://github.com/eslint/eslint-plugin-markdown/pull/183/files#diff-83e0a2056017ee834945f51308072e4a883a4ed96193581fe4aabc41cb98710a

@btmills
Copy link
Member

btmills commented Mar 28, 2021

Thanks to your discussion in #181 and https://github.com/eslint/eslint/pull/14227/files#r602802758, we can reproduce this in a test without stubbing another mdx plugin! So let's simplify this:

<!-- test.md -->

````markdown
<!-- test.md/0_0.markdown -->

```js
// test.md/0_0.markdown/0_0.js
console.log("Hello");
```
````

With that as the test input, if you configure the CLIEngine to run this plugin's processor on .md and .markdown files (the recommended config only does .md), ESLint should run the processor recursively. That should reproduce the bug without having to stub another plugin and reduce the number of moving parts in this PR.

If that doesn't work, mention me and I'll see if I can put together a reproduction case that you can use to prove this implementation works.

I'm glad you were able to fix this by keying the blocks cache on the filename. There are two implementation tweaks that I'd like to request:

  1. Can you store the cache in a Map instead of an object? That's supported all the way back to Node 8.10.
  2. To save memory, would it be possible to remove blocks from the cache once postprocess() is done with them?

@btmills btmills added this to Pull Request Opened in Triage Mar 28, 2021
pass through lint messages from other plugins
@JounQin
Copy link
Contributor Author

JounQin commented Mar 30, 2021

@btmills All done!

package.json Outdated Show resolved Hide resolved
examples/typescript/README.md Show resolved Hide resolved
lib/processor.js Outdated Show resolved Hide resolved
JounQin added a commit to mdx-js/eslint-mdx that referenced this pull request Apr 4, 2021
JounQin added a commit to mdx-js/eslint-mdx that referenced this pull request Apr 4, 2021
Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working so hard to get this down to just the essential components! I'm really happy with where it ended up. LGTM.

@btmills btmills changed the title Fix: use blocksCache instead of single blocks instance Fix: use blocksCache instead of single blocks instance (fixes #181) Apr 5, 2021
@btmills btmills merged commit d23d5f7 into eslint:main Apr 5, 2021
Triage automation moved this from Pull Request Opened to Complete Apr 5, 2021
@JounQin JounQin deleted the fix/blocks branch April 5, 2021 02:51
@JounQin
Copy link
Contributor Author

JounQin commented Apr 5, 2021

@btmills Any schedule for a release then?

@btmills
Copy link
Member

btmills commented Apr 5, 2021

Now! https://github.com/eslint/eslint-plugin-markdown/releases/tag/v2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Triage
Complete
Development

Successfully merging this pull request may close these issues.

[bug] blocks will be reset on preprocess every time and will break .md in .md
2 participants