Socket
Socket
Sign inDemoInstall

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 4.2.0 to 5.0.0

86

lib/index.js

@@ -32,5 +32,3 @@ /**

*
* By default, all rules are turned on unless explicitly
* set to `false`. When `reset: true`, the opposite is
* true: all rules are turned off, unless when given
* All rules are turned off, unless when given
* a non-nully and non-false value.

@@ -50,3 +48,2 @@ *

var rules = loadExternals(settings.external);
var reset = options && options.reset;
var enable = [];

@@ -56,3 +53,3 @@ var disable = [];

var pipeline = trough();
var setting;
var config;
var id;

@@ -62,21 +59,8 @@

for (id in rules) {
setting = settings[id];
known.push(id);
config = coerce(id, settings[id]);
if (setting != null) {
/* Pass turned on rules `undefined`. */
if (reset && setting === true) {
setting = undefined;
}
(config[0] ? enable : disable).push(id);
if (setting === false) {
setting = undefined;
disable.push(id);
} else {
enable.push(id);
}
}
pipeline.use(ruleFactory(id, rules[id], setting));
pipeline.use(ruleFactory(id, rules[id], config[0], config[1]));
}

@@ -95,3 +79,2 @@

source: SOURCE,
reset: reset,
known: known,

@@ -163,22 +146,27 @@ enable: enable,

