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

remark-lint-no-literal-urls

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-no-literal-urls - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

index.d.ts

64

index.js

@@ -21,11 +21,14 @@ /**

*
* @example {"name": "ok.md"}
* @example
* {"name": "ok.md"}
*
* <http://foo.bar/baz>
*
* @example {"name": "not-ok.md", "label": "input"}
* @example
* {"name": "not-ok.md", "label": "input", "gfm": true}
*
* http://foo.bar/baz
*
* @example {"name": "not-ok.md", "label": "output"}
* @example
* {"name": "not-ok.md", "label": "output", "gfm": true}
*

@@ -35,33 +38,32 @@ * 1:1-1:19: Don’t use literal URLs without angle brackets

'use strict'
/**
* @typedef {import('mdast').Root} Root
*/
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var position = require('unist-util-position')
var generated = require('unist-util-generated')
var toString = require('mdast-util-to-string')
import {lintRule} from 'unified-lint-rule'
import {visit} from 'unist-util-visit'
import {pointStart, pointEnd} from 'unist-util-position'
import {generated} from 'unist-util-generated'
import {toString} from 'mdast-util-to-string'
module.exports = rule('remark-lint:no-literal-urls', noLiteralURLs)
const remarkLintNoLiteralUrls = lintRule(
'remark-lint:no-literal-urls',
/** @type {import('unified-lint-rule').Rule<Root, void>} */
(tree, file) => {
visit(tree, 'link', (node) => {
const value = toString(node)
var start = position.start
var end = position.end
var mailto = 'mailto:'
var reason = 'Don’t use literal URLs without angle brackets'
if (
!generated(node) &&
pointStart(node).column === pointStart(node.children[0]).column &&
pointEnd(node).column ===
pointEnd(node.children[node.children.length - 1]).column &&
(node.url === 'mailto:' + value || node.url === value)
) {
file.message('Don’t use literal URLs without angle brackets', node)
}
})
}
)
function noLiteralURLs(tree, file) {
visit(tree, 'link', visitor)
function visitor(node) {
var children = node.children
var value = toString(node)
if (
!generated(node) &&
start(node).column === start(children[0]).column &&
end(node).column === end(children[children.length - 1]).column &&
(node.url === mailto + value || node.url === value)
) {
file.message(reason, node)
}
}
}
export default remarkLintNoLiteralUrls
{
"name": "remark-lint-no-literal-urls",
"version": "2.0.1",
"version": "3.0.0",
"description": "remark-lint rule to warn when URLs without angle brackets are used",

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

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"mdast-util-to-string": "^1.0.2",
"unified-lint-rule": "^1.0.0",
"unist-util-generated": "^1.1.0",
"unist-util-position": "^3.0.0",
"unist-util-visit": "^2.0.0"
"@types/mdast": "^3.0.0",
"mdast-util-to-string": "^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-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
}
}

@@ -54,2 +54,4 @@ <!--This file is generated-->

Note: this example uses [GFM][].
```markdown

@@ -67,2 +69,5 @@ http://foo.bar/baz

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

@@ -74,2 +79,5 @@

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

@@ -101,10 +109,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 remarkLintNoLiteralUrls from 'remark-lint-no-literal-urls'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-no-literal-urls'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintNoLiteralUrls)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -127,5 +138,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

@@ -150,6 +161,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

@@ -168,1 +181,3 @@

[author]: https://wooorm.com
[gfm]: https://github.com/remarkjs/remark-gfm
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