Socket
Socket
Sign inDemoInstall

remark-lint-checkbox-character-style

Package Overview
Dependencies
10
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

48

index.js

@@ -17,3 +17,3 @@ /**

* ```js
* { checked: 'x', unchecked: ' ' }
* {checked: 'x', unchecked: ' '}
* ```

@@ -30,3 +30,3 @@ *

*
* @example {"name": "valid.md", "setting": {"checked": "x"}}
* @example {"name": "ok.md", "setting": {"checked": "x"}}
*

@@ -36,3 +36,3 @@ * - [x] List item

*
* @example {"name": "valid.md", "setting": {"checked": "X"}}
* @example {"name": "ok.md", "setting": {"checked": "X"}}
*

@@ -42,3 +42,3 @@ * - [X] List item

*
* @example {"name": "valid.md", "setting": {"unchecked": " "}}
* @example {"name": "ok.md", "setting": {"unchecked": " "}}
*

@@ -50,3 +50,3 @@ * - [ ] List item

*
* @example {"name": "valid.md", "setting": {"unchecked": "\t"}}
* @example {"name": "ok.md", "setting": {"unchecked": "\t"}}
*

@@ -56,3 +56,3 @@ * - [»] List item

*
* @example {"name": "invalid.md", "label": "input"}
* @example {"name": "not-ok.md", "label": "input"}
*

@@ -64,3 +64,3 @@ * - [x] List item

*
* @example {"name": "invalid.md", "label": "output"}
* @example {"name": "not-ok.md", "label": "output"}
*

@@ -70,9 +70,9 @@ * 2:4-2:5: Checked checkboxes should use `x` as a marker

*
* @example {"setting": {"unchecked": "!"}, "name": "invalid.md", "label": "output", "config": {"positionless": true}}
* @example {"setting": {"unchecked": "💩"}, "name": "not-ok.md", "label": "output", "config": {"positionless": true}}
*
* 1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '`
* 1:1: Incorrect unchecked checkbox marker `💩`: use either `'\t'`, or `' '`
*
* @example {"setting": {"checked": "!"}, "name": "invalid.md", "label": "output", "config": {"positionless": true}}
* @example {"setting": {"checked": "💩"}, "name": "not-ok.md", "label": "output", "config": {"positionless": true}}
*
* 1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'`
* 1:1: Incorrect checked checkbox marker `💩`: use either `'x'`, or `'X'`
*/

@@ -100,12 +100,11 @@

function checkboxCharacterStyle(tree, file, pref) {
function checkboxCharacterStyle(tree, file, option) {
var contents = String(file)
var location = vfileLocation(file)
var preferred = typeof option === 'object' ? option : {}
pref = typeof pref === 'object' ? pref : {}
if (pref.unchecked && unchecked[pref.unchecked] !== true) {
if (preferred.unchecked && unchecked[preferred.unchecked] !== true) {
file.fail(
'Invalid unchecked checkbox marker `' +
pref.unchecked +
'Incorrect unchecked checkbox marker `' +
preferred.unchecked +
"`: use either `'\\t'`, or `' '`"

@@ -115,6 +114,6 @@ )

if (pref.checked && checked[pref.checked] !== true) {
if (preferred.checked && checked[preferred.checked] !== true) {
file.fail(
'Invalid checked checkbox marker `' +
pref.checked +
'Incorrect checked checkbox marker `' +
preferred.checked +
"`: use either `'x'`, or `'X'`"

@@ -146,10 +145,7 @@ )

// For a checkbox to be parsed, it must be followed by a whitespace.
value = contents
.slice(initial, final)
.trimRight()
.slice(0, -1)
value = contents.slice(initial, final).replace(/\s+$/, '').slice(0, -1)
// The checkbox character is behind a square bracket.
character = value.charAt(value.length - 1)
style = pref[type]
style = preferred[type]

@@ -171,5 +167,5 @@ if (style) {

} else {
pref[type] = character
preferred[type] = character
}
}
}
{
"name": "remark-lint-checkbox-character-style",
"version": "1.0.3",
"version": "1.0.4",
"description": "remark-lint rule to warn when list item checkboxes violate a given style",

@@ -10,2 +10,3 @@ "license": "MIT",

"rule",
"remark-lint-rule",
"checkbox",

@@ -18,2 +19,6 @@ "style",

"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)",

@@ -20,0 +25,0 @@ "contributors": [

@@ -23,3 +23,3 @@ <!--This file is generated-->

```js
{ checked: 'x', unchecked: ' ' }
{checked: 'x', unchecked: ' '}
```

@@ -46,3 +46,3 @@

##### `valid.md`
##### `ok.md`

@@ -62,3 +62,3 @@ When configured with `{ checked: 'x' }`.

##### `valid.md`
##### `ok.md`

@@ -78,3 +78,3 @@ When configured with `{ checked: 'X' }`.

##### `valid.md`
##### `ok.md`

@@ -98,3 +98,3 @@ When configured with `{ unchecked: ' ' }`.

##### `valid.md`
##### `ok.md`

@@ -116,3 +116,3 @@ When configured with `{ unchecked: '\t' }`.

##### `invalid.md`
##### `not-ok.md`

@@ -137,5 +137,5 @@ ###### In

##### `invalid.md`
##### `not-ok.md`
When configured with `{ unchecked: '!' }`.
When configured with `{ unchecked: '💩' }`.

@@ -145,8 +145,8 @@ ###### Out

```text
1:1: Invalid unchecked checkbox marker `!`: use either `'\t'`, or `' '`
1:1: Incorrect unchecked checkbox marker `💩`: use either `'\t'`, or `' '`
```
##### `invalid.md`
##### `not-ok.md`
When configured with `{ checked: '!' }`.
When configured with `{ checked: '💩' }`.

@@ -156,3 +156,3 @@ ###### Out

```text
1:1: Invalid checked checkbox marker `!`: use either `'x'`, or `'X'`
1:1: Incorrect checked checkbox marker `💩`: use either `'x'`, or `'X'`
```

@@ -173,12 +173,12 @@

```diff
...
"remarkConfig": {
"plugins": [
...
"lint",
+ "lint-checkbox-character-style",
...
]
}
...
```

@@ -195,4 +195,4 @@

```diff
var remark = require('remark');
var report = require('vfile-reporter');
var remark = require('remark')
var report = require('vfile-reporter')

@@ -203,4 +203,4 @@ remark()

.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file));
});
console.error(report(err || file))
})
```

@@ -214,4 +214,4 @@

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

@@ -245,3 +245,3 @@

[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg

@@ -248,0 +248,0 @@ [chat]: https://spectrum.chat/unified/remark

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc