why-jay / remark-lint-sentence-newline

Enforce a newline after an end of sentence in Markdown
7 stars 0 forks source link

Warning is not showing up? #2

Closed why-jay closed 9 years ago

why-jay commented 9 years ago

I've seen cases where the file.warn is reached but at the end of the linting I don't see any yellow warnings from this rule on the CLI.

@wooorm Could you do me a favor and see if there is more than what I did in the code in order to render a warning on the CLI?

wooorm commented 9 years ago

I’m not sure what use case you were referring to. I’m assuming regarding to mdast-lint-sentence-newline? I ran your example and it was ignored because HTML needs an extra black line after it:

The following is just two HTML blocks:

<!-- Invalid -->
Hello, world. This sentence should be on a second line.

<!-- Valid -->
Hello, world.
This sentence should be on a second line.

But this is HTML comments and text:

<!-- Invalid -->

Hello, world. This sentence should be on a second line.

<!-- Valid -->

Hello, world.
This sentence should be on a second line.

The last one is warned about about:

screen shot 2015-09-12 at 9 13 26 a m

why-jay commented 9 years ago

@wooorm Sorry for not being clearer - yes, I am talking about my custom rule. And, ah, I didn't know about the HTML comments thing, thanks. Just pushed a commit that fixes the example.

But there's another test case where what I mentioned above is still happening - let me come back with a test case to show you.

why-jay commented 9 years ago

Fuck, I'm too tired - I'll ping you tomorrow. Thanks for your help.

wooorm commented 9 years ago

Sure!

why-jay commented 9 years ago

@wooorm I'm writing tests - can I get some more help? According to the mdast-lint API doc, I'm supposed to use file.messages inside the callback to #process(). But on this line in my test suite, I keep getting undefined for file.messages:

https://github.com/chcokr/mdast-lint-sentence-newline/blob/master/test/test.js#L26

wooorm commented 9 years ago

err, res, file > err, file, res. Did you get this from an example?

why-jay commented 9 years ago

Ah, thanks! Yes, from here: https://github.com/wooorm/mdast-lint/blob/master/doc/api.md

Looks like it needs to be fixed over there!

wooorm commented 9 years ago

on it

why-jay commented 9 years ago

@wooorm Thanks, you the man.

Alright, so I just added my mysterious test case. It's actually not mysterious any more - I know why it's breaking. When there's a header, unist-util-visit doesn't seem to visit the section's child text nodes properly. Shouldn't it visit all text nodes, even ones in children, when I do visit(ast, 'text')?

https://github.com/chcokr/mdast-lint-sentence-newline/blob/master/test/header-body/file.md

wooorm commented 9 years ago

Shouldn’t the done(); be outside visit? Maybe that’s it?

wooorm commented 9 years ago

Yup, changing that fixed your tests.

why-jay commented 9 years ago

Ah, silly me! Closed via 4c302fdaf3feac625876d31ce5395320dd961204. Thank you so much for all your work - mdast is very well maintained and I hope it gets even more attention and adoption. Is there any way to donate to your open-source efforts?