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

remark-lint

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

7

history.md

@@ -5,2 +5,9 @@ <!--remark setext-->

2.3.0 / 2016-02-03
==================
* Update support for configuration comments ([`870cb99`](https://github.com/wooorm/remark-lint/commit/870cb99))
* Fix literal URL and blank lines detection ([`b6309f0`](https://github.com/wooorm/remark-lint/commit/b6309f0))
* Add `remark-lint-code` to list of external rules ([`a81e82b`](https://github.com/wooorm/remark-lint/commit/a81e82b))
2.2.1 / 2016-01-15

@@ -7,0 +14,0 @@ ==================

152

lib/index.js

@@ -27,5 +27,4 @@ /**

var range = require('remark-range');
var zone = require('mdast-zone');
var control = require('remark-message-control');
var internals = require('./rules');
var filter = require('./filter');
var npmPrefix = require('npm-prefix')();

@@ -253,6 +252,9 @@

var settings = decamelizeSettings(options || {});
var reset = settings.reset;
var rules = loadExternals(settings.external);
var reset = options && options.reset;
var enable = [];
var disable = [];
var known = [];
var setting;
var id;
var setting;

@@ -265,58 +267,2 @@ /*

/**
* Get the latest state of a rule.
*
* @param {string} ruleId - Unique rule name.
* @param {File} [file] - File (optional)
*/
function getState(ruleId, file) {
var scope = file && file.namespace('remark-lint');
var ranges = scope && scope.ranges && scope.ranges[ruleId];
if (ranges) {
return ranges[ranges.length - 1].state;
}
setting = settings[ruleId];
if (setting === false) {
return false;
}
return !reset || (setting !== null && setting !== undefined);
}
/**
* Store settings on `file`.
*
* @param {File} file - Virtual file.
*/
function store(file) {
var scope = file.namespace('remark-lint');
var ranges = scope.ranges;
var ruleId;
if (!ranges) {
ranges = {};
for (ruleId in rules) {
ranges[ruleId] = [{
'state': getState(ruleId),
'position': {
'line': 0,
'column': 0
}
}];
}
scope.ranges = ranges;
}
}
remark.use(function () {
return function (ast, file) {
store(file);
};
});
/*

@@ -327,76 +273,30 @@ * Add each rule as a seperate plugin.

for (id in rules) {
remark.use(attachFactory(id, rules[id], settings[id]));
}
setting = settings[id];
/**
* Handle a rule.
*
* @param {VFile} file - Virtual file.
* @param {Object} marker - Marker context.
* @param {string} type - Type to toggle to.
* @param {*} ruleId - Rule to toggle.
*/
function toggle(file, marker, type, ruleId) {
var scope = file.namespace('remark-lint');
var markers;
var currentState;
var previousState;
known.push(id);
if (!(ruleId in rules)) {
file.fail('Unknown rule: cannot ' + type + ' `\'' + ruleId + '\'`', marker.node);
return;
if (!(setting === null || setting === undefined)) {
if (setting === false) {
disable.push(id);
} else {
enable.push(id);
}
}
markers = scope.ranges[ruleId];
previousState = getState(ruleId, file);
currentState = type === 'enable';
if (currentState !== previousState) {
markers.push({
'state': currentState,
'position': marker.node.position.start
});
}
remark.use(attachFactory(id, rules[id], setting));
}
/**
* Handle a new-found marker.
*
* @param {Object} marker - Marker context.
* @param {Object} parser - Parser instance.
/*
* Allow comments to toggle messages.
*/
function onparse(marker, parser) {
var file = parser.file;
var attributes = marker.attributes.split(' ');
var type = attributes[0];
var ids = attributes.slice(1);
var length = ids.length;
var index = -1;
if (type !== 'disable' && type !== 'enable') {
file.fail('Unknown lint keyword `' + type + '`: use either `\'enable\'` or `\'disable\'`', marker.node);
return;
}
store(file);
while (++index < length) {
toggle(file, marker, type, ids[index]);
}
}
remark.use(zone({
remark.use(control, {
'name': 'lint',
'onparse': onparse
}));
'source': SOURCE,
'reset': reset,
'known': known,
'enable': enable,
'disable': disable
});
/*
* Filter.
*/
remark.use(filter);
/**

@@ -407,7 +307,5 @@ * Transformer sort messages.

* @param {VFile} file - Virtual file.
* @param {Function} next - Completion handler.
*/
return function (node, file, next) {
return function (node, file) {
sort(file);
next();
};

@@ -414,0 +312,0 @@ }

@@ -72,2 +72,4 @@ /**

var children = node.children;
var head = children && children[0];
var tail = children && children[children.length - 1];

@@ -78,3 +80,3 @@ if (position.generated(node)) {

if (children && children[0]) {
if (head && !position.generated(head)) {
/*

@@ -84,3 +86,3 @@ * Compare parent and first child.

compare(position.start(node), position.start(children[0]), 0);
compare(position.start(node), position.start(head), 0);

@@ -124,3 +126,5 @@ /*

compare(position.end(node), position.end(children[children.length - 1]), 1);
if (tail !== head && !position.generated(tail)) {
compare(position.end(node), position.end(tail), 1);
}
}

@@ -127,0 +131,0 @@ });

@@ -25,2 +25,3 @@ /**

var visit = require('unist-util-visit');
var toString = require('mdast-util-to-string');
var position = require('mdast-util-position');

@@ -35,2 +36,8 @@

/*
* Constants.
*/
var MAILTO = 'mailto:';
/**

@@ -50,2 +57,3 @@ * Warn for literal URLs without angle-brackets.

var final = end(node).column;
var value = toString(node);

@@ -56,3 +64,7 @@ if (position.generated(node)) {

if (initial === head && final === tail) {
if (
initial === head &&
final === tail &&
(value === node.href || value == MAILTO + node.href)
) {
file.warn('Don’t use literal URLs without angle brackets', node);

@@ -59,0 +71,0 @@ }

{
"name": "remark-lint",
"version": "2.2.1",
"version": "2.3.0",
"description": "Lint markdown with remark",

@@ -12,13 +12,17 @@ "license": "MIT",

],
"repository": "wooorm/remark-lint",
"repository": {
"type": "git",
"url": "https://github.com/wooorm/remark-lint.git"
},
"bugs": "https://github.com/wooorm/remark-lint/issues",
"author": "Titus Wormer <tituswormer@gmail.com>",
"dependencies": {
"decamelize": "^1.0.0",
"remark-range": "^2.0.0",
"mdast-util-heading-style": "^1.0.0",
"mdast-util-position": "^1.0.0",
"mdast-util-to-string": "^1.0.0",
"mdast-zone": "^2.0.0",
"npm-prefix": "^1.1.1",
"plur": "^2.0.0",
"remark-message-control": "^1.0.1",
"remark-range": "^2.0.0",
"unist-util-visit": "^1.0.0",

@@ -41,3 +45,3 @@ "vfile-sort": "^1.0.0"

"remark-comment-config": "^2.0.0",
"remark-github": "^3.0.0",
"remark-github": "^4.0.0",
"remark-toc": "^2.0.0",

@@ -44,0 +48,0 @@ "remark-validate-links": "^2.0.0",

@@ -1,4 +0,5 @@

# ![remark-lint](https://cdn.rawgit.com/wooorm/remark-lint/master/logo.svg)
# ![remark-lint][logo]
[![Build Status](https://img.shields.io/travis/wooorm/remark-lint.svg)](https://travis-ci.org/wooorm/remark-lint) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/remark-lint.svg)](https://codecov.io/github/wooorm/remark-lint)
[![Build Status][travis-badge]][travis-ci]
[![Coverage Status][coverage-badge]][coverage-ci]

@@ -12,4 +13,4 @@ **remark-lint** is a markdown code style linter. Another linter? Yes.

**remark-lint** has lots of tests. Supports Node, io.js, and the browser.
100% coverage. 50+ rules. It’s built on [**remark**](https://github.com/wooorm/remark),
a powerful markdown processor powered by [plugins](https://github.com/wooorm/remark/blob/master/doc/plugins.md)
100% coverage. 50+ rules. It’s built on [**remark**][remark],
a powerful markdown processor powered by [plugins][remark-plugins]
(such as this one).

@@ -32,3 +33,3 @@

[npm](https://docs.npmjs.com/cli/install):
[npm][npm-install]:

@@ -39,9 +40,9 @@ ```bash

**remark-lint** is also available for [duo](http://duojs.org/#getting-started),
**remark-lint** is also available for [duo][duo-install],
and as an AMD, CommonJS, and globals module, [uncompressed and
compressed](https://github.com/wooorm/remark-lint/releases).
compressed][releases].
## Command line
![Example of how remark-lint looks on screen](https://cdn.rawgit.com/wooorm/remark-lint/master/screenshot.png)
![Example of how remark-lint looks on screen][screenshot]

@@ -76,3 +77,3 @@ Use remark-lint together with remark:

See [doc/rules.md](doc/rules.md) for what those warnings are (and how to
See [`doc/rules.md`][rules] for what those warnings are (and how to
turn them off).

@@ -82,3 +83,3 @@

[doc/api.md](doc/api.md) describes how to use **remark-lint**’s
[`doc/api.md`][api] describes how to use **remark-lint**’s
programatic interface in JavaScript.

@@ -88,3 +89,3 @@

[doc/rules.md](doc/rules.md) describes all available rules, what they check
[`doc/rules.md`][rules] describes all available rules, what they check
for, examples of markdown they warn for, and how to fix their warnings.

@@ -96,3 +97,3 @@

configure using configuration files. Read more about these files
(`.remarkrc` or `package.json`) in [**remark**’s docs](https://github.com/wooorm/remark/blob/master/doc/remarkrc.5.md).
(`.remarkrc` or `package.json`) in [**remark**’s docs][remarkrc].

@@ -119,7 +120,10 @@ An example `.remarkrc` file could look as follows:

The object at `settings` determines how **remark** parses (and compiles)
markdown code. Read more about the latter on [**remark**’s readme](https://github.com/wooorm/remark#remarkprocessvalue-options-done).
markdown code. Read more about the latter on [**remark**’s
readme][remark-process].
In addition, you can also provide configuration comments to turn a rule
on or off inside a file (note that you cannot change what a setting, such as
`maximum-line-length`, you’re either enabling or disabling warnings).
on or off inside a file. Note that you cannot change what a setting,
such as `maximum-line-length`, checks for, as you’re either enabling
or disabling warnings). Read more about configuration comments in
[**remark-message-control**][message-control]s documentation.

@@ -163,3 +167,4 @@ The following file will warn twice for the duplicate headings:

Currently, **remark-lint** is integrated with Atom through [**linter-markdown**](https://atom.io/packages/linter-markdown).
Currently, **remark-lint** is integrated with Atom through
[**linter-markdown**][linter-markdown].

@@ -170,4 +175,6 @@ I’m very interested in more integrations. Let me know if I can help.

* [`chcokr/remark-lint-sentence-newline`](https://github.com/chcokr/remark-lint-sentence-newline)
— Ensure sentences are followed by a newline;
<!--
This list is ordered based on the name without prefix, so
excluding `remark-lint-no-` or `remark-lint-`
-->

@@ -183,5 +190,12 @@ * [`vhf/remark-lint-alphabetize-lists`](https://github.com/vhf/remark-lint-alphabetize-lists)

* [`Qard/remark-lint-code`](https://github.com/Qard/remark-lint-code)
— Lint fenced code blocks by corresponding language tags,
currently supporting [ESLint](https://github.com/Qard/remark-lint-code-eslint).
* [`vhf/remark-lint-no-empty-sections`](https://github.com/vhf/remark-lint-no-empty-sections)
— Ensure every heading is followed by content (forming a section);
* [`chcokr/remark-lint-sentence-newline`](https://github.com/chcokr/remark-lint-sentence-newline)
— Ensure sentences are followed by a newline;
* [`vhf/remark-lint-no-url-trailing-slash`](https://github.com/vhf/remark-lint-no-url-trailing-slash)

@@ -197,2 +211,42 @@ — Ensure that the `href` of links has no trailing slash.

[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[travis-badge]: https://img.shields.io/travis/wooorm/remark-lint.svg
[travis-ci]: https://travis-ci.org/wooorm/remark-lint
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-lint.svg
[coverage-ci]: https://codecov.io/github/wooorm/remark-lint
[npm-install]: https://docs.npmjs.com/cli/install
[duo-install]: http://duojs.org/#getting-started
[releases]: https://github.com/wooorm/remark-lint/releases
[author]: http://wooorm.com
[logo]: https://cdn.rawgit.com/wooorm/remark-lint/master/logo.svg
[screenshot]: https://cdn.rawgit.com/wooorm/remark-lint/master/screenshot.png
[rules]: doc/rules.md
[api]: doc/api.md
[license]: LICENSE
[remark]: https://github.com/wooorm/remark
[remark-plugins]: https://github.com/wooorm/remark/blob/master/doc/plugins.md
[remarkrc]: https://github.com/wooorm/remark/blob/master/doc/remarkrc.5.md
[remark-process]: https://github.com/wooorm/remark#remarkprocessvalue-options-done
[linter-markdown]: https://atom.io/packages/linter-markdown
[message-control]: https://github.com/wooorm/remark-message-control#markers
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