mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-08-18 00:00:26 +03:00
Remove remark-lint-no-auto-link-without-protocol
This commit is contained in:
parent
627363b2a2
commit
9cdda80913
@ -62,7 +62,6 @@
|
||||
"packages/remark-lint-list-item-spacing/",
|
||||
"packages/remark-lint-maximum-heading-length/",
|
||||
"packages/remark-lint-maximum-line-length/",
|
||||
"packages/remark-lint-no-auto-link-without-protocol/",
|
||||
"packages/remark-lint-no-blockquote-without-marker/",
|
||||
"packages/remark-lint-no-consecutive-blank-lines/",
|
||||
"packages/remark-lint-no-duplicate-defined-urls/",
|
||||
|
@ -1,2 +0,0 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,88 +0,0 @@
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* to do: remove.
|
||||
*
|
||||
* [api-remark-lint-no-auto-link-without-protocol]: #api
|
||||
*
|
||||
* @module no-auto-link-without-protocol
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
* @deprecated
|
||||
* **Stability: Legacy**.
|
||||
* This rule is no longer recommended for use.
|
||||
* With CommonMark, all autolinks (except for emails) are required to have a
|
||||
* protocol.
|
||||
* Otherwise they don’t parse.
|
||||
* The previous suggestion to add a protocol to email autolinks was wrong.
|
||||
*
|
||||
* @example
|
||||
* {"name": "ok.md"}
|
||||
*
|
||||
* <http://www.example.com>
|
||||
* <mailto:foo@bar.com>
|
||||
*
|
||||
* Most Markdown vendors don’t recognize the following as a link:
|
||||
* <www.example.com>
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "input"}
|
||||
*
|
||||
* <foo@bar.com>
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "output"}
|
||||
*
|
||||
* 1:1-1:14: All automatic links must start with a protocol
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {import('mdast').Root} Root
|
||||
*/
|
||||
|
||||
import {toString} from 'mdast-util-to-string'
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
import {pointEnd, pointStart} from 'unist-util-position'
|
||||
import {visit} from 'unist-util-visit'
|
||||
|
||||
// Protocol expression.
|
||||
// See: <https://en.wikipedia.org/wiki/URI_scheme#Generic_syntax>.
|
||||
const protocol = /^[a-z][a-z+.-]+:\/?/i
|
||||
|
||||
const remarkLintNoAutoLinkWithoutProtocol = lintRule(
|
||||
{
|
||||
origin: 'remark-lint:no-auto-link-without-protocol',
|
||||
url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-auto-link-without-protocol#readme'
|
||||
},
|
||||
/**
|
||||
* @param {Root} tree
|
||||
* Tree.
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
function (tree, file) {
|
||||
visit(tree, 'link', function (node) {
|
||||
const end = pointEnd(node)
|
||||
const headStart = pointStart(node.children[0])
|
||||
const start = pointStart(node)
|
||||
const tailEnd = pointEnd(node.children[node.children.length - 1])
|
||||
|
||||
if (
|
||||
end &&
|
||||
headStart &&
|
||||
start &&
|
||||
tailEnd &&
|
||||
end.column === tailEnd.column + 1 &&
|
||||
start.column === headStart.column - 1 &&
|
||||
!protocol.test(toString(node))
|
||||
) {
|
||||
file.message('All automatic links must start with a protocol', node)
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
export default remarkLintNoAutoLinkWithoutProtocol
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "remark-lint-no-auto-link-without-protocol",
|
||||
"version": "3.1.2",
|
||||
"description": "Deprecated",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"auto",
|
||||
"link",
|
||||
"lint",
|
||||
"protocol",
|
||||
"remark",
|
||||
"remark-lint",
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-auto-link-without-protocol",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.d.ts.map",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/mdast": "^4.0.0",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"unified-lint-rule": "^2.0.0",
|
||||
"unist-util-position": "^5.0.0",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
"scripts": {},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"ignoreCatch": true,
|
||||
"strict": true
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"capitalized-comments": "off",
|
||||
"unicorn/prefer-at": "off"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,212 +0,0 @@
|
||||
<!--This file is generated-->
|
||||
|
||||
# remark-lint-no-auto-link-without-protocol
|
||||
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
Deprecated.
|
||||
|
||||
## Contents
|
||||
|
||||
* [Presets](#presets)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## Presets
|
||||
|
||||
This plugin is not included in presets maintained here.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-no-auto-link-without-protocol
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintNoAutoLinkWithoutProtocol from 'https://esm.sh/remark-lint-no-auto-link-without-protocol@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import remarkLintNoAutoLinkWithoutProtocol from 'https://esm.sh/remark-lint-no-auto-link-without-protocol@3?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintNoAutoLinkWithoutProtocol from 'remark-lint-no-auto-link-without-protocol'
|
||||
import remarkParse from 'remark-parse'
|
||||
import remarkStringify from 'remark-stringify'
|
||||
import {read} from 'to-vfile'
|
||||
import {unified} from 'unified'
|
||||
import {reporter} from 'vfile-reporter'
|
||||
|
||||
const file = await read('example.md')
|
||||
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintNoAutoLinkWithoutProtocol)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
```
|
||||
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --frail --use remark-lint --use remark-lint-no-auto-link-without-protocol .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
|
||||
```diff
|
||||
…
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
…
|
||||
"remark-lint",
|
||||
+ "remark-lint-no-auto-link-without-protocol",
|
||||
…
|
||||
]
|
||||
}
|
||||
…
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintNoAutoLinkWithoutProtocol`][api-remark-lint-no-auto-link-without-protocol].
|
||||
|
||||
to do: remove.
|
||||
|
||||
## Examples
|
||||
|
||||
##### `ok.md`
|
||||
|
||||
###### In
|
||||
|
||||
```markdown
|
||||
<http://www.example.com>
|
||||
<mailto:foo@bar.com>
|
||||
|
||||
Most Markdown vendors don’t recognize the following as a link:
|
||||
<www.example.com>
|
||||
```
|
||||
|
||||
###### Out
|
||||
|
||||
No messages.
|
||||
|
||||
##### `not-ok.md`
|
||||
|
||||
###### In
|
||||
|
||||
```markdown
|
||||
<foo@bar.com>
|
||||
```
|
||||
|
||||
###### Out
|
||||
|
||||
```text
|
||||
1:1-1:14: All automatic links must start with a protocol
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
|
||||
When we cut a new major release, we drop support for unmaintained versions of
|
||||
Node.
|
||||
This means we try to keep the current release line,
|
||||
`remark-lint-no-auto-link-without-protocol@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[api-remark-lint-no-auto-link-without-protocol]: #api
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-no-auto-link-without-protocol.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-no-auto-link-without-protocol
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-no-auto-link-without-protocol
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-no-auto-link-without-protocol
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json"
|
||||
}
|
Loading…
Reference in New Issue
Block a user