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

remark-lint-rule-style

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-rule-style - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

73

index.js

@@ -17,2 +17,17 @@ /**

*
* ## Fix
*
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
* has three settings that define how rules are created:
*
* * [`rule`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrule)
* (default: `*`) — Marker to use
* * [`ruleRepetition`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrulerepetition)
* (default: `3`) — Number of markers to use
* * [`ruleSpaces`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrulespaces)
* (default: `true`) — Whether to pad markers with spaces
*
* 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.
*
* @example {"name": "valid.md", "setting": "* * *"}

@@ -45,48 +60,44 @@ *

'use strict';
'use strict'
var rule = require('unified-lint-rule');
var visit = require('unist-util-visit');
var position = require('unist-util-position');
var generated = require('unist-util-generated');
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var position = require('unist-util-position')
var generated = require('unist-util-generated')
module.exports = rule('remark-lint:rule-style', ruleStyle);
module.exports = rule('remark-lint:rule-style', ruleStyle)
var start = position.start;
var end = position.end;
var start = position.start
var end = position.end
function ruleStyle(ast, file, preferred) {
var contents = file.toString();
function ruleStyle(tree, file, pref) {
var contents = String(file)
preferred = typeof preferred !== 'string' || preferred === 'consistent' ? null : preferred;
pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null
if (validateRuleStyle(preferred) !== true) {
file.fail('Invalid preferred rule-style: provide a valid markdown rule, or `\'consistent\'`');
if (pref !== null && /[^-_* ]/.test(pref)) {
file.fail(
"Invalid preferred rule-style: provide a valid markdown rule, or `'consistent'`"
)
}
visit(ast, 'thematicBreak', visitor);
visit(tree, 'thematicBreak', visitor)
function visitor(node) {
var initial = start(node).offset;
var final = end(node).offset;
var hr;
var initial = start(node).offset
var final = end(node).offset
var rule
if (generated(node)) {
return;
}
if (!generated(node)) {
rule = contents.slice(initial, final)
hr = contents.slice(initial, final);
if (preferred) {
if (hr !== preferred) {
file.message('Rules should use `' + preferred + '`', node);
if (pref) {
if (rule !== pref) {
file.message('Rules should use `' + pref + '`', node)
}
} else {
pref = rule
}
} else {
preferred = hr;
}
}
}
function validateRuleStyle(style) {
return style === null || !/[^-_* ]/.test(style);
}
{
"name": "remark-lint-rule-style",
"version": "1.0.1",
"version": "1.0.2",
"description": "remark-lint rule to warn when horizontal rules violate a given style",

@@ -15,4 +15,4 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-rule-style",
"bugs": "https://github.com/wooorm/remark-lint/issues",
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-rule-style",
"bugs": "https://github.com/remarkjs/remark-lint/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

@@ -19,0 +19,0 @@ "contributors": [

@@ -15,2 +15,17 @@ <!--This file is generated-->

## Fix
[`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
has three settings that define how rules are created:
* [`rule`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrule)
(default: `*`) — Marker to use
* [`ruleRepetition`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrulerepetition)
(default: `3`) — Number of markers to use
* [`ruleSpaces`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsrulespaces)
(default: `true`) — Whether to pad markers with spaces
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.
## Presets

@@ -22,4 +37,4 @@

| ------ | ------- |
| [`remark-preset-lint-consistent`](https://github.com/wooorm/remark-lint/tree/master/packages/remark-preset-lint-consistent) | |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/wooorm/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | |
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-consistent) | `'consistent'` |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | `'---'` |

@@ -131,2 +146,2 @@ ## Example

[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT](https://github.com/remarkjs/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
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