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.0.10 to 1.1.0

.nvmrc

16

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

@@ -29,3 +29,3 @@ "main": "rule.js",

"engines": {
"node": ">=14"
"node": ">=14.18.0"
},

@@ -36,12 +36,12 @@ "dependencies": {

"devDependencies": {
"ava": "^5.0.1",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"ava": "5.2.0",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-jsdoc": "^40.0.0",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^46.0.0",
"markdownlint": "^0.28.0",
"prettier": "^2.7.1"
"markdownlint": "^0.28.1",
"prettier": "^2.8.7"
}
}

@@ -51,3 +51,3 @@ # markdownlint-rule-search-replace

"replace": "…",
"skipCode": true
"searchScope": "text"
},

@@ -75,3 +75,7 @@ {

- `replace`: Optional. The replacement string(s), 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.
- `searchScope` Optional. Scope to perform the search in.
- `all`: Default. Search in all Markdown content.
- `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.
- `skipCode`: Optional. All code(inline and block), which is inside backticks, will be skipped. _This property is deprecated use `searchScope` instead._

@@ -112,4 +116,4 @@ Properties are case-sensitive and are in camel case.\

"search": ["e-mail", "wtf", "web site"],
"replace": ["email", , "website"],
"skipCode": false
"replace": ["email", null, "website"],
"searchScope": "all"
}

@@ -116,0 +120,0 @@ ]

@@ -110,2 +110,28 @@ // @ts-check

/**
* Check rule definition.
*
* @param {Object} rule A rule object.
* @throws {Error} The error in rule definition.
*/
const validateRule = (rule) => {
if (!rule.search && !rule.searchPattern) {
throw new Error("Provide either `search` or `searchPattern` option.");
}
if (rule.searchScope !== undefined) {
if (rule.skipCode !== undefined) {
throw new Error(
"Both `searchScope` and `skipCode` specified, `skipCode` is deprecated, use `searchScope` instead."
);
}
if (!["all", "code", "text"].includes(rule.searchScope)) {
throw new Error(
`Invalid value \`${rule.searchScope}\` provided for \`searchScope\`, must be one of \`all\`, \`code\` or \`text\`.`
);
}
}
};
module.exports = {

@@ -179,5 +205,3 @@ names: ["search-replace"],

for (const rule of rules) {
if (!rule.search && !rule.searchPattern) {
throw new Error("Provide either `search` or `searchPattern` option.");
}
validateRule(rule);

@@ -189,5 +213,5 @@ const regex = rule.search

while ((result = regex.exec(content)) !== null) {
if (rule.skipCode && isCode(result.index, codeRanges, params.lines)) {
continue;
}
if (isCode(result.index, codeRanges, params.lines)) {
if (rule.skipCode || rule.searchScope === "text") continue;
} else if (rule.searchScope === "code") continue;

@@ -216,3 +240,3 @@ if (isHTMLComment(result.index, htmlCommentRanges, params.lines)) {

let replacement = null;
if (rule.replace !== undefined) {
if (rule.replace !== undefined && rule.replace !== null) {
replacement = rule.search

@@ -219,0 +243,0 @@ ? rule.replace

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