Skip to content

Commit

Permalink
Improve internal naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 20, 2020
1 parent 9c81265 commit 3bb2e58
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions rules/badge.js
Expand Up @@ -2,19 +2,19 @@
const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');

const badgeUrlWhitelist = new Set([
const badgeUrlAllowList = new Set([
'https://awesome.re',
'https://github.com/sindresorhus/awesome'
]);

const badgeSrcUrlWhitelist = new Set([
const badgeSrcUrlAllowList = new Set([
'https://awesome.re/badge.svg',
'https://awesome.re/badge-flat.svg',
'https://awesome.re/badge-flat2.svg'
]);

const isValidBadgeUrl = url => badgeUrlWhitelist.has(url);
const isValidBadgeSrcUrl = url => badgeSrcUrlWhitelist.has(url);
const isValidBadgeUrl = url => badgeUrlAllowList.has(url);
const isValidBadgeSrcUrl = url => badgeSrcUrlAllowList.has(url);

module.exports = rule('remark-lint:awesome-badge', (ast, file) => {
visit(ast, 'heading', (node, index) => {
Expand Down
4 changes: 2 additions & 2 deletions rules/heading.js
Expand Up @@ -3,7 +3,7 @@ const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');
const {of: caseOf, title: titleCase} = require('case');

const listHeadingCaseWhitelist = new Set([
const listHeadingCaseAllowList = new Set([
'title',
'capital'
]);
Expand Down Expand Up @@ -31,7 +31,7 @@ module.exports = rule('remark-lint:awesome-heading', (ast, file) => {

const headingText = child.value;

if (!listHeadingCaseWhitelist.has(caseOf(headingText)) && titleCase(headingText) !== headingText) {
if (!listHeadingCaseAllowList.has(caseOf(headingText)) && titleCase(headingText) !== headingText) {
file.message('Main heading must be in title case', node);
}
}
Expand Down
20 changes: 10 additions & 10 deletions rules/list-item.js
Expand Up @@ -7,10 +7,10 @@ const isUrl = require('is-url-superb');
const rule = require('unified-lint-rule');
const toString = require('mdast-util-to-string');
const visit = require('unist-util-visit');
const identifierWhitelist = require('../lib/identifier-whitelist');
const identifierAllowList = require('../lib/identifier-allow-list');

// Valid casings for first text word in list item descriptions
const listItemPrefixCaseWhitelist = new Set([
const listItemPrefixCaseAllowList = new Set([
'camel',
'capital',
'constant',
Expand All @@ -19,14 +19,14 @@ const listItemPrefixCaseWhitelist = new Set([
]);

// Valid node types in list item link
const listItemLinkNodeWhitelist = new Set([
const listItemLinkNodeAllowList = new Set([
'emphasis',
'inlineCode',
'text'
]);

// Valid node types in list item descriptions
const listItemDescriptionNodeWhitelist = new Set([
const listItemDescriptionNodeAllowList = new Set([
'emphasis',
'footnoteReference',
'html',
Expand All @@ -39,7 +39,7 @@ const listItemDescriptionNodeWhitelist = new Set([
]);

// Valid node types in list item description suffix
const listItemDescriptionSuffixNodeWhitelist = new Set([
const listItemDescriptionSuffixNodeAllowList = new Set([
'emphasis',
'html',
'image',
Expand Down Expand Up @@ -133,7 +133,7 @@ function validateListItemLink(link, file) {
}

for (const node of link.children) {
if (!listItemLinkNodeWhitelist.has(node.type)) {
if (!listItemLinkNodeAllowList.has(node.type)) {
file.message('Invalid list item link', node);
return false;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ function validateListItemDescription(description, file) {
}

// Ensure description ends with an acceptable node type
if (!listItemDescriptionSuffixNodeWhitelist.has(suffix.type)) {
if (!listItemDescriptionSuffixNodeAllowList.has(suffix.type)) {
file.message('List item description must end with proper punctuation', suffix);
return false;
}
Expand All @@ -196,7 +196,7 @@ function validateListItemDescription(description, file) {
} else {
// Description contains mixed node types
for (const node of description) {
if (!listItemDescriptionNodeWhitelist.has(node.type)) {
if (!listItemDescriptionNodeAllowList.has(node.type)) {
file.message('List item description contains invalid markdown', node);
return false;
}
Expand Down Expand Up @@ -250,9 +250,9 @@ function validateListItemPrefixCasing(prefix, file) {
return false;
}

if (!listItemPrefixCaseWhitelist.has(caseOf(firstWord))) {
if (!listItemPrefixCaseAllowList.has(caseOf(firstWord))) {
if (!/\d/.test(firstWord) && !/^["“'(]/.test(firstWord)) {
if (!identifierWhitelist.has(firstWord)) {
if (!identifierAllowList.has(firstWord)) {
file.message('List item description must start with valid casing', prefix);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions rules/spell-check.js
Expand Up @@ -5,7 +5,7 @@ const visit = require('unist-util-visit');
const arrify = require('arrify');
const spellCheckRules = require('../lib/spell-check-rules');

const wordBreakCharacterWhitelist = new Set([
const wordBreakCharacterAllowList = new Set([
'-'
]);

Expand Down Expand Up @@ -39,11 +39,11 @@ module.exports = rule('remark-lint:awesome-spell-check', (ast, file) => {
const previousCharacter = sanitizedValue[match.index - 1];
const nextCharacter = sanitizedValue[match.index + match[0].length];

if (wordBreakCharacterWhitelist.has(previousCharacter)) {
if (wordBreakCharacterAllowList.has(previousCharacter)) {
continue;
}

if (wordBreakCharacterWhitelist.has(nextCharacter)) {
if (wordBreakCharacterAllowList.has(nextCharacter)) {
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions rules/toc.js
Expand Up @@ -12,7 +12,7 @@ const slugger = new GitHubSlugger();

const maxListItemDepth = 1;

const sectionHeadingBlacklist = new Set([
const sectionHeadingDenylist = new Set([
'Contributing',
'Footnotes'
]);
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = rule('remark-lint:awesome-toc', (ast, file) => {
const headingsPost = findAllAfter(ast, toc, {
type: 'heading',
depth: 2
}).filter(node => !sectionHeadingBlacklist.has(toString(node)));
}).filter(node => !sectionHeadingDenylist.has(toString(node)));

if (headingsPost.length === 0) {
file.message('Missing content headers', ast);
Expand Down Expand Up @@ -117,7 +117,7 @@ function validateListItems({ast, file, list, headingLinks, headings, depth}) {
}

if (!headingText) {
if (sectionHeadingBlacklist.has(text)) {
if (sectionHeadingDenylist.has(text)) {
file.message(`ToC should not contain section "${text}"`, listItem);
} else {
file.message(`ToC item "${text}" missing corresponding heading`, listItem);
Expand Down

0 comments on commit 3bb2e58

Please sign in to comment.