remark-lint-table-cell-padding
Advanced tools
Comparing version 4.1.1 to 4.1.2
53
index.js
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module table-cell-padding | ||
* @fileoverview | ||
* Warn when table cells are incorrectly padded. | ||
* ## When should I use this? | ||
* | ||
* Options: `'consistent'`, `'padded'`, or `'compact'`, default: `'consistent'`. | ||
* You can use this package to check that table cells are padded consistently. | ||
* Tables are a GFM feature enabled with | ||
* [`remark-gfm`](https://github.com/remarkjs/remark-gfm). | ||
* | ||
* `'consistent'` detects the first used cell padding style and warns when | ||
* subsequent cells use different styles. | ||
* ## API | ||
* | ||
* ## Fix | ||
* The following options (default: `'consistent'`) are accepted: | ||
* | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) | ||
* formats tables with padding by default. | ||
* Pass | ||
* [`spacedTable: false`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsspacedtable) | ||
* to not use padding. | ||
* * `'padded'` | ||
* — prefer at least one space between pipes and content | ||
* * `'compact'` | ||
* — prefer zero spaces between pipes and content | ||
* * `'consistent'` | ||
* — detect the first used style and warn when further tables differ | ||
* | ||
* 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. | ||
* ## Recommendation | ||
* | ||
* It’s recommended to use at least one space between pipes and content for | ||
* legibility of the markup (`'padded'`). | ||
* | ||
* ## Fix | ||
* | ||
* [`remark-gfm`](https://github.com/remarkjs/remark-gfm) | ||
* formats all table cells as padded by default. | ||
* Pass | ||
* [`tableCellPadding: false`](https://github.com/remarkjs/remark-gfm#optionstablecellpadding) | ||
* to use a more compact style. | ||
* | ||
* @module table-cell-padding | ||
* @summary | ||
* remark-lint rule to warn when table cells are inconsistently padded. | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @example | ||
@@ -215,5 +228,5 @@ * {"name": "ok.md", "setting": "padded", "gfm": true} | ||
const align = node.align || [] | ||
/** @type {number[]} */ | ||
/** @type {Array<number>} */ | ||
const sizes = [] | ||
/** @type {Entry[]} */ | ||
/** @type {Array<Entry>} */ | ||
const entries = [] | ||
@@ -298,3 +311,3 @@ let index = -1 | ||
* @param {0|1} style | ||
* @param {number[]} sizes | ||
* @param {Array<number>} sizes | ||
*/ | ||
@@ -301,0 +314,0 @@ function checkSide(side, entry, style, sizes) { |
{ | ||
"name": "remark-lint-table-cell-padding", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "remark-lint rule to warn when table cells are incorrectly padded", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
228
readme.md
@@ -13,20 +13,32 @@ <!--This file is generated--> | ||
Warn when table cells are incorrectly padded. | ||
[`remark-lint`][mono] rule to warn when table cells are inconsistently padded. | ||
Options: `'consistent'`, `'padded'`, or `'compact'`, default: `'consistent'`. | ||
## Contents | ||
`'consistent'` detects the first used cell padding style and warns when | ||
subsequent cells use different styles. | ||
* [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(remarkLintTableCellPadding[, config])`](#unifieduseremarklinttablecellpadding-config) | ||
* [Recommendation](#recommendation) | ||
* [Fix](#fix) | ||
* [Examples](#examples) | ||
* [Compatibility](#compatibility) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
## Fix | ||
## What is this? | ||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify) | ||
formats tables with padding by default. | ||
Pass | ||
[`spacedTable: false`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsspacedtable) | ||
to not use padding. | ||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint` | ||
rule. | ||
Lint rules check markdown code style. | ||
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. | ||
## When should I use this? | ||
You can use this package to check that table cells are padded consistently. | ||
Tables are a GFM feature enabled with | ||
[`remark-gfm`](https://github.com/remarkjs/remark-gfm). | ||
## Presets | ||
@@ -41,4 +53,103 @@ | ||
## 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-table-cell-padding | ||
``` | ||
In Deno with [Skypack][]: | ||
```js | ||
import remarkLintTableCellPadding from 'https://cdn.skypack.dev/remark-lint-table-cell-padding@4?dts' | ||
``` | ||
In browsers with [Skypack][]: | ||
```html | ||
<script type="module"> | ||
import remarkLintTableCellPadding from 'https://cdn.skypack.dev/remark-lint-table-cell-padding@4?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 remarkLintTableCellPadding from 'remark-lint-table-cell-padding' | ||
main() | ||
async function main() { | ||
const file = await remark() | ||
.use(remarkLint) | ||
.use(remarkLintTableCellPadding) | ||
.process(await read('example.md')) | ||
console.error(reporter(file)) | ||
} | ||
``` | ||
On the CLI: | ||
```sh | ||
remark --use remark-lint --use remark-lint-table-cell-padding example.md | ||
``` | ||
On the CLI in a config file (here a `package.json`): | ||
```diff | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
… | ||
"remark-lint", | ||
+ "remark-lint-table-cell-padding", | ||
… | ||
] | ||
} | ||
… | ||
``` | ||
## API | ||
This package exports no identifiers. | ||
The default export is `remarkLintTableCellPadding`. | ||
### `unified().use(remarkLintTableCellPadding[, 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). | ||
The following options (default: `'consistent'`) are accepted: | ||
* `'padded'` | ||
— prefer at least one space between pipes and content | ||
* `'compact'` | ||
— prefer zero spaces between pipes and content | ||
* `'consistent'` | ||
— detect the first used style and warn when further tables differ | ||
## Recommendation | ||
It’s recommended to use at least one space between pipes and content for | ||
legibility of the markup (`'padded'`). | ||
## Fix | ||
[`remark-gfm`](https://github.com/remarkjs/remark-gfm) | ||
formats all table cells as padded by default. | ||
Pass | ||
[`tableCellPadding: false`](https://github.com/remarkjs/remark-gfm#optionstablecellpadding) | ||
to use a more compact style. | ||
## Examples | ||
##### `ok.md` | ||
@@ -50,3 +161,3 @@ | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -69,3 +180,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -108,3 +219,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -133,3 +244,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -155,3 +266,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -174,3 +285,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -201,3 +312,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -224,3 +335,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -249,3 +360,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -272,3 +383,3 @@ ```markdown | ||
Note: this example uses [GFM][]. | ||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]). | ||
@@ -301,56 +412,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-table-cell-padding | ||
``` | ||
This package exports no identifiers. | ||
The default export is `remarkLintTableCellPadding`. | ||
## Use | ||
You probably want to use it on the CLI through a config file: | ||
```diff | ||
… | ||
"remarkConfig": { | ||
"plugins": [ | ||
… | ||
"lint", | ||
+ "lint-table-cell-padding", | ||
… | ||
] | ||
} | ||
… | ||
``` | ||
Or use it on the CLI directly | ||
```sh | ||
remark -u lint -u lint-table-cell-padding readme.md | ||
``` | ||
Or use this on the API: | ||
```diff | ||
import {remark} from 'remark' | ||
import {reporter} from 'vfile-reporter' | ||
import remarkLint from 'remark-lint' | ||
import remarkLintTableCellPadding from 'remark-lint-table-cell-padding' | ||
remark() | ||
.use(remarkLint) | ||
+ .use(remarkLintTableCellPadding) | ||
.process('_Emphasis_ and **importance**') | ||
.then((file) => { | ||
console.error(reporter(file)) | ||
}) | ||
``` | ||
## Contribute | ||
@@ -396,4 +460,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 | ||
@@ -403,7 +475,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 | ||
@@ -410,0 +482,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
21934
382
472