Skip to content

Commit 15f8835

Browse files
committed
get rid of functions
1 parent 01ac0a2 commit 15f8835

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

lib/rules/forbid-component-props.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ module.exports = {
141141
const propPattern = value.propNamePattern;
142142
const prop = propName || propPattern;
143143
const options = {
144-
allowList: typeof value === 'string' ? [] : (value.allowedFor || []),
145-
allowPatternList: typeof value === 'string' ? [] : value.allowedForPatterns || [],
146-
disallowList: typeof value === 'string' ? [] : (value.disallowedFor || []),
147-
disallowPatternList: typeof value === 'string' ? [] : value.disallowedForPatterns || [],
144+
allowList: [].concat(value.allowedFor || []),
145+
allowPatternList: [].concat(value.allowedForPatterns || []),
146+
disallowList: [].concat(value.disallowedFor || []),
147+
disallowPatternList: [].concat(value.disallowedForPatterns || []),
148148
message: typeof value === 'string' ? null : value.message,
149149
isPattern: !!value.propNamePattern,
150150
};
@@ -169,11 +169,11 @@ module.exports = {
169169
return false;
170170
}
171171

172-
function checkIsTagForbiddenByAllowList() {
173-
return options.allowList.indexOf(tagName) === -1;
174-
}
172+
function checkIsTagForbiddenByAllowOptions() {
173+
if (options.allowList.indexOf(tagName) !== -1) {
174+
return false;
175+
}
175176

176-
function checkIsTagForbiddenByAllowPatternList() {
177177
if (options.allowPatternList.length === 0) {
178178
return true;
179179
}
@@ -183,15 +183,11 @@ module.exports = {
183183
);
184184
}
185185

186-
function checkIsTagForbiddenByAllowOptions() {
187-
return checkIsTagForbiddenByAllowList() && checkIsTagForbiddenByAllowPatternList();
188-
}
189-
190-
function checkIsTagForbiddenByDisallowList() {
191-
return options.disallowList.indexOf(tagName) !== -1;
192-
}
186+
function checkIsTagForbiddenByDisallowOptions() {
187+
if (options.disallowList.indexOf(tagName) !== -1) {
188+
return true;
189+
}
193190

194-
function checkIsTagForbiddenByDisallowPatternList() {
195191
if (options.disallowPatternList.length === 0) {
196192
return false;
197193
}
@@ -201,10 +197,6 @@ module.exports = {
201197
);
202198
}
203199

204-
function checkIsTagForbiddenByDisallowOptions() {
205-
return checkIsTagForbiddenByDisallowList() || checkIsTagForbiddenByDisallowPatternList();
206-
}
207-
208200
const hasDisallowOptions = options.disallowList.length > 0 || options.disallowPatternList.length > 0;
209201

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

0 commit comments

Comments
 (0)