mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-26 01:36:03 +03:00
[PR #342] [MERGED] Use require.resolve as a fallback of path.resolve #842
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#842
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/DavidAnson/markdownlint/pull/342
Author: @kachkaev
Created: 10/17/2020
Status: ✅ Merged
Merged: 10/22/2020
Merged by: @DavidAnson
Base:
next← Head:fallback-to-require-resolve📝 Commits (10+)
c518e92Use require.resolve as a fallback of path.resolve80a76f5Remove unnecessary catch blockd2800c8Address some comments and add a couple of testsb0c0091Address some comments1e0e339Fix incorrect c8 report on branches5d5a257Tweak nodejs.yml to remove c8 ignore8a66f80resolved → Resolvedb08b5b4Address some review commentsa0a069bAdd paths to require.resolve2854f3bUpdate .github/workflows/nodejs.yml📊 Changes
9 files changed (+5672 additions, -8 deletions)
View changed files
📝
.github/workflows/nodejs.yml(+2 -2)📝
.gitignore(+1 -0)📝
lib/markdownlint.js(+32 -6)➕
package-lock.json(+5590 -0)➕
test/config/config-badchildpackage.json(+4 -0)➕
test/config/config-packageparent.json(+7 -0)📝
test/markdownlint-test.js(+29 -0)➕
test/node_modules/pseudo-package/config-frompackage.json(+4 -0)➕
test/node_modules/pseudo-package/package.json(+3 -0)📄 Description
Hi @DavidAnson! We had a discussion about resolving
config.extendsin the CLI some time ago; this PR is a follow-up.My initial question a few months ago was about extending
jsfiles in an auto-discoveredjsonconfig and you explained some unwanted security implications of a change in the logic. We also discussed an opportunity of usingrequire.resolveas a risk-free option for those who want to use a shared markdownlint config and avoid writing something like this in their.markdownlint.json:This is what used to stick with till now.
This weekend I was playing with Yarn v2 (Berry) and realised that the conversion of
"./node_modules/@my-company/markdownlint-config/index.json"to"@my-company/markdownlint-config"became unavoidable. The folder callednode_modulesno longer exists and the real location of all dependency files is now fully controlled by Yarn. Thus, there is no way to refer to a config file in a third-party package without usingrequire.resolve.This PR adds
require.resolveas a fallback topath.resolvein a fully backwards-compatible manner. It should not affect the security model and does not change the error messages in the existing scenarios. The resolution strategy just becomes a little bit more optimistic and can successfully handle more cases than it used to before. So the change in the logic remains unnoticeable for the existing Markdownlint users, while making it possible to use fancier and shorter"extends"paths.I'd be keen to hear what you think about this change and if you're generally happy with the approach, I'm happy to add tests and resolve any other review comments you might have. WDYT?
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.