Closed why-jay closed 8 years ago
Maybe because you’re still linked from the mdast-
prefix?
# from mdast-lint-sentence-newline
npm unlink
cd ..
mv mdast-lint-sentence-newline remark-lint-sentence-newline
cd remark-lint-sentence-newline
rm -rf node_modules && npm install # just to be sure new module come along properly
npm link
...and try again.
Maybe it’s something else though? If this doesn’t work, please ping again!
Ah, I know what the problem is now.
By external:[\"remark-lint-sentence-newline\"]
, remark
looks up the local scope, not the global score (as in npm install
vs npm install -g
).
How could I address this?
This is the list remark-lint supports, whereas this is what remark supports.
And this code ensures to only depend on globally installed plug-ins when remarkis also in global mode.
If you’re interested, you can do a PR :wink:
So, in the case of this issue, the global remark-lint-sentence-newline
rule is not being found because remark-lint
only supports the following:
$cwd/$pathlike
;$cwd/$pathlike.js
;$cwd/node_modules/$pathlike
;$pathlike
.Am I correct?
Yup!
Also: the reason for not always loading global dependencies is in fact so that people get some error.
When you package a .remarkrc
file, you should add said rule to your dependencies and not depend on a global package.
Right. I actually think the current behavior is good. I guess I need to change external:[\"remark-lint-sentence-newline\"]
to refer to the global directory, but am not sure how to do this. Is there some sort of a Node.js way of referring to the global npm cache..?
Or do you think this is a better alternative: If a .remarkrc
is being used, don't look up globally. Otherwise, do look up globally. Something like this.
The only way to detect that is here in remark, but that’s in JS and not in a .remarkrc
. Maybe you could specify an absolute path though?
Anyway, I think I prefer loading global plugins/rules when in global mode (so just like remark itself) over treating CLI flags different from .remarkrc
.
Ah, I see. That makes sense. So it comes down to: If remark
is global, remark-lint
should look up globally too. If this is correct, I'll work on a PR over the next couple of days.
Yes, it is! When remark is global, it looks up a local remark-lint and if that isn’t found, it looks for a global remark-lint. So what we’re adding now is that remark-lint will load external rules normally but when it cannot find them in global mode, tries the global npm directory.
:+1:
Now being tracked at https://github.com/wooorm/remark-lint/issues/38
Hey @wooorm, could you help!
If I run the following inside this repo,
I get this error:
Do you happen to know what this is about?