Skip to content

Commit

Permalink
get rid of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Efimenko committed Sep 19, 2024
1 parent 01ac0a2 commit 15f8835
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ module.exports = {
const propPattern = value.propNamePattern;
const prop = propName || propPattern;
const options = {
allowList: typeof value === 'string' ? [] : (value.allowedFor || []),
allowPatternList: typeof value === 'string' ? [] : value.allowedForPatterns || [],
disallowList: typeof value === 'string' ? [] : (value.disallowedFor || []),
disallowPatternList: typeof value === 'string' ? [] : value.disallowedForPatterns || [],
allowList: [].concat(value.allowedFor || []),
allowPatternList: [].concat(value.allowedForPatterns || []),
disallowList: [].concat(value.disallowedFor || []),
disallowPatternList: [].concat(value.disallowedForPatterns || []),
message: typeof value === 'string' ? null : value.message,
isPattern: !!value.propNamePattern,
};
Expand All @@ -169,11 +169,11 @@ module.exports = {
return false;
}

function checkIsTagForbiddenByAllowList() {
return options.allowList.indexOf(tagName) === -1;
}
function checkIsTagForbiddenByAllowOptions() {
if (options.allowList.indexOf(tagName) !== -1) {
return false;
}

function checkIsTagForbiddenByAllowPatternList() {
if (options.allowPatternList.length === 0) {
return true;
}
Expand All @@ -183,15 +183,11 @@ module.exports = {
);
}

function checkIsTagForbiddenByAllowOptions() {
return checkIsTagForbiddenByAllowList() && checkIsTagForbiddenByAllowPatternList();
}

function checkIsTagForbiddenByDisallowList() {
return options.disallowList.indexOf(tagName) !== -1;
}
function checkIsTagForbiddenByDisallowOptions() {
if (options.disallowList.indexOf(tagName) !== -1) {
return true;
}

function checkIsTagForbiddenByDisallowPatternList() {
if (options.disallowPatternList.length === 0) {
return false;
}
Expand All @@ -201,10 +197,6 @@ module.exports = {
);
}

function checkIsTagForbiddenByDisallowOptions() {
return checkIsTagForbiddenByDisallowList() || checkIsTagForbiddenByDisallowPatternList();
}

const hasDisallowOptions = options.disallowList.length > 0 || options.disallowPatternList.length > 0;

// disallowList should have a least one item (schema configuration)
Expand Down

0 comments on commit 15f8835

Please sign in to comment.