remark-lint-no-tabs
Advanced tools
Comparing version 3.1.0 to 3.1.1
export default remarkLintNoTabs | ||
export type Root = import('mdast').Root | ||
declare const remarkLintNoTabs: import('unified').Plugin< | ||
| void[] | ||
| [unknown] | ||
| void[] | ||
| [ | ||
( | ||
| boolean | ||
| import('unified-lint-rule').Label | ||
| import('unified-lint-rule').Severity | ||
| import('unified-lint-rule').Label | ||
), | ||
@@ -12,0 +12,0 @@ unknown |
62
index.js
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module no-tabs | ||
* @fileoverview | ||
* Warn when hard tabs (`\t`) are used instead of spaces. | ||
* ## When should I use this? | ||
* | ||
* ## Fix | ||
* You can use this package to check that tabs are not used. | ||
* | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) | ||
* uses spaces where tabs are used for indentation, but retains tabs used in | ||
* content. | ||
* ## API | ||
* | ||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) | ||
* on how to automatically fix warnings for this rule. | ||
* There are no options. | ||
* | ||
* ## Recommendation | ||
* | ||
* Regardless of the debate in other languages of whether to use tabs vs. | ||
* spaces, when it comes to markdown, tabs do not work as expected. | ||
* Largely around contains such as block quotes and lists. | ||
* Take for example block quotes: `>\ta` gives a paragraph with the text `a` | ||
* in a blockquote, so one might expect that `>\t\ta` results in indented code | ||
* with the text `a` in a block quote. | ||
* | ||
* ```markdown | ||
* >\ta | ||
* | ||
* >\t\ta | ||
* ``` | ||
* | ||
* Yields: | ||
* | ||
* ```html | ||
* <blockquote> | ||
* <p>a</p> | ||
* </blockquote> | ||
* <blockquote> | ||
* <pre><code> a | ||
* </code></pre> | ||
* </blockquote> | ||
* ``` | ||
* | ||
* Because markdown uses a hardcoded tab size of 4, the first tab could be | ||
* represented as 3 spaces (because there’s a `>` before). | ||
* One of those “spaces” is taken because block quotes allow the `>` to be | ||
* followed by one space, leaving 2 spaces. | ||
* The next tab can be represented as 4 spaces, so together we have 6 spaces. | ||
* The indented code uses 4 spaces, so there are two spaces left, which are | ||
* shown in the indented code. | ||
* | ||
* ## Fix | ||
* | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) | ||
* uses spaces exclusively for indentation. | ||
* | ||
* @module no-tabs | ||
* @summary | ||
* remark-lint rule to warn when tabs are used. | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @example | ||
@@ -19,0 +57,0 @@ * {"name": "ok.md"} |
{ | ||
"name": "remark-lint-no-tabs", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "remark-lint rule to warn when hard tabs are used instead of spaces", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
229
readme.md
@@ -13,19 +13,155 @@ <!--This file is generated--> | ||
Warn when hard tabs (`\t`) are used instead of spaces. | ||
[`remark-lint`][mono] rule to warn when tabs are used. | ||
## Fix | ||
## Contents | ||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) | ||
uses spaces where tabs are used for indentation, but retains tabs used in | ||
content. | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Presets](#presets) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`unified().use(remarkLintNoTabs[, config])`](#unifieduseremarklintnotabs-config) | ||
* [Recommendation](#recommendation) | ||
* [Fix](#fix) | ||
* [Examples](#examples) | ||
* [Compatibility](#compatibility) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown) | ||
on how to automatically fix warnings for this rule. | ||
## What is this? | ||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint` | ||
rule. | ||
Lint rules check markdown code style. | ||
## When should I use this? | ||
You can use this package to check that tabs are not used. | ||
## Presets | ||
This rule is not included in any default preset | ||
This rule is not included in a preset maintained here. | ||
## Example | ||
## Install | ||
This package is [ESM only][esm]. | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
```sh | ||
npm install remark-lint-no-tabs | ||
``` | ||
In Deno with [Skypack][]: | ||
```js | ||
import remarkLintNoTabs from 'https://cdn.skypack.dev/remark-lint-no-tabs@3?dts' | ||
``` | ||
In browsers with [Skypack][]: | ||
```html | ||
<script type="module"> | ||
import remarkLintNoTabs from 'https://cdn.skypack.dev/remark-lint-no-tabs@3?min' | ||
</script> | ||
``` | ||
## Use | ||
On the API: | ||
```js | ||
import {read} from 'to-vfile' | ||
import {reporter} from 'vfile-reporter' | ||
import {remark} from 'remark' | ||
import remarkLint from 'remark-lint' | ||
import remarkLintNoTabs from 'remark-lint-no-tabs' | ||
main() | ||
async function main() { | ||
const file = await remark() | ||
.use(remarkLint) | ||
.use(remarkLintNoTabs) | ||
.process(await read('example.md')) | ||
console.error(reporter(file)) | ||
} | ||
``` | ||
On the CLI: | ||
```sh | ||
remark --use remark-lint --use remark-lint-no-tabs example.md | ||
``` | ||
On the CLI in a config file (here a `package.json`): | ||
```diff | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
… | ||
"remark-lint", | ||
+ "remark-lint-no-tabs", | ||
… | ||
] | ||
} | ||
… | ||
``` | ||
## API | ||
This package exports no identifiers. | ||
The default export is `remarkLintNoTabs`. | ||
### `unified().use(remarkLintNoTabs[, config])` | ||
This rule supports standard configuration that all remark lint rules accept | ||
(such as `false` to turn it off or `[1, options]` to configure it). | ||
There are no options. | ||
## Recommendation | ||
Regardless of the debate in other languages of whether to use tabs vs. | ||
spaces, when it comes to markdown, tabs do not work as expected. | ||
Largely around contains such as block quotes and lists. | ||
Take for example block quotes: `>\ta` gives a paragraph with the text `a` | ||
in a blockquote, so one might expect that `>\t\ta` results in indented code | ||
with the text `a` in a block quote. | ||
```markdown | ||
>\ta | ||
>\t\ta | ||
``` | ||
Yields: | ||
```html | ||
<blockquote> | ||
<p>a</p> | ||
</blockquote> | ||
<blockquote> | ||
<pre><code> a | ||
</code></pre> | ||
</blockquote> | ||
``` | ||
Because markdown uses a hardcoded tab size of 4, the first tab could be | ||
represented as 3 spaces (because there’s a `>` before). | ||
One of those “spaces” is taken because block quotes allow the `>` to be | ||
followed by one space, leaving 2 spaces. | ||
The next tab can be represented as 4 spaces, so together we have 6 spaces. | ||
The indented code uses 4 spaces, so there are two spaces left, which are | ||
shown in the indented code. | ||
## Fix | ||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) | ||
uses spaces exclusively for indentation. | ||
## Examples | ||
##### `ok.md` | ||
@@ -35,3 +171,3 @@ | ||
Note: `·` represents a space. | ||
> 👉 **Note**: `·` represents a space. | ||
@@ -52,3 +188,3 @@ ```markdown | ||
Note: `»` represents a tab. | ||
> 👉 **Note**: `»` represents a tab. | ||
@@ -85,56 +221,9 @@ ```markdown | ||
## Install | ||
## Compatibility | ||
This package is [ESM only][esm]: | ||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d. | ||
Projects maintained by the unified collective are compatible with all maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
[npm][]: | ||
```sh | ||
npm install remark-lint-no-tabs | ||
``` | ||
This package exports no identifiers. | ||
The default export is `remarkLintNoTabs`. | ||
## Use | ||
You probably want to use it on the CLI through a config file: | ||
```diff | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
… | ||
"lint", | ||
+ "lint-no-tabs", | ||
… | ||
] | ||
} | ||
… | ||
``` | ||
Or use it on the CLI directly | ||
```sh | ||
remark -u lint -u lint-no-tabs readme.md | ||
``` | ||
Or use this on the API: | ||
```diff | ||
import {remark} from 'remark' | ||
import {reporter} from 'vfile-reporter' | ||
import remarkLint from 'remark-lint' | ||
import remarkLintNoTabs from 'remark-lint-no-tabs' | ||
remark() | ||
.use(remarkLint) | ||
+ .use(remarkLintNoTabs) | ||
.process('_Emphasis_ and **importance**') | ||
.then((file) => { | ||
console.error(reporter(file)) | ||
}) | ||
``` | ||
## Contribute | ||
@@ -180,4 +269,12 @@ | ||
[unified]: https://github.com/unifiedjs/unified | ||
[remark]: https://github.com/remarkjs/remark | ||
[mono]: https://github.com/remarkjs/remark-lint | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[skypack]: https://www.skypack.dev | ||
[npm]: https://docs.npmjs.com/cli/install | ||
@@ -187,7 +284,7 @@ | ||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
@@ -194,0 +291,0 @@ [license]: https://github.com/remarkjs/remark-lint/blob/main/license |
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
11151
130
288