-
-
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
Add support for external rules #14
Comments
First: loading extra rules wouldn't be very hard. I’ll just Then, every rule could define the options it accepts. So, to me, something like this fictional {
"plugins": {
"lint": {
"external": [
"standard-markdown"
],
"maximum-line-length": 60,
"some-standard-markdown-rule": false
}
}
} But an alternative would be the following: {
"plugins": {
"lint": {
"external": {
"standard-markdown": {
"some-standard-markdown-rule": false
}
},
"maximum-line-length": 60
}
}
} However, this setup (just a rule object as exports) would not support plug-in specific settings... |
I would opt for the first version, as same names imply same rule. So every Is there currently anything that restricts plugin options to {
"plugins": {
"lint": {
"external": ["standard-markdown"],
"maximum-line-length": 60,
"standard-markdown-optional-blocks": ["badges", "reference"]
}
}
} |
Rules can receive anything. Only the settings relating to Still, as i explained earlier, all rules are run regardless of value, and receive that value as a third argument. |
I agree btw that your example looks good :) |
@zcei Hmm, I’m still missing one part, how about the JS API, something like this? var mdast = require('mdast');
var lint = require('mdast-lint');
var standard = require('mdast-lint-standard');
var processor = mdast().use(lint, {
'external': [standard],
'maximum-line-length': 60,
'standard-markdown-optional-blocks': ['badges', 'reference']
}); |
I'd rather have the plugin configured before: var mdast = require('mdast');
var lint = require('mdast-lint');
var standard = require('mdast-lint-standard');
standard.optionalBlocks(['badges', 'reference']);
var processor = mdast().use(lint, {
'external': [standard],
'maximum-line-length': 60
}); Then you can easily reuse some parts without fuzzy work with removing the configuration values from the object. But then, having two different styles in Thoughts on this? |
To be consistent in the example: var mdast = require('mdast');
var lint = require('mdast-lint');
var standard = require('mdast-lint-standard');
standard('optional-blocks', ['badges', 'reference']);
standard.optionalBlocks(['badges', 'reference']);
lint('maximum-line-length', 60);
lint.maximumLineLength(60);
lint('external', [standard]);
lint.external([standard]);
var processor = mdast().use(lint); |
TBH I’d rather not add much difference to the CLI/API. Especially the boilerplate needed for many getters/setters seems unnecessary to me! In addition, the above setters all set options on the global Why not just use JSON when possible for settings? |
Guess you're right - there is no negative argument I could provide against your provided solution. |
Alright :) however, it's your plugin, so you can do whatever! But this system is already in place so it'd be less of a hassle! |
Err.. what kind of community are we in here? :) And due to its intention to serve as a standard for the community there is no "do whatever you want", more like "do whatever everyone wants" 🎯 |
* Add example rule, and rule object file, to `test/external`; * Add fixtures for external tests; * Move `mdast.js`, `mdast.min.js` to `mdast-lint.js`, `mdast-lint.min.js`; * Add docs for external rules. Closes GH-14.
* Add example rule, and rule object file, to `test/external`; * Add fixtures for external tests; * Move `mdast.js`, `mdast.min.js` to `mdast-lint.js`, `mdast-lint.min.js`; * Add docs for external rules. Closes GH-14.
With this I could build
standard-readme
as a semantic rule checked bymdast-lint
.I think about smth like this:
or even with customization:
The text was updated successfully, but these errors were encountered: