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

remark-lint-table-cell-padding

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-table-cell-padding

remark-lint rule to warn when table cells are incorrectly padded

  • 4.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78K
decreased by-26.4%
Maintainers
2
Weekly downloads
 
Created
Source

remark-lint-table-cell-padding

Build Coverage Downloads Size Sponsors Backers Chat

remark-lint rule to warn when table cells are inconsistently padded.

Contents

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 table cells are padded consistently. Tables are a GFM feature enabled with remark-gfm.

Presets

This rule is included in the following presets:

PresetSetting
remark-preset-lint-consistent'consistent'
remark-preset-lint-markdown-style-guide'padded'

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install remark-lint-table-cell-padding

In Deno with Skypack:

import remarkLintTableCellPadding from 'https://cdn.skypack.dev/remark-lint-table-cell-padding@4?dts'

In browsers with Skypack:

<script type="module">
  import remarkLintTableCellPadding from 'https://cdn.skypack.dev/remark-lint-table-cell-padding@4?min'
</script>

Use

On the API:

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:

remark --use remark-lint --use remark-lint-table-cell-padding example.md

On the CLI in a config file (here a package.json):

 …
 "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 formats all table cells as padded by default. Pass tableCellPadding: false to use a more compact style.

Examples

ok.md

When configured with 'padded'.

In

👉 Note: this example uses GFM (remark-gfm).

| A     | B     |
| ----- | ----- |
| Alpha | Bravo |
Out

No messages.

not-ok.md

When configured with 'padded'.

In

👉 Note: this example uses GFM (remark-gfm).

| A    |    B |
| :----|----: |
| Alpha|Bravo |

| C      |    D |
| :----- | ---: |
|Charlie | Delta|

Too much padding isn’t good either:

| E     | F        |   G    |      H |
| :---- | -------- | :----: | -----: |
| Echo  | Foxtrot  |  Golf  |  Hotel |
Out
3:8: Cell should be padded
3:9: Cell should be padded
7:2: Cell should be padded
7:17: Cell should be padded
13:9: Cell should be padded with 1 space, not 2
13:20: Cell should be padded with 1 space, not 2
13:21: Cell should be padded with 1 space, not 2
13:29: Cell should be padded with 1 space, not 2
13:30: Cell should be padded with 1 space, not 2
empty.md

When configured with 'padded'.

In

👉 Note: this example uses GFM (remark-gfm).

<!-- Empty cells are OK, but those surrounding them may not be. -->

|        | Alpha | Bravo|
| ------ | ----- | ---: |
| Charlie|       |  Echo|
Out
3:25: Cell should be padded
5:10: Cell should be padded
5:25: Cell should be padded
missing-body.md

When configured with 'padded'.

In

👉 Note: this example uses GFM (remark-gfm).

<!-- Missing cells are fine as well. -->

| Alpha | Bravo   | Charlie |
| ----- | ------- | ------- |
| Delta |
| Echo  | Foxtrot |
Out

No messages.

ok.md

When configured with 'compact'.

In

👉 Note: this example uses GFM (remark-gfm).

|A    |B    |
|-----|-----|
|Alpha|Bravo|
Out

No messages.

not-ok.md

When configured with 'compact'.

In

👉 Note: this example uses GFM (remark-gfm).

|   A    | B    |
|   -----| -----|
|   Alpha| Bravo|

|C      |     D|
|:------|-----:|
|Charlie|Delta |
Out
3:2: Cell should be compact
3:11: Cell should be compact
7:16: Cell should be compact
ok-padded.md

When configured with 'consistent'.

In

👉 Note: this example uses GFM (remark-gfm).

| A     | B     |
| ----- | ----- |
| Alpha | Bravo |

| C       | D     |
| ------- | ----- |
| Charlie | Delta |
Out

No messages.

not-ok-padded.md

When configured with 'consistent'.

In

👉 Note: this example uses GFM (remark-gfm).

| A     | B     |
| ----- | ----- |
| Alpha | Bravo |

| C      |     D |
| :----- | ----: |
|Charlie | Delta |
Out
7:2: Cell should be padded
ok-compact.md

When configured with 'consistent'.

In

👉 Note: this example uses GFM (remark-gfm).

|A    |B    |
|-----|-----|
|Alpha|Bravo|

|C      |D    |
|-------|-----|
|Charlie|Delta|
Out

No messages.

not-ok-compact.md

When configured with 'consistent'.

In

👉 Note: this example uses GFM (remark-gfm).

|A    |B    |
|-----|-----|
|Alpha|Bravo|

|C      |     D|
|:------|-----:|
|Charlie|Delta |
Out
7:16: Cell should be compact
not-ok.md

When configured with '💩'.

Out
1:1: Incorrect table cell padding style `💩`, expected `'padded'`, `'compact'`, or `'consistent'`

Compatibility

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.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 03 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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