Changeset 0c6b92a for imaps-frontend/node_modules/eslint-plugin-react/lib/rules/forbid-component-props.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/forbid-component-props.js
rd565449 r0c6b92a 53 53 items: { type: 'string' }, 54 54 }, 55 allowedForPatterns: { 56 type: 'array', 57 uniqueItems: true, 58 items: { type: 'string' }, 59 }, 55 60 message: { type: 'string' }, 56 61 }, … … 67 72 items: { type: 'string' }, 68 73 }, 69 message: { type: 'string' }, 70 }, 71 required: ['disallowedFor'], 72 additionalProperties: false, 73 }, 74 74 disallowedForPatterns: { 75 type: 'array', 76 uniqueItems: true, 77 minItems: 1, 78 items: { type: 'string' }, 79 }, 80 message: { type: 'string' }, 81 }, 82 anyOf: [ 83 { required: ['disallowedFor'] }, 84 { required: ['disallowedForPatterns'] }, 85 ], 86 additionalProperties: false, 87 }, 75 88 { 76 89 type: 'object', … … 82 95 items: { type: 'string' }, 83 96 }, 97 allowedForPatterns: { 98 type: 'array', 99 uniqueItems: true, 100 items: { type: 'string' }, 101 }, 84 102 message: { type: 'string' }, 85 103 }, … … 96 114 items: { type: 'string' }, 97 115 }, 98 message: { type: 'string' }, 99 }, 100 required: ['disallowedFor'], 116 disallowedForPatterns: { 117 type: 'array', 118 uniqueItems: true, 119 minItems: 1, 120 items: { type: 'string' }, 121 }, 122 message: { type: 'string' }, 123 }, 124 anyOf: [ 125 { required: ['disallowedFor'] }, 126 { required: ['disallowedForPatterns'] }, 127 ], 101 128 additionalProperties: false, 102 129 }, … … 115 142 const prop = propName || propPattern; 116 143 const options = { 117 allowList: typeof value === 'string' ? [] : (value.allowedFor || []), 118 disallowList: typeof value === 'string' ? [] : (value.disallowedFor || []), 144 allowList: [].concat(value.allowedFor || []), 145 allowPatternList: [].concat(value.allowedForPatterns || []), 146 disallowList: [].concat(value.disallowedFor || []), 147 disallowPatternList: [].concat(value.disallowedForPatterns || []), 119 148 message: typeof value === 'string' ? null : value.message, 120 149 isPattern: !!value.propNamePattern, … … 141 170 } 142 171 172 function checkIsTagForbiddenByAllowOptions() { 173 if (options.allowList.indexOf(tagName) !== -1) { 174 return false; 175 } 176 177 if (options.allowPatternList.length === 0) { 178 return true; 179 } 180 181 return options.allowPatternList.every( 182 (pattern) => !minimatch(tagName, pattern) 183 ); 184 } 185 186 function checkIsTagForbiddenByDisallowOptions() { 187 if (options.disallowList.indexOf(tagName) !== -1) { 188 return true; 189 } 190 191 if (options.disallowPatternList.length === 0) { 192 return false; 193 } 194 195 return options.disallowPatternList.some( 196 (pattern) => minimatch(tagName, pattern) 197 ); 198 } 199 200 const hasDisallowOptions = options.disallowList.length > 0 || options.disallowPatternList.length > 0; 201 143 202 // disallowList should have a least one item (schema configuration) 144 const isTagForbidden = options.disallowList.length > 0145 ? options.disallowList.indexOf(tagName) !== -1146 : options.allowList.indexOf(tagName) === -1;203 const isTagForbidden = hasDisallowOptions 204 ? checkIsTagForbiddenByDisallowOptions() 205 : checkIsTagForbiddenByAllowOptions(); 147 206 148 207 // if the tagName is undefined (`<this.something>`), we assume it's a forbidden element
Note:
See TracChangeset
for help on using the changeset viewer.