* @param {Function} rule - Rule
* @param {number} severity - Severity.
* @param {*} options - Options for respective rule.
* @return {Function} - Trough ware.
*/
function ruleFactory(id, rule, options) {
function ruleFactory(id, rule, severity, options) {
var fn = wrapped(rule);
var fatal = severity === 2;
return function (ast, file, next) {
var scope = file.namespace('remark-lint');
var scope = file.data;
/* Track new messages per file. */
scope.index = file.messages.length;
scope.remarkLintIndex = file.messages.length;
fn(ast, file, options, function (err) {
var messages = file.messages;
var message;
while (scope.index < messages.length) {
messages[scope.index].ruleId = id;
messages[scope.index].source = SOURCE;
while (scope.remarkLintIndex < messages.length) {
message = messages[scope.remarkLintIndex];
message.ruleId = id;
message.source = SOURCE;
message.fatal = fatal;
scope.index++;
scope.remarkLintIndex++;
}

@@ -191,9 +179,3 @@

/**
* Helper to ensure ruleId’s are dash-cased instead of
* camel-cased.
*
* @param {Object} source - Original settings.
* @return {Object} - Dash-cased settings.
*/
/* Ensure ruleId’s are dash-cased. */
function decamelizeSettings(source) {

@@ -209,1 +191,33 @@ var result = {};

}
/* Coerce a value to a severity--options tuple. */
function coerce(name, value) {
var def = 0;
var result;
if (value == null) {
result = [def];
} else if (typeof value === 'boolean') {
result = [value];
} else if (
typeof value === 'object' &&
(typeof value[0] === 'number' || typeof value[0] === 'boolean')
) {
result = value.concat();
} else {
result = [1, value];
}
if (typeof result[0] === 'boolean') {
result[0] = result[0] ? 1 : 0;
}
if (result[0] < 0 || result[0] > 2) {
throw new Error(
'Invalid severity `' + result[0] + '` for `' + name + '`, ' +
'expected 0, 1, or 2'
);
}
return result;
}

@@ -94,3 +94,3 @@ /**

if (diff !== 0) {
file.warn(
file.message(
word + ' ' + diff + ' ' + plural('space', diff) +

@@ -97,0 +97,0 @@ ' between blockquote and content',

@@ -174,3 +174,3 @@ /**

file.warn(
file.message(
type.charAt(0).toUpperCase() + type.slice(1) +

@@ -177,0 +177,0 @@ ' checkboxes should use `' + style + '` as a marker',

@@ -85,3 +85,3 @@ /**

file.warn('Checkboxes should be followed by a single character', {
file.message('Checkboxes should be followed by a single character', {
start: location.toPosition(final - value.length + 1),

@@ -88,0 +88,0 @@ end: location.toPosition(final)

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

file.fail('Invalid code block style `' + preferred + '`: use either `\'consistent\'`, `\'fenced\'`, or `\'indented\'`');
return;
}

@@ -142,3 +141,3 @@

} else if (preferred !== current) {
file.warn('Code blocks should be ' + preferred, node);
file.message('Code blocks should be ' + preferred, node);
}

@@ -145,0 +144,0 @@ });

@@ -67,5 +67,5 @@ /**

if (label !== label.toLowerCase()) {
file.warn('Do not use upper-case characters in definition labels', node);
file.message('Do not use upper-case characters in definition labels', node);
}
}
}

@@ -67,5 +67,5 @@ /**

if (/[ \t\n]{2,}/.test(label)) {
file.warn('Do not use consecutive white-space in definition labels', node);
file.message('Do not use consecutive white-space in definition labels', node);
}
}
}

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

file.fail('Invalid emphasis marker `' + preferred + '`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`');
return;
}

@@ -100,3 +99,3 @@

if (marker !== preferred) {
file.warn('Emphasis should use `' + preferred + '` as a marker', node);
file.message('Emphasis should use `' + preferred + '` as a marker', node);
}

@@ -103,0 +102,0 @@ } else {

@@ -113,8 +113,8 @@ /**

if (flags.length && flags.indexOf(node.lang) === -1) {
file.warn('Invalid code-language flag', node);
file.message('Invalid code-language flag', node);
}
} else if (/^ {0,3}([~`])\1{2,}/.test(value) && !allowEmpty) {
file.warn('Missing code-language flag', node);
file.message('Missing code-language flag', node);
}
});
}

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

file.fail('Invalid fenced code marker `' + preferred + '`: use either `\'consistent\'`, `` \'`\' ``, or `\'~\'`');
return;
}

@@ -111,3 +110,3 @@

if (marker !== preferred) {
file.warn('Fenced code should use ' + preferred + ' as a marker', node);
file.message('Fenced code should use ' + preferred + ' as a marker', node);
}

@@ -114,0 +113,0 @@ } else {

@@ -40,9 +40,14 @@ /**

function fileExtension(ast, file, preferred) {
var ext = file.extension;
var ext = file.extname;
if (ext) {
ext = ext.slice(1);
}
preferred = typeof preferred === 'string' ? preferred : 'md';
if (ext !== '' && ext !== preferred) {
file.warn('Invalid extension: use `' + preferred + '`');
if (ext && ext !== preferred) {
console.log('e: ', [ext, preferred, file.extname], file);
file.message('Invalid extension: use `' + preferred + '`');
}
}

@@ -60,3 +60,3 @@ /**

if (last !== null && last > line) {
file.warn('Move definitions to the end of the file (after the node at line `' + last + '`)', node);
file.message('Move definitions to the end of the file (after the node at line `' + last + '`)', node);
}

@@ -63,0 +63,0 @@ } else if (last === null) {

@@ -30,4 +30,4 @@ /**

if (last > -1 && contents.charAt(last) !== '\n') {
file.warn('Missing newline character at end of file');
file.message('Missing newline character at end of file');
}
}

@@ -73,3 +73,3 @@ /**

if (node.depth !== style) {
file.warn('First heading level should be `' + style + '`', node);
file.message('First heading level should be `' + style + '`', node);
}

@@ -76,0 +76,0 @@

@@ -61,5 +61,5 @@ /**

if (value.length > 2) {
file.warn('Use two spaces for hard line breaks', node);
file.message('Use two spaces for hard line breaks', node);
}
});
}

@@ -55,3 +55,3 @@ /**

if (prev && depth > prev + 1) {
file.warn('Heading levels should increment by one level at a time', node);
file.message('Heading levels should increment by one level at a time', node);
}

@@ -58,0 +58,0 @@

@@ -101,3 +101,3 @@ /**

if (style(node, preferred) !== preferred) {
file.warn('Headings should use ' + preferred, node);
file.message('Headings should use ' + preferred, node);
}

@@ -104,0 +104,0 @@ } else {

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

file.fail('Invalid link title style marker `' + preferred + '`: use either `\'consistent\'`, `\'"\'`, `\'\\\'\'`, or `\'()\'`');
return;
}

@@ -153,5 +152,5 @@

pos = location.toPosition(last + 1);
file.warn('Titles should use `' + (preferred === ')' ? '()' : preferred) + '` as a quote', pos);
file.message('Titles should use `' + (preferred === ')' ? '()' : preferred) + '` as a quote', pos);
}
}
}

@@ -69,3 +69,3 @@ /**

file.warn('Incorrect indentation before bullet: remove ' + indent + ' ' + plural('space', indent), {
file.message('Incorrect indentation before bullet: remove ' + indent + ' ' + plural('space', indent), {
line: initial.line,

@@ -72,0 +72,0 @@ column: initial.column - indent

@@ -90,3 +90,3 @@ /**

file.warn(
file.message(
'Don’t use mixed indentation for children, ' + word +

@@ -93,0 +93,0 @@ ' ' + diff + ' ' + plural('space', diff),

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

file.fail('Invalid list-item indent style `' + preferred + '`: use either `\'tab-size\'`, `\'space\'`, or `\'mixed\'`');
return;
}

@@ -152,3 +151,3 @@

file.warn(
file.message(
'Incorrect list-item indent: ' + word +

@@ -155,0 +154,0 @@ ' ' + diff + ' ' + plural('space', diff),

@@ -10,3 +10,3 @@ /**

*
* According the [markdown-style-guide](http://www.cirosantilli.com/markdown-style-guide/),
* According to the [markdown-style-guide](http://www.cirosantilli.com/markdown-style-guide/),
* if one or more list-items in a list spans more than one line,

@@ -115,3 +115,3 @@ * the list is required to have blank lines between each item.

if (type === 'loose') {
file.warn('Missing new line after list item', {
file.message('Missing new line after list item', {
start: end(item),

@@ -121,3 +121,3 @@ end: start(next)

} else {
file.warn('Extraneous new line after list item', {
file.message('Extraneous new line after list item', {
start: end(item),

@@ -124,0 +124,0 @@ end: start(next)

@@ -56,5 +56,5 @@ /**

if (toString(node).length > preferred) {
file.warn('Use headings shorter than `' + preferred + '`', node);
file.message('Use headings shorter than `' + preferred + '`', node);
}
});
}

@@ -111,3 +111,3 @@ /**

if (lineLength > style) {
file.warn('Line must be at most ' + style + ' characters', {
file.message('Line must be at most ' + style + ' characters', {
line: index + 1,

@@ -114,0 +114,0 @@ column: lineLength + 1

@@ -67,3 +67,3 @@ /**

if (initial === head - 1 && final === tail + 1 && !hasProtocol(node)) {
file.warn('All automatic links must start with a protocol', node);
file.message('All automatic links must start with a protocol', node);
}

@@ -70,0 +70,0 @@ });

@@ -77,3 +77,3 @@ /**

file.warn('Missing caret in blockquote', {
file.message('Missing caret in blockquote', {
line: line,

@@ -80,0 +80,0 @@ column: column

@@ -121,5 +121,5 @@ /**

if (diff > 0) {
file.warn('Remove ' + diff + ' ' + plural('line', diff) + ' ' + word + ' node', end);
file.message('Remove ' + diff + ' ' + plural('line', diff) + ' ' + word + ' node', end);
}
}
}

@@ -65,3 +65,3 @@ /**

file.warn(
file.message(
'Do not use definitions with the same identifier (' +

@@ -68,0 +68,0 @@ pos.line + ':' + pos.column + ')',

@@ -64,3 +64,3 @@ /**

file.warn(
file.message(
'Do not use headings with similar content (' +

@@ -67,0 +67,0 @@ pos.line + ':' + pos.column + ')',

@@ -61,5 +61,5 @@ /**

) {
file.warn('Don’t use emphasis to introduce a section, use a heading', node);
file.message('Don’t use emphasis to introduce a section, use a heading', node);
}
});
}

@@ -36,7 +36,7 @@ /**

function noFileNameArticles(ast, file) {
var match = file.filename && file.filename.match(/^(the|an?)\b/i);
var match = file.stem && file.stem.match(/^(the|an?)\b/i);
if (match) {
file.warn('Do not start file names with `' + match[0] + '`');
file.message('Do not start file names with `' + match[0] + '`');
}
}

@@ -28,5 +28,5 @@ /**

function noFileNameConsecutiveDashes(ast, file) {
if (file.filename && /-{2,}/.test(file.filename)) {
file.warn('Do not use consecutive dashes in a file name');
if (file.stem && /-{2,}/.test(file.stem)) {
file.message('Do not use consecutive dashes in a file name');
}
}

@@ -59,7 +59,7 @@ /**

match = file.filename && file.filename.match(expression);
match = file.stem && file.stem.match(expression);
if (match) {
file.warn('Do not use `' + match[0] + '` in a file name');
file.message('Do not use `' + match[0] + '` in a file name');
}
}

@@ -32,7 +32,7 @@ /**

function noFileNameMixedCase(ast, file) {
var name = file.filename;
var name = file.stem;
if (name && !(name === name.toLowerCase() || name === name.toUpperCase())) {
file.warn('Do not mix casing in file names');
file.message('Do not mix casing in file names');
}
}

@@ -32,5 +32,5 @@ /**

function noFileNameOuterDashes(ast, file) {
if (file.filename && /^-|-$/.test(file.filename)) {
file.warn('Do not use initial or final dashes in a file name');
if (file.stem && /^-|-$/.test(file.stem)) {
file.message('Do not use initial or final dashes in a file name');
}
}

@@ -125,3 +125,3 @@ /**

file.warn(
file.message(
word + ' ' + diff + ' ' + plural('space', diff) +

@@ -145,3 +145,3 @@ ' before this heading’s content',

if (diff) {
file.warn(
file.message(
'Remove ' + diff + ' ' + plural('space', diff) +

@@ -148,0 +148,0 @@ ' after this heading’s content',

@@ -91,3 +91,3 @@ /**

if (diff) {
file.warn(
file.message(
'Remove ' + diff + ' ' + plural('space', diff) +

@@ -94,0 +94,0 @@ ' before this heading',

@@ -74,5 +74,5 @@ /**

if (new RegExp('[' + preferred + ']').test(value)) {
file.warn('Don’t add a trailing `' + value + '` to headings', node);
file.message('Don’t add a trailing `' + value + '` to headings', node);
}
});
}

@@ -47,3 +47,3 @@ /**

if (!position.generated(node) && !/^\s*<!--/.test(node.value)) {
file.warn('Do not use HTML in markdown', node);
file.message('Do not use HTML in markdown', node);
}

@@ -50,0 +50,0 @@ });

@@ -63,3 +63,3 @@ /**

if (contents.charAt(0) === ' ' || contents.charAt(contents.length - 1) === ' ') {
file.warn('Don’t pad `' + type + '` with inner spaces', node);
file.message('Don’t pad `' + type + '` with inner spaces', node);
}

@@ -66,0 +66,0 @@ }

@@ -65,5 +65,5 @@ /**

) {
file.warn('Don’t use literal URLs without angle brackets', node);
file.message('Don’t use literal URLs without angle brackets', node);
}
});
}

@@ -91,3 +91,3 @@ /**

) {
file.warn('Missing blank line before block node', next);
file.message('Missing blank line before block node', next);
}

@@ -94,0 +94,0 @@ });

@@ -60,3 +60,3 @@ /**

file.warn('Don’t use multiple top level headings (' + pos.line + ':' + pos.column + ')', node);
file.message('Don’t use multiple top level headings (' + pos.line + ':' + pos.column + ')', node);
}

@@ -63,0 +63,0 @@

@@ -86,3 +86,3 @@ /**

if (warn) {
file.warn('Do not use dollar signs before shell-commands', node);
file.message('Do not use dollar signs before shell-commands', node);
}

@@ -89,0 +89,0 @@ }

@@ -48,5 +48,5 @@ /**

if (node.referenceType === 'shortcut') {
file.warn('Use the trailing [] on reference images', node);
file.message('Use the trailing [] on reference images', node);
}
});
}

@@ -48,5 +48,5 @@ /**

if (node.referenceType === 'shortcut') {
file.warn('Use the trailing [] on reference links', node);
file.message('Use the trailing [] on reference links', node);
}
});
}

@@ -58,3 +58,3 @@ /**

if (fence.indexOf('|') > 1) {
file.warn('Do not indent table rows', row);
file.message('Do not indent table rows', row);
}

@@ -61,0 +61,0 @@ });

@@ -70,3 +70,3 @@ /**

if (content.charAt(index) === '\t') {
file.warn('Use spaces instead of hard-tabs', location.toPosition(index));
file.message('Use spaces instead of hard-tabs', location.toPosition(index));
}

@@ -73,0 +73,0 @@ }

@@ -75,5 +75,5 @@ /**

if (!map[node.identifier.toUpperCase()]) {
file.warn('Found reference to undefined definition', node);
file.message('Found reference to undefined definition', node);
}
}
}

@@ -52,3 +52,3 @@ /**

if (!map[identifier].used) {
file.warn('Found unused definition', map[identifier].node);
file.message('Found unused definition', map[identifier].node);
}

@@ -55,0 +55,0 @@ }

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

file.fail('Invalid ordered list-item marker style `' + preferred + '`: use either `\'.\'` or `\')\'`');
return;
}

@@ -116,3 +115,3 @@

} else if (marker !== preferred) {
file.warn('Marker style should be `' + preferred + '`', item);
file.message('Marker style should be `' + preferred + '`', item);
}

@@ -119,0 +118,0 @@ });

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

file.fail('Invalid ordered list-item marker value `' + preferred + '`: use either `\'ordered\'` or `\'one\'`');
return;
}

@@ -154,3 +153,3 @@

if (marker !== shouldBe) {
file.warn('Marker should be `' + shouldBe + '`, was `' + marker + '`', item);
file.message('Marker should be `' + shouldBe + '`, was `' + marker + '`', item);
}

@@ -157,0 +156,0 @@ });

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

file.fail('Invalid preferred rule-style: provide a valid markdown rule, or `\'consistent\'`');
return;
}

@@ -93,3 +92,3 @@

if (hr !== preferred) {
file.warn('Rules should use `' + preferred + '`', node);
file.message('Rules should use `' + preferred + '`', node);
}

@@ -96,0 +95,0 @@ } else {

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

file.fail('Invalid strong marker `' + preferred + '`: use either `\'consistent\'`, `\'*\'`, or `\'_\'`');
return;
}

@@ -87,3 +86,3 @@

if (marker !== preferred) {
file.warn('Strong should use `' + preferred + '` as a marker', node);
file.message('Strong should use `' + preferred + '` as a marker', node);
}

@@ -90,0 +89,0 @@ } else {

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

file.fail('Invalid table-cell-padding style `' + preferred + '`');
return;
}

@@ -188,3 +187,3 @@

if (diff !== style && diff !== undefined && diff !== null) {
file.warn(warning, locations[index]);
file.message(warning, locations[index]);
}

@@ -191,0 +190,0 @@ });

@@ -72,3 +72,3 @@ /**

} else if (pos !== indices[index]) {
file.warn('Misaligned table fence', {
file.message('Misaligned table fence', {
start: {

@@ -75,0 +75,0 @@ line: line,

@@ -64,7 +64,7 @@ /**

if (initial.indexOf('|') === -1) {
file.warn('Missing initial pipe in table fence', start(row));
file.message('Missing initial pipe in table fence', start(row));
}
if (final.indexOf('|') === -1) {
file.warn('Missing final pipe in table fence', end(row));
file.message('Missing final pipe in table fence', end(row));
}

@@ -71,0 +71,0 @@ });

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

file.fail('Invalid unordered list-item marker style `' + preferred + '`: use either `\'-\'`, `\'*\'`, or `\'+\'`');
return;
}

@@ -111,3 +110,3 @@

} else if (marker !== preferred) {
file.warn('Marker style should be `' + preferred + '`', item);
file.message('Marker style should be `' + preferred + '`', item);
}

@@ -114,0 +113,0 @@ });

{
"name": "remark-lint",
"version": "4.2.0",
"version": "5.0.0",
"description": "Lint markdown with remark",

@@ -12,3 +12,3 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/remark-lint",
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint",
"bugs": "https://github.com/wooorm/remark-lint/issues",

@@ -28,5 +28,9 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

],
"files": [
"index.js",
"lib/"
],
"dependencies": {
"decamelize": "^1.0.0",
"load-plugin": "^1.1.1",
"load-plugin": "^2.0.0",
"mdast-util-heading-style": "^1.0.0",

@@ -42,77 +46,3 @@ "mdast-util-to-string": "^1.0.0",

"wrapped": "^1.0.1"
},
"files": [
"index.js",
"lib/"
],
"devDependencies": {
"browserify": "^13.0.0",
"chalk": "^1.1.3",
"dox": "^0.9.0",
"esmangle": "^1.0.0",
"nyc": "^8.0.0",
"remark": "^5.0.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint-no-url-trailing-slash": "^2.0.0",
"remark-toc": "^3.0.0",
"remark-validate-links": "^4.0.0",
"strip-indent": "^1.0.0",
"tape": "^4.6.0",
"to-vfile": "^1.0.0",
"trim": "0.0.1",
"unist-builder": "^1.0.2",
"unist-util-remove-position": "^1.1.0",
"xo": "^0.16.0"
},
"scripts": {
"build-index": "node script/build-index.js",
"build-rules": "node script/build-docs.js",
"build-md": "remark . --quiet --frail",
"build-bundle": "browserify index.js --bare -s remarkLint > remark-lint.js",
"build-mangle": "esmangle remark-lint.js > remark-lint.min.js",
"build": "npm run build-md && npm run build-index && npm run build-rules && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "tape test/index.js",
"test-coverage": "nyc --reporter lcov tape test/index.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"rules": {
"guard-for-in": "off",
"no-eq-null": "off",
"eqeqeq": "off"
},
"ignores": [
"remark-lint.js",
"remark-lint.min.js"
]
},
"remarkConfig": {
"output": true,
"plugins": {
"comment-config": null,
"github": null,
"toc": {
"tight": true,
"maxDepth": 2
},
"./": {
"no-missing-blank-lines": false,
"list-item-spacing": false
},
"validate-links": null
},
"settings": {
"bullet": "*"
}
}
}
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