You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

remark-lint-no-duplicate-defined-urls

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-no-duplicate-defined-urls - npm Package Compare versions

Comparing version

to
2.0.0

index.d.ts

70

index.js

@@ -9,3 +9,4 @@ /**

*
* @example {"name": "ok.md"}
* @example
* {"name": "ok.md"}
*

@@ -15,3 +16,4 @@ * [alpha]: alpha.com

*
* @example {"name": "not-ok.md", "label": "input"}
* @example
* {"name": "not-ok.md", "label": "input"}
*

@@ -21,3 +23,4 @@ * [alpha]: alpha.com

*
* @example {"name": "not-ok.md", "label": "output"}
* @example
* {"name": "not-ok.md", "label": "output"}
*

@@ -27,40 +30,39 @@ * 2:1-2:19: Do not use different definitions with the same URL (1:1)

'use strict'
/**
* @typedef {import('mdast').Root} Root
*/
var rule = require('unified-lint-rule')
var position = require('unist-util-position')
var generated = require('unist-util-generated')
var stringify = require('unist-util-stringify-position')
var visit = require('unist-util-visit')
import {lintRule} from 'unified-lint-rule'
import {pointStart} from 'unist-util-position'
import {generated} from 'unist-util-generated'
import {stringifyPosition} from 'unist-util-stringify-position'
import {visit} from 'unist-util-visit'
module.exports = rule(
const remarkLintNoDuplicateDefinedUrls = lintRule(
'remark-lint:no-duplicate-defined-urls',
noDuplicateDefinedUrls
)
/** @type {import('unified-lint-rule').Rule<Root, void>} */
(tree, file) => {
/** @type {Record<string, string>} */
const map = Object.create(null)
var reason = 'Do not use different definitions with the same URL'
visit(tree, 'definition', (node) => {
if (!generated(node) && node.url) {
const url = String(node.url).toUpperCase()
const duplicate = map[url]
function noDuplicateDefinedUrls(tree, file) {
var map = {}
if (duplicate) {
file.message(
'Do not use different definitions with the same URL (' +
duplicate +
')',
node
)
}
visit(tree, 'definition', check)
function check(node) {
var url
var duplicate
if (!generated(node) && node.url) {
url = String(node.url).toUpperCase()
duplicate = map[url]
if (duplicate && duplicate.type) {
file.message(
reason + ' (' + stringify(position.start(duplicate)) + ')',
node
)
map[url] = stringifyPosition(pointStart(node))
}
})
}
)
map[url] = node
}
}
}
export default remarkLintNoDuplicateDefinedUrls
{
"name": "remark-lint-no-duplicate-defined-urls",
"version": "1.0.1",
"version": "2.0.0",
"description": "remark-lint rule to warn on definitions that define the same urls",

@@ -25,13 +25,29 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"unified-lint-rule": "^1.0.0",
"unist-util-generated": "^1.0.0",
"unist-util-position": "^3.0.0",
"unist-util-stringify-position": "^2.0.0",
"unist-util-visit": "^2.0.0"
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-position": "^4.0.0",
"unist-util-stringify-position": "^3.0.0",
"unist-util-visit": "^4.0.0"
},
"xo": false
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage"
},
"xo": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -51,2 +51,5 @@ <!--This file is generated-->

This package is [ESM only][esm]:
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
[npm][]:

@@ -58,2 +61,5 @@

This package exports no identifiers.
The default export is `remarkLintNoDuplicateDefinedUrls`.
## Use

@@ -85,10 +91,13 @@

```diff
var remark = require('remark')
var report = require('vfile-reporter')
import {remark} from 'remark'
import {reporter} from 'vfile-reporter'
import remarkLint from 'remark-lint'
import remarkLintNoDuplicateDefinedUrls from 'remark-lint-no-duplicate-defined-urls'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-no-duplicate-defined-urls'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintNoDuplicateDefinedUrls)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -111,5 +120,5 @@ ```

[build-badge]: https://img.shields.io/travis/remarkjs/remark-lint/main.svg
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
[build]: https://travis-ci.org/remarkjs/remark-lint
[build]: https://github.com/remarkjs/remark-lint/actions

@@ -134,6 +143,8 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg

[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://spectrum.chat/unified/remark
[chat]: https://github.com/remarkjs/remark/discussions
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install

@@ -140,0 +151,0 @@