Comments (9)
Actually, I think I understand after looking at your project README. This seems like a bit of an edge case, but it's reasonable for me to add. I put it on my TODO list.
from markdownlint-rule-search-replace.
This scenario will be supported in the next release of markdownlint
: DavidAnson/markdownlint@c699b8e
from markdownlint-rule-search-replace.
Beautiful! It exactly solves my requirement—thank you @OnkarRuikar and @DavidAnson 💖 👏
from markdownlint-rule-search-replace.
The markdownlint
package treats the entire custom rule as one rule, at the moment there is not way to make it recognize sub rules as individual. When the custom rule reports an error, this is how the information
URL is being used in upstream markdownlint
package:
results.push({
lineNumber,
"ruleName": rule.names[0],
"ruleNames": rule.names,
"ruleDescription": rule.description,
"ruleInformation": rule.information ? rule.information.href : null,
"errorDetail": errorInfo.detail || null,
"errorContext": errorInfo.context || null,
"errorRange": errorInfo.range ? [ ...errorInfo.range ] : null,
"fixInfo": fixInfo ? cleanFixInfo : null
});
The URL is taken from the rule object and not errorInfo
object. It would be ideal if markdownlint
looks for the info URL in errorInfo
object first.
@DavidAnson This is a valid request as any custom rule may want to provide info URL depending on the error. In order to implement this feature, is it possible to make following change?
-- "ruleInformation": rule.information ? rule.information.href : null,
++ "ruleInformation": errorInfo?.information?.href || rule?.information?.href || null,
@ACyphus till markdownlint
supports this we can do either of these:
a. Provide info URL in custom rule's message itself. But this won't look good.
b. Provide entire rule wide custom info URL.
"search-replace": {
"infoURL": "https://github.com/my/repo/README.md#all_custom_rules
"rules": []
}
c. For now, to support URL for each rule we'll have to cheat a bit by setting href
string on rule.information
object before raising error every time. Need to check the feasibility.
Note: b. and c. will break if upstream implementation changes. markdownlint
need to let custom rules change info URL mid run.
from markdownlint-rule-search-replace.
I'm on my phone right now and only had a chance to skim this issue. I'm not sure I understand the issue, though. Each rule is meant to do a single thing and the URL is meant to explain that. If you are implementing multiple rules, you can export them all from the same package and each can have own URL. If it's confusing to point that URL to wherever it is today, you can point it at the markdownlint project if that's more useful? Basically, I'm not clear on why the URL for a particular rule should need to change dynamically. If you're able to clear that up, I would appreciate it. Thanks!
from markdownlint-rule-search-replace.
... and your sneaky trick of changing the rule definition dynamically will not: DavidAnson/markdownlint@14a7529
😀
from markdownlint-rule-search-replace.
... and your sneaky trick of changing the rule definition dynamically will not: DavidAnson/markdownlint@14a7529
grinning
I haven't implemented the trick ;)
By the way this makes the tool more secure. We need to mention in the documentation that custom rules can not mutate.
from markdownlint-rule-search-replace.
I feel like not mutating should be expected. My second change was just closing an unintentional hole.
from markdownlint-rule-search-replace.
@ACyphus the feature has been published on NPM in the latest version v1.2.0 let me know if it solves your requirement.
from markdownlint-rule-search-replace.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdownlint-rule-search-replace.