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

read settings config for rules like remark-lint-strong-marker #263

Closed
JounQin opened this issue Apr 29, 2021 · 10 comments
Closed

read settings config for rules like remark-lint-strong-marker #263

JounQin opened this issue Apr 29, 2021 · 10 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@JounQin
Copy link
Member

JounQin commented Apr 29, 2021

Subject of the feature

As title

Problem

var report = require('vfile-reporter')
var remark = require('remark')
var emphasisMarker = require('remark-lint-emphasis-marker')
var strongMarker = require('remark-lint-strong-marker')

remark()
  .use({
    settings: { emphasis: '*', strong: '*' },
    // ^ `remark-stringify` settings.
  })
  .use(emphasisMarker)
  .use(strongMarker)
  // ^ two `remark-lint` rules.
  .process('_Hello_, __world__!', function(err, file) {
    console.error(report(err || file))
    console.log(String(file))
  })

There is no warning at all.

Expected behavior

emphasisMarker and strongMarker can read remark-stringify settings automatically to set the default style, so that the user don't have to config same thing twice.

Alternatives

N/A

@JounQin JounQin added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Apr 29, 2021
@wooorm
Copy link
Member

wooorm commented Apr 29, 2021

That might work 🤔

Rules don’t have access to settings though. So that would mean some changes have to land in unified-lint-rule first.

@wooorm wooorm added 🤞 phase/open Post is being triaged manually and removed 🦋 type/enhancement This is great to have 🙉 open/needs-info This needs some more info labels Aug 22, 2021
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Aug 22, 2021
@github-actions

This comment has been minimized.

@wooorm wooorm added 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels Aug 22, 2021
@github-actions

This comment has been minimized.

@wooorm
Copy link
Member

wooorm commented Aug 22, 2021

I think it’s fine to do this. One part is:

which should probably be:

}).call(this, tree, file, options)

then, this.data('settings') could be uses in the rules, based on https://github.com/syntax-tree/mdast-util-to-markdown#tomarkdowntree-options, to replace the default where needed.

@JounQin Is this something you could help with?

@JounQin
Copy link
Member Author

JounQin commented Aug 23, 2021

@wooorm What kind help do you mean? Raising a PR as you suggested or something else?

@wooorm
Copy link
Member

wooorm commented Aug 23, 2021

Yeah, if this is something you could and would want to work on?
I could perhaps also work on it?

@JounQin
Copy link
Member Author

JounQin commented Aug 23, 2021

I'd like to help, but I'm a bit busy these days, and I'm not so familiar with the code base.

I'll let you know whether I have time to work on before tomorrow, is this OK?

@wooorm
Copy link
Member

wooorm commented Aug 23, 2021

Of course, no rush!
Can also be in a week or so.
Or if you’re not interested, that’s also okay!

@wooorm
Copy link
Member

wooorm commented Jan 24, 2025

I have thought about this for a while now and I don‘t think it is a good idea. Closing this!

First, in many cases, users pass serialization options without settings, but directly to remark-stringify. We cannot catch that:

unified()
  .use(remarkParse)
  .use(remarkLintEmphasisMarker)
  .use(remarkLintStrongMarker)
  .use(remarkStringify, {emphasis: '*', strong: '*'})
  // …

Direct options are also preferred if both exist:

  .use({settings: {emphasis: '_', strong: '_'}})
  .use(remarkStringify, {emphasis: '*', strong: '*'})

Second, I think it becomes too complex to reason what the source of things is.
There are also users who want the rule to be the source,
for how it is configured or for what it finds in a document to create the settings,
to then affect remark-stringify.

Third, lint rules are about the input document, settings (in this case) about the output document.
They do not have to be the same — they could have different preferences.

Finally, settings is an exception. Normally plugins are given options. Those options are not shared with other plugins. But that cannot happen with remark-parse and remark-stringify when used through remark. That’s the exception for why settings exist and when to use it.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2025
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Jan 24, 2025

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

Successfully merging a pull request may close this issue.

2 participants