-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Compatibility with Yarn 2 (berry) #131
Comments
The VS Code extension does not depend on any version of the library being installed. It bundles its own version and uses that. So I am guessing there doesn't need to be any path redirection as with those other tools. The extends implementation used by the VS Code extension is the same one that is exported by the library, so it should automatically benefit from your changes there once the dependency is updated. Therefore, it doesn't seem like there should be any special work needed here. But please let me know if you find otherwise. |
I see what you mean. I have not noticed that the extension does not resolve a local version of markdownlint and always uses a built-in one. This behaviour of other linters made me think Markdownlint is doing something similar. Perhaps, it could be worth adding something like |
I'd love to let the other tools (with actual teams behind them) figure this out. Per this section, it seems extensible configuration in ESLint still has issues with Yarn's PNP: https://yarnpkg.com/features/pnp#native-support. The idea of Yarn modifying extensions installed via VS Code seems problematic - especially when those extensions get updated automatically (presumably overwriting the customizations). |
I agree with you that Yarn v2 is still not playing well with the tooling. The support improves over time though and I guess will be good enough quite soon. My experiment with Yarn 2 was somewhat painful this weekend, but I imagine that a year ago the pain would be 10 times more. ESLint seems to be on the path to resolving their compatibility problem and I’m looking forward to trying it out: eslint/eslint#13481! Let’s try to finish DavidAnson/markdownlint#342 and then come back to this conversation. It’d be great to discuss the missing bits for integrating Markdownlint with VScode and Yarn 2 🙂 Happy to help! |
I published new versions of the library and VS Code extension with your changes to handle this scenario better (updated CLI’s to come in a few days). Thanks for the help! Please give this a try and let me know if there’s more to do in this issue. |
Hi @DavidAnson! Which version of Markdownlint should I try? The latest on npm is 0.21.1, which does not seem to include the fallback: https://www.npmjs.com/package/markdownlint?activeTab=versions. Same for the |
@kachkaev You're right, I'm sorry for wasting your time! The release I did was the patch release for two minor issues. Your change is in the "next" branch, but not yet part of the release. I got the two mixed up in my head, sorry. |
Try now. |
Just tried the VSCode extension in kachkaev/njt#29 again. Seems like I’m still blocked by lack of DavidAnson/markdownlint#342. If I replace |
I'm not sure I understand. Are you saying that you are still blocked because this feature is not yet present in the extension? That makes sense and will be resolved soon, though I thought you were building your own extension to test this? Or are you saying that your scenario doesn't work with the feature as it's been implemented and we should change how it works in the library? |
|
After upgrading all deps in kachkaev/njt#29, I managed to get Markdownlint working in CI, which is great. However, the VSCode integration is still lacking. Here is what’s show in Markdownlint output:
So the VSCode extension falls back to the default Markdownlint config and incorrectly highlights some bits of the markdown, while ignoring the errors I would like it to report. My {
"extends": "@kachkaev/markdownlint-config",
"first-line-heading": false,
"no-inline-html": false
} That’s similar to, say, my project’s ESLint config, which works: module.exports = {
extends: ["@kachkaev/eslint-config-react"],
rules: {
// ...
},
overrides: [
// ...
}; The is a significant difference between how Markdownlint VSCode extension works compared to other extensions I’ve been using. TypeScript, ESLint and Prettier extensions try finding a locally installed executable for a given tool and run it in the background. This guarantees the parity between CLI, CI/CD and the editor no matter what. If a tool can resolve a plugin from the command line, so will the VSCode extension, because all it does is just calling that same tool. As far as I understand, Markdownlint for VSCode runs a built-in version of the library and only looks for the config file in the project. Other linters do this too, but only as a fallback when a local executable is not found or its path is not manually provided. The reason why a built-in library is only fallback option is because it does not guarantee the linting parity between all members of a team. Codebase collaborators can have different editors and different versions of the extension, and if that’s the case, there’ll be discrepancies between contributions or between the feedback people see locally and in CI. Because the local CLI executable is not involved in the Markdownlint VSCode extension, package resolution fails and so To summarise, for package resolution to work in a Yarn 2 project, we need Markdownlint for VSCode to call a local executable, which will be able to load the project’s config and call the right
We should probably reopen this issue. Although the prevalence of Yarn 2 is still small, it’s just a matter of time when this issue will be hit by more developers. |
I'll need to think about this some more. You are right that this extension uses a bundled version of the library, but this has never been an issue. Teams can easily standardize on extension versions, so I'm not sure it needs to be an issue now, either. I think I understand why the new behavior isn't working as you'd like, but that may not be hard to fix. If you have a project you can point me at that demonstrates the problem, that would be helpful! Otherwise, I'll try to reproduce the scenario and see if it can be addressed by resolving packages relative to the project directory. I'd rather not have to worry about accommodating every different package manager, but I also fear that calling a local executable adds complexity and potential confusion. |
Seems like I should be able to use njt to test with? I'll try that first. |
Thanks for reopening this issue! Indeed, yarn 2 with PnP is bringing quite a few challenges across the ecosystem but the benefits it brings make the efforts to resolve them worthy. What’s good is that many tools are still on the path of supporting PnP, so there is no immediate pressure from production-grade projects on Markdownlint at this point. If you want to experiment, feel free to use njt’s branch called |
I had a bit of time to look at this. It works today as it should - kind of... What I'm seeing is that if I run the extension in bundled/release mode ( |
This seems to be a problem with webpack and is detailed here: webpack/webpack#9393 As in that example, |
Also relevant: webpack/webpack#4175 webpack does not seem to support the scenario where library code needs to dynamically |
I think I have a workaround - though it requires patching |
Seems like there are still problems with PnP. Using
|
@DavidAnson are you able to reproduce this? If yes, shall we reopen this issue or create a new one? |
It may be a little while before I get a chance to look into this. It sounds like things worked correctly according to the previous scenario, but are breaking under different circumstances. Please open a new issue with the information above. |
I was playing with Yarn 2 and discovered that the linting tools required an additional setup in order to be integrated with VSCode. After running
yarn set version berry; yarn install
and updating.gitignore
, I also had to run this somewhat unusual command:It created a bunch of files in
yarn/sdks
and also added.vscode/settings.json
with the links to the new entry points for the tools. That affected ESLint, Prettier and TypeScript, but not Markdownlint.I'm opening this issue to explore what’s needed for a local Makrdownlint to become compatible with VSCode when a project is configured with Yarn 2. The adoption of its new ‘Plug and Play’ architecture is still low, but I guess that the raise is inevitable.
As of now, it seems that VSCode falls back to the global version of Markdownlint, which may be different from the one mentioned in
devDependencies
. Besides,.markdownlint.json
is ignored if the file extends a config in a local npm package. The latter will be fixed for CLI via DavidAnson/markdownlint#342, but we'll probably need to do something extra to fix the SDK integration as well.I won’t have time this weekend, but happy to join the investigation and also help with the testing in the upcoming weeks.
The text was updated successfully, but these errors were encountered: