markdownlint-rule-search-replace
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "markdownlint-rule-search-replace", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A custom markdownlint rule for search and replaces", | ||
@@ -5,0 +5,0 @@ "main": "rule.js", |
@@ -5,3 +5,3 @@ # markdownlint-rule-search-replace | ||
![npm](https://img.shields.io/npm/v/markdownlint-rule-search-replace) | ||
[![npm](https://img.shields.io/npm/v/markdownlint-rule-search-replace)](https://www.npmjs.com/package/markdownlint-rule-search-replace) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
@@ -74,3 +74,3 @@ | ||
- `searchPattern`: regex pattern to search. Include flags as well, as if you are defining a regex literal in JavaScript, e.g. `/http/g`. | ||
- `replace`: The replacement string, e.g. `https`. Regex properties like `$1` can be used if `searchPattern` is being used. | ||
- `replace`: Optional. The replacement string, e.g. `https`. Regex properties like `$1` can be used if `searchPattern` is being used. | ||
- `skipCode`: Optional. All code(inline and block), which is inside backticks, will be skipped. | ||
@@ -137,3 +137,3 @@ | ||
### With markdownlint api | ||
### With markdownlint API | ||
@@ -140,0 +140,0 @@ Add the rule object to the `customRules` array: |
11
rule.js
@@ -127,3 +127,3 @@ // @ts-check | ||
if (typeof replacement !== "undefined") { | ||
if (typeof replacement !== "undefined" && replacement !== null) { | ||
options.fixInfo = { | ||
@@ -179,5 +179,8 @@ lineNumber: lineNo + 1, | ||
} else { | ||
const replacement = rule.search | ||
? rule.replace | ||
: match.replace(new RegExp(regex), rule.replace); | ||
let replacement = null; | ||
if (typeof rule.replace !== "undefined") { | ||
replacement = rule.search | ||
? rule.replace | ||
: match.replace(new RegExp(regex), rule.replace); | ||
} | ||
report(rule, match, lineNo, columnNo, replacement); | ||
@@ -184,0 +187,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12683
170