-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Give rules access to settings #279
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
ca0bfba
to
9f2c248
Compare
This comment was marked as resolved.
This comment was marked as resolved.
d816196
to
f5ddf64
Compare
deed8ce
to
ef344b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jablko!
It's good to see #279 moving forward, thanks for taking time to look into it.
A general note, there seem to be some changes which, at first blush appear to be unrelated mixed in here.
Some documentation changes, and (semver) major changes to how settings directly passed are handled.
Are those intentional? Could you expand a bit on how they tie into this PR and what the goal/intention with the additional changes is?
so, some rules might need access to the fileSet too
Could you expand on this?
In general Unified/remark/remark-lint acts on a single file at a time.
There has been some thoughts on a higher level tool which would handle multiple files unifiedjs/ideas#11 (comment), but that would likely live at a higher level of abstraction?
@@ -40,32 +40,32 @@ | |||
* @copyright 2015 Titus Wormer | |||
* @license MIT | |||
* @example | |||
* {"setting": "*", "name": "ok.md"} | |||
* {"settings": {"emphasis": "*"}, "name": "ok.md"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears to suggest a breaking change?
That all configuration would need to be updated to this format?
Is that accurate?
@@ -135,14 +135,10 @@ a value of `2` can be defined here. | |||
|
|||
##### `ok.md` | |||
|
|||
When configured with `2`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, I'm a bit confused.
These changes appear to be unrelated to the settings, and it's unclear what these changes fix/improve.
script/util/rule.js
Outdated
@@ -77,7 +77,7 @@ export function rule(filePath) { | |||
|
|||
while (++index < examples.length) { | |||
const lines = examples[index].split('\n') | |||
/** @type {{name: string, label?: 'input'|'output', setting?: unknown, positionless?: boolean, gfm?: boolean}} */ | |||
/** @type {{name: string, label?: 'input'|'output', settings?: unknown, setting?: unknown, positionless?: boolean, gfm?: boolean}} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a typo, defining settings
twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings
is the processor.use({settings})
argument vs. setting
is the processor.use(rule, setting)
argument.
@ChristianMurphy Thank you for the encouragement! I started out aiming to give rules access to remark-lint/packages/remark-lint-emphasis-marker/index.js Lines 108 to 111 in 8b57de8
I've now added a commit to update those docs. 👍 |
unified-engine passes |
I've added a commit to make the remaining rules' options default to their respective settings. |
c6a986f
to
20685cf
Compare
@jablko How’s it going here? Can you let me know if you need help or if there’s anything in particular to review? |
ad97cc3
to
c59a20a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the helpful and detailed feedback!
// recommended preset, but if we’d prefer something else, it can be | ||
// reconfigured: | ||
settings: {listItemIndent: 'one'} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've edited the prose:
settings.listItemIndent
is set totab
in the recommended preset, but you can change it if you’d prefer something else:
|
||
* Pass a severity, options, or both to the rules themselves. | ||
This affects each rule individually and takes highest precedence. | ||
* Some rules correspond to settings that are shared among all remark plugins --- particularly [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've added shared settings docs to the Configure section.
to always use fenced code. | ||
|
||
## Examples | ||
|
||
##### `ok.md` | ||
|
||
When configured with `'indented'`. | ||
When [`settings.fences`](https://github.com/remarkjs/remark-lint#configure) is `false` and the rule is not configured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In each readme I've linked to the monorepo Configure section.
| Setting | Rule | | ||
| - | - | | ||
| [`settings.bullet`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsbullet) | [`remark-lint-unordered-list-marker-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-unordered-list-marker-style) | | ||
| [`settings.bulletOrdered`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsbulletordered) | [`remark-lint-ordered-list-marker-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-style) | | ||
| [`settings.closeAtx`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionscloseatx) | [`remark-lint-heading-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style) | | ||
| [`settings.emphasis`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsemphasis) | [`remark-lint-emphasis-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-emphasis-marker) | | ||
| [`settings.fence`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfence) | [`remark-lint-fenced-code-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-marker) | | ||
| [`settings.fences`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfences) | [`remark-lint-code-block-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style) | | ||
| [`settings.incrementListMarker`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsincrementlistmarker) | [`remark-lint-ordered-list-marker-value`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-value) | | ||
| [`settings.listItemIndent`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionslistitemindent) | [`remark-lint-list-item-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent) | | ||
| [`settings.quote`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsquote) | [`remark-lint-link-title-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-link-title-style) | | ||
| [`settings.rule`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrule) | [`remark-lint-rule-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style) | | ||
| [`settings.ruleRepetition`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrulerepetition) | [`remark-lint-rule-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style) | | ||
| [`settings.ruleSpaces`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsrulespaces) | [`remark-lint-rule-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style) | | ||
| [`settings.setext`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionssetext) | [`remark-lint-heading-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style) | | ||
| [`settings.strong`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsstrong) | [`remark-lint-strong-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've added a table to the Configure section, listing the settings that also affect lint rules.
> 🧑🏫 **Info**: remark lint rules *check* markdown. | ||
> [`remark-stringify`][remark-stringify] *formats* markdown. | ||
> They behave consistently when you change shared settings that they both understand, but not if you pass options to rules individually. | ||
> Passing options to rules individually doesn't affect [`remark-stringify`][remark-stringify] or vice versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've added the trade-offs between rules' options and shared settings to the Configure section, and called out the synchronization problem.
@@ -141,24 +138,24 @@ This preset configures [`remark-lint`][mono] with the following rules: | |||
| [`remark-lint-maximum-line-length`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length) | `80` | | |||
| [`remark-lint-no-shell-dollars`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shell-dollars) | | | |||
| [`remark-lint-hard-break-spaces`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-hard-break-spaces) | | | |||
| [`remark-lint-heading-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style) | `'atx'` | | |||
| [`remark-lint-heading-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style) | [`settings.setext`](https://github.com/remarkjs/remark-lint#configure) is `false` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've distinguished between rules' options and shared settings in the presets' readmes.
script/build-rules.js
Outdated
const {settings, rawOptions} = JSON.parse(configuration) | ||
const fixtures = tests[configuration] | ||
|
||
// Don't show the same test for both shared settings and rules' options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've hidden repetitious examples from the readmes:
- All of the existing tests are retained.
- Each readme has the same number of examples as it does now.
Co-authored-by: Titus <[email protected]>
This reverts commit 7d24ed2.
Are we moving on this? cc @wooorm |
It’s been a while! @jablko Was this done? Ready for another review? Anything in particular I can help with? |
Any update on this 🤔 |
Initial checklist
Description of changes
I'm interested in working on this: Giving rules access to
settings
.Also, some rules might need access to the
fileSet
too? but from what I could gather, whilesettings
is accessible viathis
(processor:this.data().settings
),fileSet
isn't? Consequently I've appended it to the rule arguments, symmetric with how the other (options
) attacher parameter is appended to the rule arguments, roughly.Fixes #263 (comment)