Skip to content

Commit

Permalink
Update dependencies and require Node.js 6 (#22)
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
transitive-bullshit authored and sindresorhus committed Jul 29, 2018
1 parent f2f4f63 commit c5c87d8
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 102 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ language: node_js
node_js:
- '8'
- '6'
- '4'
126 changes: 53 additions & 73 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,59 @@
'use strict';
const path = require('path');

// Rules per remark-lint 4.0.2
exports.plugins = [
require('remark-lint'),

module.exports = {
reset: true,
'blockquote-indentation': 2,
'checkbox-character-style': {
// Official plugins
[require('remark-lint-blockquote-indentation'), 2],
[require('remark-lint-checkbox-character-style'), {
checked: 'x',
unchecked: ' '
},
'checkbox-content-indent': true,
'code-block-style': 'fenced',
'definition-case': true,
'definition-spacing': true,
'emphasis-marker': '*',
'fenced-code-marker': '`',
'file-extension': true,
'final-newline': true,
// TODO: because of https://github.com/wooorm/remark-lint/issues/77
// 'first-heading-level': 1,
'hard-break-spaces': true,
'heading-style': 'atx',
'link-title-style': '\'',
'list-item-bullet-indent': true,
'list-item-content-indent': true,
'list-item-indent': 'space',
// TODO: because of https://github.com/wooorm/remark-lint/issues/78
// 'list-item-spacing': true,
'no-auto-link-without-protocol': true,
'no-blockquote-without-caret': true,
'no-duplicate-definitions': true,
// TODO: because of https://github.com/wooorm/remark-lint/issues/84
// 'no-duplicate-headings': true,
'no-emphasis-as-heading': true,
'no-file-name-articles': true,
'no-file-name-consecutive-dashes': true,
'no-file-name-irregular-characters': true,
'no-file-name-mixed-case': true,
'no-file-name-outer-dashes': true,
'no-heading-content-indent': true,
'no-heading-indent': true,
'no-heading-punctuation': true,
'no-inline-padding': true,
'no-literal-urls': true,
// TODO: because of https://github.com/wooorm/remark-lint/issues/79
// 'no-missing-blank-lines': true,
'no-multiple-toplevel-headings': 1,
'no-shell-dollars': true,
'no-table-indentation': true,
'no-undefined-references': true,
'no-unused-definitions': true,
'ordered-list-marker-style': '.',
'ordered-list-marker-value': 'ordered',
'rule-style': '---',
'strong-marker': '*',
'table-cell-padding': 'padded',
'table-pipe-alignment': true,
'table-pipes': true,
'unordered-list-marker-style': '-',
}],
require('remark-lint-checkbox-content-indent'),
[require('remark-lint-code-block-style'), 'fenced'],
require('remark-lint-definition-case'),
require('remark-lint-definition-spacing'),
[require('remark-lint-emphasis-marker'), '*'],
[require('remark-lint-fenced-code-marker'), '`'],
require('remark-lint-file-extension'),
require('remark-lint-final-newline'),
require('remark-lint-hard-break-spaces'),
[require('remark-lint-heading-style'), 'atx'],
[require('remark-lint-link-title-style'), '\''],
require('remark-lint-list-item-bullet-indent'),
require('remark-lint-list-item-content-indent'),
[require('remark-lint-list-item-indent'), 'space'],
require('remark-lint-no-auto-link-without-protocol'),
require('remark-lint-no-blockquote-without-marker'),
require('remark-lint-no-emphasis-as-heading'),
require('remark-lint-no-file-name-articles'),
require('remark-lint-no-file-name-consecutive-dashes'),
require('remark-lint-no-file-name-irregular-characters'),
require('remark-lint-no-file-name-mixed-case'),
require('remark-lint-no-file-name-outer-dashes'),
require('remark-lint-no-heading-content-indent'),
require('remark-lint-no-heading-indent'),
require('remark-lint-no-heading-punctuation'),
require('remark-lint-no-inline-padding'),
require('remark-lint-no-literal-urls'),
[require('remark-lint-no-multiple-toplevel-headings'), 1],
require('remark-lint-no-shell-dollars'),
require('remark-lint-no-table-indentation'),
require('remark-lint-no-undefined-references'),
require('remark-lint-no-unused-definitions'),
[require('remark-lint-ordered-list-marker-style'), '.'],
[require('remark-lint-ordered-list-marker-value'), 'ordered'],
[require('remark-lint-rule-style'), '---'],
[require('remark-lint-strong-marker'), '*'],
[require('remark-lint-table-cell-padding'), 'padded'],
require('remark-lint-table-pipe-alignment'),
require('remark-lint-table-pipes'),
[require('remark-lint-unordered-list-marker-style'), '-'],

// Plugins
external: [
'remark-lint-no-empty-sections',
'remark-lint-no-url-trailing-slash',
// 'remark-lint-are-links-valid',
path.join(__dirname, 'rules')
],
'empty-sections': true,
'trailing-slash': true,
// This rule is a good idea, but in reality it's way too slow and has too many false positives
// 'are-links-valid': {
// // TODO: The error message is too unclear here. Make a rule that disallows redirects
// // allowRedirects: false,
// timeout: 2000
// },
'awesome/badge': true
};
// Third-party plugins
require('remark-lint-no-empty-sections'),
require('remark-lint-no-url-trailing-slash'),

// Custom plugins
...require('./rules')
];
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
const remark = require('remark');
const remarkLint = require('remark-lint');
const globby = require('globby');
const pify = require('pify');
const toVfile = require('to-vfile');
Expand All @@ -18,21 +17,21 @@ const m = opts => {
return Promise.reject(new Error(`Couldn't find the file ${opts.filename}`));
}

const run = remark().use(remarkLint, config).process;
const run = remark().use(config).process;
const file = toVfile.readSync(readmeFile);

return pify(run)(file);
};

m.report = opts => m(opts).then(file => {
const messages = file.messages;
const {messages} = file;

if (messages.length === 0) {
return;
}

messages.forEach(x => {
x.fatal = true; // TODO: because of https://github.com/wooorm/remark-lint/issues/65
x.fatal = true; // eslint-ignore-line TODO: because of https://github.com/wooorm/remark-lint/issues/65
});

process.exitCode = 1;
Expand Down
63 changes: 53 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"bin": "cli.js",
"engines": {
"node": ">=4"
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -34,20 +34,63 @@
"cli"
],
"dependencies": {
"globby": "^6.0.0",
"meow": "^3.7.0",
"globby": "^8.0.1",
"meow": "^5.0.0",
"pify": "^3.0.0",
"remark": "^5.0.1",
"remark-lint": "^4.1.0",
"remark-lint-no-empty-sections": "^1.0.0",
"remark-lint-no-url-trailing-slash": "^2.0.0",
"to-vfile": "^1.0.0",
"remark": "^9.0.0",
"remark-lint": "^6.0.2",
"remark-lint-blockquote-indentation": "^1.0.2",
"remark-lint-checkbox-character-style": "^1.0.2",
"remark-lint-checkbox-content-indent": "^1.0.2",
"remark-lint-code-block-style": "^1.0.2",
"remark-lint-definition-case": "^1.0.2",
"remark-lint-definition-spacing": "^1.0.2",
"remark-lint-emphasis-marker": "^1.0.2",
"remark-lint-fenced-code-marker": "^1.0.2",
"remark-lint-file-extension": "^1.0.2",
"remark-lint-final-newline": "^1.0.2",
"remark-lint-hard-break-spaces": "^1.0.3",
"remark-lint-heading-style": "^1.0.2",
"remark-lint-link-title-style": "^1.0.2",
"remark-lint-list-item-bullet-indent": "^1.0.2",
"remark-lint-list-item-content-indent": "^1.0.2",
"remark-lint-list-item-indent": "^1.0.2",
"remark-lint-no-auto-link-without-protocol": "^1.0.2",
"remark-lint-no-blockquote-without-marker": "^2.0.2",
"remark-lint-no-emphasis-as-heading": "^1.0.2",
"remark-lint-no-empty-sections": "^2.0.0",
"remark-lint-no-file-name-articles": "^1.0.2",
"remark-lint-no-file-name-consecutive-dashes": "^1.0.2",
"remark-lint-no-file-name-irregular-characters": "^1.0.2",
"remark-lint-no-file-name-mixed-case": "^1.0.2",
"remark-lint-no-file-name-outer-dashes": "^1.0.3",
"remark-lint-no-heading-content-indent": "^1.0.2",
"remark-lint-no-heading-indent": "^1.0.2",
"remark-lint-no-heading-punctuation": "^1.0.2",
"remark-lint-no-inline-padding": "^1.0.2",
"remark-lint-no-literal-urls": "^1.0.2",
"remark-lint-no-multiple-toplevel-headings": "^1.0.2",
"remark-lint-no-shell-dollars": "^1.0.2",
"remark-lint-no-table-indentation": "^1.0.2",
"remark-lint-no-undefined-references": "^1.0.2",
"remark-lint-no-unused-definitions": "^1.0.2",
"remark-lint-no-url-trailing-slash": "^3.0.1",
"remark-lint-ordered-list-marker-style": "^1.0.2",
"remark-lint-ordered-list-marker-value": "^1.0.2",
"remark-lint-rule-style": "^1.0.2",
"remark-lint-strong-marker": "^1.0.2",
"remark-lint-table-cell-padding": "^1.0.2",
"remark-lint-table-pipe-alignment": "^1.0.2",
"remark-lint-table-pipes": "^1.0.2",
"remark-lint-unordered-list-marker-style": "^1.0.2",
"to-vfile": "^5.0.0",
"unified-lint-rule": "^1.0.3",
"unist-util-visit": "^1.1.0",
"vfile-reporter-pretty": "^0.1.0"
"vfile-reporter-pretty": "^1.0.2"
},
"devDependencies": {
"ava": "*",
"execa": "^0.8.0",
"execa": "^0.10.0",
"xo": "*"
}
}
25 changes: 14 additions & 11 deletions rules/badge.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');

module.exports = (ast, file) => {
module.exports = rule('remark-lint:awesome/badge', (ast, file) => {
visit(ast, 'heading', (node, index) => {
if (index > 0) {
return;
Expand All @@ -13,22 +14,24 @@ module.exports = (ast, file) => {
let hasBadge = false;

for (const child of node.children) {
if (node.depth === 1 && child.type === 'link' && child.url === badgeUrl) {
for (const child2 of child.children) {
if (child2.type === 'image') {
if (child2.url !== badgeSrcUrl) {
file.warn('Incorrect badge source', child2);
return;
}
if (node.depth !== 1 || child.type !== 'link' || child.url !== badgeUrl) {
continue;
}

hasBadge = true;
for (const child2 of child.children) {
if (child2.type === 'image') {
if (child2.url !== badgeSrcUrl) {
file.message('Incorrect badge source', child2);
return;
}

hasBadge = true;
}
}
}

if (!hasBadge) {
file.warn('Missing Awesome badge after the main heading', node);
file.message('Missing Awesome badge after the main heading', node);
}
});
};
});
6 changes: 3 additions & 3 deletions rules/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
'awesome/badge': require('./badge')
};
module.exports = [
require('./badge')
];

0 comments on commit c5c87d8

Please sign in to comment.