Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdownlint-rule-search-replace

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdownlint-rule-search-replace - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json
{
"name": "markdownlint-rule-search-replace",
"version": "1.1.1",
"version": "1.2.0",
"description": "A custom markdownlint rule for search and replaces",

@@ -5,0 +5,0 @@ "main": "rule.js",

@@ -49,2 +49,3 @@ # markdownlint-rule-search-replace

"message": "Do not use three dots '...' for ellipsis.",
"information": "https://example.com/rules/ellipsis",
"search": "...",

@@ -70,6 +71,7 @@ "replace": "…",

- search-replace definition: defines search term/pattern and replacement.
- `name`: name of the definition.
- `message`: corresponding message.
- `search`: text or array of texts to search
- `searchPattern`: regex pattern or array of patterns to search. Include flags as well, as if you are defining a regex literal in JavaScript, e.g. `/http/g`.
- `name`: Name of the definition.
- `message`: Corresponding message.
- `information`: Optional. An absolute URL of a link to more information about the sub-rule.
- `search`: Text or array of texts to search.
- `searchPattern`: Regex pattern or array of patterns to search. Include flags as well, as if you are defining a regex literal in JavaScript, e.g. `/http/g`.
- `replace`: Optional. The replacement string(s), e.g. `https`. Regex properties like `$1` can be used if `searchPattern` is being used.

@@ -79,3 +81,3 @@ - `searchScope` Optional. Scope to perform the search in.

- `code`: Search only in code (block and inline). That is code inside code fences and inline backticks.
- `text`: Search only in markdown text, skip code.
- `text`: Search only in Markdown text, skip code.
- `skipCode`: Optional. All code(inline and block), which is inside backticks, will be skipped. _This property is deprecated use `searchScope` instead._

@@ -82,0 +84,0 @@

@@ -116,3 +116,3 @@ // @ts-check

*/
const validateRule = (rule) => {
const validateAndUpdateRule = (rule) => {
if (!rule.search && !rule.searchPattern) {

@@ -135,2 +135,10 @@ throw new Error("Provide either `search` or `searchPattern` option.");

}
if (rule.information !== undefined) {
try {
rule.information = new URL(rule.information);
} catch {
throw new Error(`Provide valid 'information' URL: ${rule.information}`);
}
}
};

@@ -153,2 +161,3 @@

range: [columnNo + 1, match.length],
information: rule.information,
};

@@ -177,3 +186,3 @@

// expand multivalue rules
// expand rules with multiple values
const listRules = [];

@@ -208,3 +217,3 @@ for (const rule of rules) {

for (const rule of rules) {
validateRule(rule);
validateAndUpdateRule(rule);

@@ -211,0 +220,0 @@ const regex = rule.search

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc