Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Intended to make it easier to create and maintain Awesome lists.

Includes a bunch of [general Markdown rules](https://github.com/sindresorhus/awesome-lint/blob/master/config.js) and some [Awesome specific rules](https://github.com/sindresorhus/awesome-lint/tree/master/rules).

Supports to enable, disable, and ignore rules by special comments. See detailed examples in [remark-message-control](https://github.com/remarkjs/remark-message-control#markers).

![](media/screenshot.png)


Expand Down
2 changes: 1 addition & 1 deletion rules/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const badgeSrcUrlWhitelist = new Set([
const isValidBadgeUrl = url => badgeUrlWhitelist.has(url);
const isValidBadgeSrcUrl = url => badgeSrcUrlWhitelist.has(url);

module.exports = rule('remark-lint:awesome/badge', (ast, file) => {
module.exports = rule('remark-lint:awesome-badge', (ast, file) => {
visit(ast, 'heading', (node, index) => {
if (index > 0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion rules/contributing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const globby = require('globby');
const rule = require('unified-lint-rule');

module.exports = rule('remark-lint:awesome/contributing', (ast, file) => {
module.exports = rule('remark-lint:awesome-contributing', (ast, file) => {
const {dirname} = file;

const contributingFile = globby.sync(['contributing.md', 'CONTRIBUTING.md'], {cwd: dirname})[0];
Expand Down
2 changes: 1 addition & 1 deletion rules/git-repo-age.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const oneDay = 24 * 60 * 60 * 1000;
const minGitRepoAgeDays = 30;
const minGitRepoAgeMs = minGitRepoAgeDays * oneDay;

module.exports = rule('remark-lint:awesome/git-repo-age', async (ast, file) => {
module.exports = rule('remark-lint:awesome-git-repo-age', async (ast, file) => {
const {dirname} = file;

try {
Expand Down
2 changes: 1 addition & 1 deletion rules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const got = require('got');
const gh = require('github-url-to-object');
const rule = require('unified-lint-rule');

module.exports = rule('remark-lint:awesome/github', async (ast, file) => {
module.exports = rule('remark-lint:awesome-github', async (ast, file) => {
const {dirname} = file;

try {
Expand Down
2 changes: 1 addition & 1 deletion rules/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const listHeadingCaseWhitelist = new Set([
'capital'
]);

module.exports = rule('remark-lint:awesome/heading', (ast, file) => {
module.exports = rule('remark-lint:awesome-heading', (ast, file) => {
let headings = 0;

visit(ast, (node, index) => {
Expand Down
2 changes: 1 addition & 1 deletion rules/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const rule = require('unified-lint-rule');
const toString = require('mdast-util-to-string');
const visit = require('unist-util-visit');

module.exports = rule('remark-lint:awesome/license', (ast, file) => {
module.exports = rule('remark-lint:awesome-license', (ast, file) => {
const license = find(ast, node => (
node.type === 'heading' &&
(toString(node) === 'Licence' || toString(node) === 'License')
Expand Down
2 changes: 1 addition & 1 deletion rules/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const listItemDescriptionSuffixNodeWhitelist = new Set([
'text'
]);

module.exports = rule('remark-lint:awesome/list-item', (ast, file) => {
module.exports = rule('remark-lint:awesome-list-item', (ast, file) => {
let lists = findAllLists(ast);

const toc = find(ast, node => (
Expand Down
2 changes: 1 addition & 1 deletion rules/no-ci-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');

module.exports = rule('remark-lint:awesome/no-ci-badge', (ast, file) => {
module.exports = rule('remark-lint:awesome-no-ci-badge', (ast, file) => {
visit(ast, 'image', node => {
if (/build status|travis|circleci/i.test(node.title)) {
file.message('Readme must not contain CI badge', node);
Expand Down
2 changes: 1 addition & 1 deletion rules/spell-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const wordBreakCharacterWhitelist = new Set([
'-'
]);

module.exports = rule('remark-lint:awesome/spell-check', (ast, file) => {
module.exports = rule('remark-lint:awesome-spell-check', (ast, file) => {
visit(ast, 'text', node => {
if (!node.value) {
return;
Expand Down
2 changes: 1 addition & 1 deletion rules/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const sectionHeadingBlacklist = new Set([
'License'
]);

module.exports = rule('remark-lint:awesome/toc', (ast, file) => {
module.exports = rule('remark-lint:awesome-toc', (ast, file) => {
slugger.reset();

// Heading links are order-dependent, so it's important to gather them up front
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/list-item/4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!--lint disable awesome-list-item -->
- [foo](https://foo.com) - an invalid description.
6 changes: 3 additions & 3 deletions test/rules/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('badge - missing', async t => {
const messages = await lint({config, filename: 'test/fixtures/badge/error0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/badge',
ruleId: 'awesome-badge',
message: 'Missing Awesome badge after the main heading'
}
]);
Expand All @@ -22,7 +22,7 @@ test('badge - incorrect source', async t => {
const messages = await lint({config, filename: 'test/fixtures/badge/error1.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/badge',
ruleId: 'awesome-badge',
message: 'Invalid badge source'
}
]);
Expand All @@ -32,7 +32,7 @@ test('badge - incorrect source raw git', async t => {
const messages = await lint({config, filename: 'test/fixtures/badge/error2.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/badge',
ruleId: 'awesome-badge',
message: 'Invalid badge source'
}
]);
Expand Down
4 changes: 2 additions & 2 deletions test/rules/contributing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('contributing - missing', async t => {
const messages = await lint({config, filename: 'test/fixtures/contributing/error0/readme.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/contributing',
ruleId: 'awesome-contributing',
message: 'Missing file contributing.md'
}
]);
Expand All @@ -21,7 +21,7 @@ test('contributing - empty', async t => {
const messages = await lint({config, filename: 'test/fixtures/contributing/error1/readme.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/contributing',
ruleId: 'awesome-contributing',
message: 'contributing.md file must not be empty'
}
]);
Expand Down
4 changes: 2 additions & 2 deletions test/rules/git-repo-age.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.serial('git-repo-age - error invalid git repo', async t => {
const messages = await lint({config, filename: 'test/fixtures/git-repo-age/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/git-repo-age',
ruleId: 'awesome-git-repo-age',
message: 'Awesome list must reside in a valid deep-cloned Git repository (see https://github.com/sindresorhus/awesome-lint#tip for more information)'
}
]);
Expand All @@ -49,7 +49,7 @@ test.serial('git-repo-age - error repo is not old enough', async t => {
const messages = await lint({config, filename: 'test/fixtures/git-repo-age/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/git-repo-age',
ruleId: 'awesome-git-repo-age',
message: 'Git repository must be at least 30 days old'
}
]);
Expand Down
20 changes: 10 additions & 10 deletions test/rules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.serial('github - error invalid git repo', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'Awesome list must reside in a valid git repository'
}
]);
Expand All @@ -56,10 +56,10 @@ test.serial('github - repo without description and license', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'The repository should have a description'
}, {
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'License was not detected by GitHub'
}
]);
Expand Down Expand Up @@ -88,7 +88,7 @@ test.serial('github - missing topic awesome-list', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'The repository should have "awesome-list" as a GitHub topic'
}
]);
Expand Down Expand Up @@ -117,7 +117,7 @@ test.serial('github - missing topic awesome', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'The repository should have "awesome" as a GitHub topic'
}
]);
Expand All @@ -133,7 +133,7 @@ test.serial('github - remote origin is an GitLab repo', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'Repository should be on GitHub'
}
]);
Expand All @@ -156,7 +156,7 @@ test.serial('github - invalid token', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'Unauthorized access or token is invalid'
}
]);
Expand Down Expand Up @@ -184,7 +184,7 @@ test.serial('github - API rate limit exceeded with token', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'API rate limit of 5000 requests per hour exceeded'
}
]);
Expand Down Expand Up @@ -212,7 +212,7 @@ test.serial('github - API rate limit exceeded without token', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'API rate limit of 60 requests per hour exceeded. Use a personal token to increase the number of requests'
}
]);
Expand All @@ -236,7 +236,7 @@ test.serial('github - API offline', async t => {
const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/github',
ruleId: 'awesome-github',
message: 'There was a problem trying to connect to GitHub: getaddrinfo ENOTFOUND api.github.com api.github.com:443'
}
]);
Expand Down
8 changes: 4 additions & 4 deletions test/rules/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('heading - missing', async t => {
const messages = await lint({config, filename: 'test/fixtures/heading/error0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/heading',
ruleId: 'awesome-heading',
message: 'Missing main list heading'
}
]);
Expand All @@ -22,7 +22,7 @@ test('heading - not in title case', async t => {
const messages = await lint({config, filename: 'test/fixtures/heading/error1.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/heading',
ruleId: 'awesome-heading',
message: 'Main heading must be in title case'
}
]);
Expand All @@ -32,7 +32,7 @@ test('heading - more than one heading', async t => {
const messages = await lint({config, filename: 'test/fixtures/heading/error2.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/heading',
ruleId: 'awesome-heading',
message: 'List can only have one heading'
}
]);
Expand All @@ -42,7 +42,7 @@ test('heading - depth is bigger than 1', async t => {
const messages = await lint({config, filename: 'test/fixtures/heading/error3.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/heading',
ruleId: 'awesome-heading',
message: 'Main list heading must be of depth 1'
}
]);
Expand Down
10 changes: 5 additions & 5 deletions test/rules/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('license - missing', async t => {
const messages = await lint({config, filename: 'test/fixtures/license/error0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/license',
ruleId: 'awesome-license',
message: 'Missing License section'
}
]);
Expand All @@ -27,7 +27,7 @@ test('license - empty', async t => {
message: 'Remove empty section: "License"'
},
{
ruleId: 'awesome/license',
ruleId: 'awesome-license',
message: 'License must not be empty'
}
]);
Expand All @@ -37,7 +37,7 @@ test('license - not last section', async t => {
const messages = await lint({config, filename: 'test/fixtures/license/error2.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/license',
ruleId: 'awesome-license',
message: 'License must be the last section'
}
]);
Expand All @@ -47,7 +47,7 @@ test('license - incorrect heading depth', async t => {
const messages = await lint({config, filename: 'test/fixtures/license/error3.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/license',
ruleId: 'awesome-license',
message: 'License section must be at heading depth 2'
}
]);
Expand All @@ -57,7 +57,7 @@ test('license - png image', async t => {
const messages = await lint({config, filename: 'test/fixtures/license/error4.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/license',
ruleId: 'awesome-license',
message: 'License image must be SVG'
}
]);
Expand Down
5 changes: 5 additions & 0 deletions test/rules/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ test('list-item - valid ignoring Contents section', async t => {
const messages = await lint({config, filename: 'test/fixtures/list-item/2.md'});
t.deepEqual(messages, []);
});

test('list-item - disable by remark-message-control', async t => {
const messages = await lint({config, filename: 'test/fixtures/list-item/4.md'});
t.deepEqual(messages, []);
});
4 changes: 2 additions & 2 deletions test/rules/no-ci-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ test('no-ci-badge - missing', async t => {
const messages = await lint({config, filename: 'test/fixtures/no-ci-badge/0.md'});
t.deepEqual(messages, [
{
ruleId: 'awesome/no-ci-badge',
ruleId: 'awesome-no-ci-badge',
message: 'Readme must not contain CI badge'
},
{
ruleId: 'awesome/no-ci-badge',
ruleId: 'awesome-no-ci-badge',
message: 'Readme must not contain CI badge'
}
]);
Expand Down
Loading