- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- Location:
- imaps-frontend/node_modules/eslint-plugin-react/lib/rules
- Files:
-
- 209 added
- 67 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js
rd565449 r0c6b92a 11 11 const Components = require('../util/Components'); 12 12 const propsUtil = require('../util/props'); 13 const astUtil = require('../util/ast'); 13 14 const docsUrl = require('../util/docsUrl'); 14 15 const propWrapperUtil = require('../util/propWrapper'); … … 18 19 const getSourceCode = eslintUtil.getSourceCode; 19 20 const getText = eslintUtil.getText; 21 22 /** 23 * Checks if prop is nested 24 * @param {Object} prop Property object, single prop type declaration 25 * @returns {boolean} 26 */ 27 function nestedPropTypes(prop) { 28 return ( 29 prop.type === 'Property' 30 && astUtil.isCallExpression(prop.value) 31 ); 32 } 20 33 21 34 // ------------------------------------------------------------------------------ … … 129 142 * Checks if prop is declared in flow way 130 143 * @param {Object} prop Property object, single prop type declaration 131 * @returns { Boolean}144 * @returns {boolean} 132 145 */ 133 146 function flowCheck(prop) { … … 142 155 * Checks if prop is declared in regular way 143 156 * @param {Object} prop Property object, single prop type declaration 144 * @returns { Boolean}157 * @returns {boolean} 145 158 */ 146 159 function regularCheck(prop) { … … 164 177 165 178 /** 166 * Checks if prop is nested167 * @param {Object} prop Property object, single prop type declaration168 * @returns {Boolean}169 */170 function nestedPropTypes(prop) {171 return (172 prop.type === 'Property'173 && prop.value.type === 'CallExpression'174 );175 }176 177 /**178 179 * Runs recursive check on all proptypes 179 180 * @param {Array} proptypes A list of Property object (for each proptype defined) … … 181 182 */ 182 183 function runCheck(proptypes, addInvalidProp) { 183 (proptypes || []).forEach((prop) => { 184 if (config.validateNested && nestedPropTypes(prop)) { 185 runCheck(prop.value.arguments[0].properties, addInvalidProp); 186 return; 187 } 188 if (flowCheck(prop) || regularCheck(prop) || tsCheck(prop)) { 189 addInvalidProp(prop); 190 } 191 }); 184 if (proptypes) { 185 proptypes.forEach((prop) => { 186 if (config.validateNested && nestedPropTypes(prop)) { 187 runCheck(prop.value.arguments[0].properties, addInvalidProp); 188 return; 189 } 190 if (flowCheck(prop) || regularCheck(prop) || tsCheck(prop)) { 191 addInvalidProp(prop); 192 } 193 }); 194 } 192 195 } 193 196 … … 257 260 } 258 261 259 const annotationTypeParams = component.node.parent.id.typeAnnotation.typeAnnotation.typeParameters; 262 const annotationTypeArguments = propsUtil.getTypeArguments( 263 component.node.parent.id.typeAnnotation.typeAnnotation 264 ); 260 265 if ( 261 annotationType Params && (262 annotationType Params.type === 'TSTypeParameterInstantiation'263 || annotationType Params.type === 'TypeParameterInstantiation'266 annotationTypeArguments && ( 267 annotationTypeArguments.type === 'TSTypeParameterInstantiation' 268 || annotationTypeArguments.type === 'TypeParameterInstantiation' 264 269 ) 265 270 ) { 266 return annotationType Params.params.find(271 return annotationTypeArguments.params.find( 267 272 (param) => param.type === 'TSTypeReference' || param.type === 'GenericTypeAnnotation' 268 273 ); … … 310 315 if ( 311 316 node.value 312 && node.value.type === 'CallExpression'317 && astUtil.isCallExpression(node.value) 313 318 && propWrapperUtil.isPropWrapperFunction( 314 319 context, … … 336 341 const right = node.parent.right; 337 342 if ( 338 right.type === 'CallExpression'343 astUtil.isCallExpression(right) 339 344 && propWrapperUtil.isPropWrapperFunction( 340 345 context, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/button-has-type.js
rd565449 r0c6b92a 29 29 }; 30 30 31 /** @type {import('eslint').Rule.RuleModule} */ 31 32 module.exports = { 32 33 meta: { … … 150 151 151 152 const props = node.arguments[1].properties; 152 const typeProp = props.find((prop) => prop.key && prop.key.name === 'type'); 153 const typeProp = props.find((prop) => ( 154 'key' in prop 155 && prop.key 156 && 'name' in prop.key 157 && prop.key.name === 'type' 158 )); 153 159 154 160 if (!typeProp) { … … 157 163 } 158 164 159 checkExpression(node, typeProp.value);165 checkExpression(node, 'value' in typeProp ? typeProp.value : undefined); 160 166 }, 161 167 }; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/checked-requires-onchange-or-readonly.js
rd565449 r0c6b92a 25 25 26 26 /** 27 * @param { string[]} properties27 * @param {object[]} properties 28 28 * @param {string} keyName 29 29 * @returns {Set<string>} … … 42 42 } 43 43 44 /** @type {import('eslint').Rule.RuleModule} */ 44 45 module.exports = { 45 46 meta: { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/destructuring-assignment.js
rd565449 r0c6b92a 182 182 } 183 183 184 // valid-jsdoc cannot read function types 185 // eslint-disable-next-line valid-jsdoc 186 /** 187 * Find a parent that satisfy the given predicate 188 * @param {ASTNode} node 189 * @param {(node: ASTNode) => boolean} predicate 190 * @returns {ASTNode | undefined} 191 */ 192 function findParent(node, predicate) { 193 let n = node; 194 while (n) { 195 if (predicate(n)) { 196 return n; 197 } 198 n = n.parent; 199 } 200 return undefined; 201 } 202 184 203 return { 185 204 … … 197 216 198 217 MemberExpression(node) { 199 let scope = getScope(context, node); 200 let SFCComponent = components.get(scope.block); 201 while (!SFCComponent && scope.upper && scope.upper !== scope) { 202 SFCComponent = components.get(scope.upper.block); 203 scope = scope.upper; 204 } 218 const SFCComponent = utils.getParentStatelessComponent(node); 205 219 if (SFCComponent) { 206 220 handleSFCUsage(node); … … 210 224 if (classComponent) { 211 225 handleClassUsage(node); 226 } 227 }, 228 229 TSQualifiedName(node) { 230 if (configuration !== 'always') { 231 return; 232 } 233 // handle `typeof props.a.b` 234 if (node.left.type === 'Identifier' 235 && node.left.name === sfcParams.propsName() 236 && findParent(node, (n) => n.type === 'TSTypeQuery') 237 && utils.getParentStatelessComponent(node) 238 ) { 239 report(context, messages.useDestructAssignment, 'useDestructAssignment', { 240 node, 241 data: { 242 type: 'props', 243 }, 244 }); 212 245 } 213 246 }, … … 258 291 return; 259 292 } 293 260 294 // Skip if props is used elsewhere 261 295 if (propsRefs.length > 1) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/display-name.js
rd565449 r0c6b92a 74 74 * Checks if React.forwardRef is nested inside React.memo 75 75 * @param {ASTNode} node The AST node being checked. 76 * @returns { Boolean} True if React.forwardRef is nested inside React.memo, false if not.76 * @returns {boolean} True if React.forwardRef is nested inside React.memo, false if not. 77 77 */ 78 78 function isNestedMemo(node) { 79 const argumentIsCallExpression = node.arguments && node.arguments[0] && node.arguments[0].type === 'CallExpression'; 80 81 return node.type === 'CallExpression' && argumentIsCallExpression && utils.isPragmaComponentWrapper(node); 79 return astUtil.isCallExpression(node) 80 && node.arguments 81 && astUtil.isCallExpression(node.arguments[0]) 82 && utils.isPragmaComponentWrapper(node); 82 83 } 83 84 … … 112 113 * Checks if the component have a name set by the transpiler 113 114 * @param {ASTNode} node The AST node being checked. 114 * @returns { Boolean} True if component has a name, false if not.115 * @returns {boolean} True if component has a name, false if not. 115 116 */ 116 117 function hasTranspilerName(node) { … … 199 200 return; 200 201 } 201 markDisplayNameAsDeclared( component.node.type === 'TSAsExpression' ? component.node.expression : component.node);202 markDisplayNameAsDeclared(astUtil.unwrapTSAsExpression(component.node)); 202 203 }, 203 204 -
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 -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/forbid-elements.js
rd565449 r0c6b92a 21 21 }; 22 22 23 /** @type {import('eslint').Rule.RuleModule} */ 23 24 module.exports = { 24 25 meta: { … … 106 107 } 107 108 108 const argType = argument.type; 109 110 if (argType === 'Identifier' && /^[A-Z_]/.test(argument.name)) { 109 if (argument.type === 'Identifier' && /^[A-Z_]/.test(argument.name)) { 111 110 reportIfForbidden(argument.name, argument); 112 } else if (arg Type === 'Literal' && /^[a-z][^.]*$/.test(argument.value)) {111 } else if (argument.type === 'Literal' && /^[a-z][^.]*$/.test(String(argument.value))) { 113 112 reportIfForbidden(argument.value, argument); 114 } else if (arg Type === 'MemberExpression') {113 } else if (argument.type === 'MemberExpression') { 115 114 reportIfForbidden(getText(context, argument), argument); 116 115 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/forbid-foreign-prop-types.js
rd565449 r0c6b92a 14 14 }; 15 15 16 /** @type {import('eslint').Rule.RuleModule} */ 16 17 module.exports = { 17 18 meta: { … … 109 110 && !isAllowedAssignment(node) 110 111 )) || ( 112 // @ts-expect-error The JSXText type is not present in the estree type definitions 111 113 (node.property.type === 'Literal' || node.property.type === 'JSXText') 114 && 'value' in node.property 112 115 && node.property.value === 'propTypes' 113 116 && !ast.isAssignmentLHS(node) … … 122 125 123 126 ObjectPattern(node) { 124 const propTypesNode = node.properties.find((property) => property.type === 'Property' && property.key.name === 'propTypes'); 127 const propTypesNode = node.properties.find((property) => ( 128 property.type === 'Property' 129 && 'name' in property.key 130 && property.key.name === 'propTypes' 131 )); 125 132 126 133 if (propTypesNode) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/forbid-prop-types.js
rd565449 r0c6b92a 27 27 }; 28 28 29 /** @type {import('eslint').Rule.RuleModule} */ 29 30 module.exports = { 30 31 meta: { … … 135 136 value = value.object; 136 137 } 137 if ( value.type === 'CallExpression') {138 if (astUtil.isCallExpression(value)) { 138 139 if (!isPropTypesPackage(value.callee)) { 139 140 return; … … 159 160 160 161 function checkNode(node) { 161 switch (node && node.type) {162 case 'ObjectExpression':163 checkProperties(node.properties);164 break; 165 case 'Identifier':{166 const propTypesObject = variableUtil.findVariableByName(context, node, node.name);167 if (propTypesObject && propTypesObject.properties) {168 checkProperties(propTypesObject.properties);169 }170 break;171 } 172 case 'CallExpression':{173 174 175 162 if (!node) { 163 return; 164 } 165 166 if (node.type === 'ObjectExpression') { 167 checkProperties(node.properties); 168 } else if (node.type === 'Identifier') { 169 const propTypesObject = variableUtil.findVariableByName(context, node, node.name); 170 if (propTypesObject && propTypesObject.properties) { 171 checkProperties(propTypesObject.properties); 172 } 173 } else if (astUtil.isCallExpression(node)) { 174 const innerNode = node.arguments && node.arguments[0]; 175 if ( 176 propWrapperUtil.isPropWrapperFunction(context, getText(context, node.callee)) 176 177 && innerNode 177 ) { 178 checkNode(innerNode); 179 } 180 break; 181 } 182 default: 183 break; 178 ) { 179 checkNode(innerNode); 180 } 184 181 } 185 182 } … … 197 194 if (node.specifiers.length >= 1) { 198 195 const propTypesSpecifier = node.specifiers.find((specifier) => ( 199 specifier.imported && specifier.imported.name === 'PropTypes' 196 'imported' in specifier 197 && specifier.imported 198 && specifier.imported.name === 'PropTypes' 200 199 )); 201 200 if (propTypesSpecifier) { … … 233 232 } 234 233 235 checkNode( node.parent.right);234 checkNode('right' in node.parent && node.parent.right); 236 235 }, 237 236 238 237 CallExpression(node) { 239 238 if ( 240 node.callee.object 239 node.callee.type === 'MemberExpression' 240 && node.callee.object 241 241 && !isPropTypesPackage(node.callee.object) 242 242 && !propsUtil.isPropTypesDeclaration(node.callee) … … 247 247 if ( 248 248 node.arguments.length > 0 249 && (node.callee.name === 'shape' || astUtil.getPropertyName(node.callee) === 'shape') 250 ) { 251 checkProperties(node.arguments[0].properties); 249 && ( 250 ('name' in node.callee && node.callee.name === 'shape') 251 || astUtil.getPropertyName(node.callee) === 'shape' 252 ) 253 ) { 254 checkProperties('properties' in node.arguments[0] && node.arguments[0].properties); 252 255 } 253 256 }, … … 272 275 ObjectExpression(node) { 273 276 node.properties.forEach((property) => { 274 if (! property.key) {277 if (!('key' in property) || !property.key) { 275 278 return; 276 279 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/function-component-definition.js
rd565449 r0c6b92a 11 11 const reportC = require('../util/report'); 12 12 const getText = require('../util/eslint').getText; 13 const propsUtil = require('../util/props'); 13 14 14 15 // ------------------------------------------------------------------------------ … … 35 36 36 37 function hasOneUnconstrainedTypeParam(node) { 37 const nodeType Params = node.typeParameters;38 39 return nodeType Params40 && nodeType Params.params41 && nodeType Params.params.length === 142 && !nodeType Params.params[0].constraint;38 const nodeTypeArguments = propsUtil.getTypeArguments(node); 39 40 return nodeTypeArguments 41 && nodeTypeArguments.params 42 && nodeTypeArguments.params.length === 1 43 && !nodeTypeArguments.params[0].constraint; 43 44 } 44 45 … … 203 204 } 204 205 206 const nodeTypeArguments = propsUtil.getTypeArguments(node); 205 207 return (fixer) => fixer.replaceTextRange( 206 208 options.range, 207 209 buildFunction(options.template, { 208 210 typeAnnotation, 209 typeParams: getNodeText(node .typeParameters, source),211 typeParams: getNodeText(nodeTypeArguments, source), 210 212 params: getParams(node, source), 211 213 returnType: getNodeText(node.returnType, source), -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/hook-use-state.js
rd565449 r0c6b92a 27 27 }; 28 28 29 /** @type {import('eslint').Rule.RuleModule} */ 29 30 module.exports = { 30 31 meta: { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/index.js
rd565449 r0c6b92a 16 16 'forbid-foreign-prop-types': require('./forbid-foreign-prop-types'), 17 17 'forbid-prop-types': require('./forbid-prop-types'), 18 'forward-ref-uses-ref': require('./forward-ref-uses-ref'), 18 19 'function-component-definition': require('./function-component-definition'), 19 20 'hook-use-state': require('./hook-use-state'), -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-closing-bracket-location.js
rd565449 r0c6b92a 21 21 }; 22 22 23 /** @type {import('eslint').Rule.RuleModule} */ 23 24 module.exports = { 24 25 meta: { … … 101 102 * Get expected location for the closing bracket 102 103 * @param {Object} tokens Locations of the opening bracket, closing bracket and last prop 103 * @return { String} Expected location for the closing bracket104 * @return {string} Expected location for the closing bracket 104 105 */ 105 106 function getExpectedLocation(tokens) { … … 122 123 * expected location. 123 124 * @param {Object} tokens Locations of the opening bracket, closing bracket and last prop 124 * @param { String} expectedLocation Expected location for the closing bracket125 * @param {string} expectedLocation Expected location for the closing bracket 125 126 * @return {?Number} The correct column for the closing bracket, or null 126 127 */ … … 141 142 * Check if the closing bracket is correctly located 142 143 * @param {Object} tokens Locations of the opening bracket, closing bracket and last prop 143 * @param { String} expectedLocation Expected location for the closing bracket144 * @return { Boolean} True if the closing bracket is correctly located, false if not144 * @param {string} expectedLocation Expected location for the closing bracket 145 * @return {boolean} True if the closing bracket is correctly located, false if not 145 146 */ 146 147 function hasCorrectLocation(tokens, expectedLocation) { … … 164 165 * Get the characters used for indentation on the line to be matched 165 166 * @param {Object} tokens Locations of the opening bracket, closing bracket and last prop 166 * @param { String} expectedLocation Expected location for the closing bracket167 * @param { Number} [correctColumn] Expected column for the closing bracket. Default to 0168 * @return { String} The characters used for indentation167 * @param {string} expectedLocation Expected location for the closing bracket 168 * @param {number} [correctColumn] Expected column for the closing bracket. Default to 0 169 * @return {string} The characters used for indentation 169 170 */ 170 171 function getIndentation(tokens, expectedLocation, correctColumn) { … … 236 237 * 237 238 * @param {ASTNode} node The AST node being checked. 238 * @returns { String} Unique ID (based on its range)239 * @returns {string} Unique ID (based on its range) 239 240 */ 240 241 function getOpeningElementId(node) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-curly-brace-presence.js
rd565449 r0c6b92a 31 31 ]; 32 32 const DEFAULT_CONFIG = { props: OPTION_NEVER, children: OPTION_NEVER, propElementValues: OPTION_IGNORE }; 33 34 const HTML_ENTITY_REGEX = () => /&[A-Za-z\d#]+;/g; 35 36 function containsLineTerminators(rawStringValue) { 37 return /[\n\r\u2028\u2029]/.test(rawStringValue); 38 } 39 40 function containsBackslash(rawStringValue) { 41 return arrayIncludes(rawStringValue, '\\'); 42 } 43 44 function containsHTMLEntity(rawStringValue) { 45 return HTML_ENTITY_REGEX().test(rawStringValue); 46 } 47 48 function containsOnlyHtmlEntities(rawStringValue) { 49 return rawStringValue.replace(HTML_ENTITY_REGEX(), '').trim() === ''; 50 } 51 52 function containsDisallowedJSXTextChars(rawStringValue) { 53 return /[{<>}]/.test(rawStringValue); 54 } 55 56 function containsQuoteCharacters(value) { 57 return /['"]/.test(value); 58 } 59 60 function containsMultilineComment(value) { 61 return /\/\*/.test(value); 62 } 63 64 function escapeDoubleQuotes(rawStringValue) { 65 return rawStringValue.replace(/\\"/g, '"').replace(/"/g, '\\"'); 66 } 67 68 function escapeBackslashes(rawStringValue) { 69 return rawStringValue.replace(/\\/g, '\\\\'); 70 } 71 72 function needToEscapeCharacterForJSX(raw, node) { 73 return ( 74 containsBackslash(raw) 75 || containsHTMLEntity(raw) 76 || (node.parent.type !== 'JSXAttribute' && containsDisallowedJSXTextChars(raw)) 77 ); 78 } 79 80 function containsWhitespaceExpression(child) { 81 if (child.type === 'JSXExpressionContainer') { 82 const value = child.expression.value; 83 return value ? jsxUtil.isWhiteSpaces(value) : false; 84 } 85 return false; 86 } 87 88 function isLineBreak(text) { 89 return containsLineTerminators(text) && text.trim() === ''; 90 } 91 92 function wrapNonHTMLEntities(text) { 93 const HTML_ENTITY = '<HTML_ENTITY>'; 94 const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map((word) => ( 95 word === '' ? '' : `{${JSON.stringify(word)}}` 96 )).join(HTML_ENTITY); 97 98 const htmlEntities = text.match(HTML_ENTITY_REGEX()); 99 return htmlEntities.reduce((acc, htmlEntity) => ( 100 acc.replace(HTML_ENTITY, htmlEntity) 101 ), withCurlyBraces); 102 } 103 104 function wrapWithCurlyBraces(rawText) { 105 if (!containsLineTerminators(rawText)) { 106 return `{${JSON.stringify(rawText)}}`; 107 } 108 109 return rawText.split('\n').map((line) => { 110 if (line.trim() === '') { 111 return line; 112 } 113 const firstCharIndex = line.search(/[^\s]/); 114 const leftWhitespace = line.slice(0, firstCharIndex); 115 const text = line.slice(firstCharIndex); 116 117 if (containsHTMLEntity(line)) { 118 return `${leftWhitespace}${wrapNonHTMLEntities(text)}`; 119 } 120 return `${leftWhitespace}{${JSON.stringify(text)}}`; 121 }).join('\n'); 122 } 123 124 function isWhiteSpaceLiteral(node) { 125 return node.type && node.type === 'Literal' && node.value && jsxUtil.isWhiteSpaces(node.value); 126 } 127 128 function isStringWithTrailingWhiteSpaces(value) { 129 return /^\s|\s$/.test(value); 130 } 131 132 function isLiteralWithTrailingWhiteSpaces(node) { 133 return node.type && node.type === 'Literal' && node.value && isStringWithTrailingWhiteSpaces(node.value); 134 } 33 135 34 136 // ------------------------------------------------------------------------------ … … 75 177 76 178 create(context) { 77 const HTML_ENTITY_REGEX = () => /&[A-Za-z\d#]+;/g;78 179 const ruleOptions = context.options[0]; 79 180 const userConfig = typeof ruleOptions === 'string' 80 181 ? { props: ruleOptions, children: ruleOptions, propElementValues: OPTION_IGNORE } 81 182 : Object.assign({}, DEFAULT_CONFIG, ruleOptions); 82 83 function containsLineTerminators(rawStringValue) {84 return /[\n\r\u2028\u2029]/.test(rawStringValue);85 }86 87 function containsBackslash(rawStringValue) {88 return arrayIncludes(rawStringValue, '\\');89 }90 91 function containsHTMLEntity(rawStringValue) {92 return HTML_ENTITY_REGEX().test(rawStringValue);93 }94 95 function containsOnlyHtmlEntities(rawStringValue) {96 return rawStringValue.replace(HTML_ENTITY_REGEX(), '').trim() === '';97 }98 99 function containsDisallowedJSXTextChars(rawStringValue) {100 return /[{<>}]/.test(rawStringValue);101 }102 103 function containsQuoteCharacters(value) {104 return /['"]/.test(value);105 }106 107 function containsMultilineComment(value) {108 return /\/\*/.test(value);109 }110 111 function escapeDoubleQuotes(rawStringValue) {112 return rawStringValue.replace(/\\"/g, '"').replace(/"/g, '\\"');113 }114 115 function escapeBackslashes(rawStringValue) {116 return rawStringValue.replace(/\\/g, '\\\\');117 }118 119 function needToEscapeCharacterForJSX(raw, node) {120 return (121 containsBackslash(raw)122 || containsHTMLEntity(raw)123 || (node.parent.type !== 'JSXAttribute' && containsDisallowedJSXTextChars(raw))124 );125 }126 127 function containsWhitespaceExpression(child) {128 if (child.type === 'JSXExpressionContainer') {129 const value = child.expression.value;130 return value ? jsxUtil.isWhiteSpaces(value) : false;131 }132 return false;133 }134 135 function isLineBreak(text) {136 return containsLineTerminators(text) && text.trim() === '';137 }138 139 function wrapNonHTMLEntities(text) {140 const HTML_ENTITY = '<HTML_ENTITY>';141 const withCurlyBraces = text.split(HTML_ENTITY_REGEX()).map((word) => (142 word === '' ? '' : `{${JSON.stringify(word)}}`143 )).join(HTML_ENTITY);144 145 const htmlEntities = text.match(HTML_ENTITY_REGEX());146 return htmlEntities.reduce((acc, htmlEntity) => (147 acc.replace(HTML_ENTITY, htmlEntity)148 ), withCurlyBraces);149 }150 151 function wrapWithCurlyBraces(rawText) {152 if (!containsLineTerminators(rawText)) {153 return `{${JSON.stringify(rawText)}}`;154 }155 156 return rawText.split('\n').map((line) => {157 if (line.trim() === '') {158 return line;159 }160 const firstCharIndex = line.search(/[^\s]/);161 const leftWhitespace = line.slice(0, firstCharIndex);162 const text = line.slice(firstCharIndex);163 164 if (containsHTMLEntity(line)) {165 return `${leftWhitespace}${wrapNonHTMLEntities(text)}`;166 }167 return `${leftWhitespace}{${JSON.stringify(text)}}`;168 }).join('\n');169 }170 183 171 184 /** … … 187 200 188 201 if (parentType === 'JSXAttribute') { 189 textToReplace = `"${expressionType === 'TemplateLiteral' 190 ? expression.quasis[0].value.raw 191 : expression.raw.slice(1, -1) 192 }"`; 202 if (expressionType !== 'TemplateLiteral' && /["]/.test(expression.raw.slice(1, -1))) { 203 textToReplace = expression.raw; 204 } else { 205 textToReplace = `"${expressionType === 'TemplateLiteral' 206 ? expression.quasis[0].value.raw 207 : expression.raw.slice(1, -1) 208 }"`; 209 } 193 210 } else if (jsxUtil.isJSX(expression)) { 194 211 textToReplace = getText(context, expression); … … 234 251 } 235 252 236 function isWhiteSpaceLiteral(node) {237 return node.type && node.type === 'Literal' && node.value && jsxUtil.isWhiteSpaces(node.value);238 }239 240 function isStringWithTrailingWhiteSpaces(value) {241 return /^\s|\s$/.test(value);242 }243 244 function isLiteralWithTrailingWhiteSpaces(node) {245 return node.type && node.type === 'Literal' && node.value && isStringWithTrailingWhiteSpaces(node.value);246 }247 248 253 // Bail out if there is any character that needs to be escaped in JSX 249 254 // because escaping decreases readability and the original code may be more … … 269 274 && !needToEscapeCharacterForJSX(expression.raw, JSXExpressionNode) && ( 270 275 jsxUtil.isJSX(JSXExpressionNode.parent) 271 || !containsQuoteCharacters(expression.value)276 || (!containsQuoteCharacters(expression.value) || typeof expression.value === 'string') 272 277 ) 273 278 ) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js
rd565449 r0c6b92a 36 36 }; 37 37 38 /** @type {import('eslint').Rule.RuleModule} */ 38 39 module.exports = { 39 40 meta: { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-equals-spacing.js
rd565449 r0c6b92a 21 21 }; 22 22 23 /** @type {import('eslint').Rule.RuleModule} */ 23 24 module.exports = { 24 25 meta: { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-first-prop-new-line.js
rd565449 r0c6b92a 8 8 const docsUrl = require('../util/docsUrl'); 9 9 const report = require('../util/report'); 10 const propsUtil = require('../util/props'); 10 11 11 12 // ------------------------------------------------------------------------------ … … 56 57 node: decl, 57 58 fix(fixer) { 58 return fixer.replaceTextRange([(node.typeParameters || node.name).range[1], decl.range[0]], '\n'); 59 const nodeTypeArguments = propsUtil.getTypeArguments(node); 60 return fixer.replaceTextRange([(nodeTypeArguments || node.name).range[1], decl.range[0]], '\n'); 59 61 }, 60 62 }); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-fragments.js
rd565449 r0c6b92a 23 23 24 24 const messages = { 25 fragmentsNotSupported: 'Fragments are only supported starting from React v16.2. ' 26 + 'Please disable the `react/jsx-fragments` rule in `eslint` settings or upgrade your version of React.', 25 fragmentsNotSupported: 'Fragments are only supported starting from React v16.2. Please disable the `react/jsx-fragments` rule in `eslint` settings or upgrade your version of React.', 27 26 preferPragma: 'Prefer {{react}}.{{fragment}} over fragment shorthand', 28 27 preferFragment: 'Prefer fragment shorthand over {{react}}.{{fragment}}', 29 28 }; 30 29 30 /** @type {import('eslint').Rule.RuleModule} */ 31 31 module.exports = { 32 32 meta: { … … 171 171 if (node.source && node.source.value === 'react') { 172 172 node.specifiers.forEach((spec) => { 173 if ( spec.imported && spec.imported.name === fragmentPragma) {173 if ('imported' in spec && spec.imported && spec.imported.name === fragmentPragma) { 174 174 if (spec.local) { 175 175 fragmentNames.add(spec.local.name); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-indent-props.js
rd565449 r0c6b92a 46 46 }; 47 47 48 /** @type {import('eslint').Rule.RuleModule} */ 48 49 module.exports = { 49 50 meta: { … … 117 118 * Reports a given indent violation and properly pluralizes the message 118 119 * @param {ASTNode} node Node violating the indent rule 119 * @param { Number} needed Expected indentation character count120 * @param { Number} gotten Indentation character count in the actual node/code120 * @param {number} needed Expected indentation character count 121 * @param {number} gotten Indentation character count in the actual node/code 121 122 */ 122 123 function report(node, needed, gotten) { … … 142 143 * Get node indent 143 144 * @param {ASTNode} node Node to examine 144 * @return { Number} Indent145 * @return {number} Indent 145 146 */ 146 147 function getNodeIndent(node) { … … 174 175 * Check indent for nodes list 175 176 * @param {ASTNode[]} nodes list of node objects 176 * @param { Number} indent needed indent177 * @param {number} indent needed indent 177 178 */ 178 179 function checkNodesIndent(nodes, indent) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-indent.js
rd565449 r0c6b92a 51 51 }; 52 52 53 /** @type {import('eslint').Rule.RuleModule} */ 53 54 module.exports = { 54 55 meta: { … … 106 107 * Responsible for fixing the indentation issue fix 107 108 * @param {ASTNode} node Node violating the indent rule 108 * @param { Number} needed Expected indentation character count109 * @param {number} needed Expected indentation character count 109 110 * @returns {Function} function to be executed by the fixer 110 111 * @private … … 147 148 * Reports a given indent violation and properly pluralizes the message 148 149 * @param {ASTNode} node Node violating the indent rule 149 * @param { Number} needed Expected indentation character count150 * @param { Number} gotten Indentation character count in the actual node/code150 * @param {number} needed Expected indentation character count 151 * @param {number} gotten Indentation character count in the actual node/code 151 152 * @param {Object} [loc] Error line and column location 152 153 */ … … 169 170 * Get node indent 170 171 * @param {ASTNode} node Node to examine 171 * @param { Boolean} [byLastLine] get indent of node's last line172 * @param { Boolean} [excludeCommas] skip comma on start of line173 * @return { Number} Indent172 * @param {boolean} [byLastLine] get indent of node's last line 173 * @param {boolean} [excludeCommas] skip comma on start of line 174 * @return {number} Indent 174 175 */ 175 176 function getNodeIndent(node, byLastLine, excludeCommas) { … … 198 199 * Check if the node is the right member of a logical expression 199 200 * @param {ASTNode} node The node to check 200 * @return { Boolean} true if its the case, false if not201 * @return {boolean} true if its the case, false if not 201 202 */ 202 203 function isRightInLogicalExp(node) { … … 213 214 * Check if the node is the alternate member of a conditional expression 214 215 * @param {ASTNode} node The node to check 215 * @return { Boolean} true if its the case, false if not216 * @return {boolean} true if its the case, false if not 216 217 */ 217 218 function isAlternateInConditionalExp(node) { … … 228 229 * Check if the node is within a DoExpression block but not the first expression (which need to be indented) 229 230 * @param {ASTNode} node The node to check 230 * @return { Boolean} true if its the case, false if not231 * @return {boolean} true if its the case, false if not 231 232 */ 232 233 function isSecondOrSubsequentExpWithinDoExp(node) { … … 299 300 * Check indent for nodes list 300 301 * @param {ASTNode} node The node to check 301 * @param { Number} indent needed indent302 * @param { Boolean} [excludeCommas] skip comma on start of line302 * @param {number} indent needed indent 303 * @param {boolean} [excludeCommas] skip comma on start of line 303 304 */ 304 305 function checkNodesIndent(node, indent, excludeCommas) { … … 319 320 * Check indent for Literal Node or JSXText Node 320 321 * @param {ASTNode} node The node to check 321 * @param { Number} indent needed indent322 * @param {number} indent needed indent 322 323 */ 323 324 function checkLiteralNodeIndent(node, indent) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-max-depth.js
rd565449 r0c6b92a 92 92 function find(refs, prevRefs) { 93 93 for (let i = refs.length - 1; i >= 0; i--) { 94 if ( has(refs[i], 'writeExpr')) {94 if (typeof refs[i].writeExpr !== 'undefined') { 95 95 const writeExpr = refs[i].writeExpr; 96 96 -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-no-bind.js
rd565449 r0c6b92a 10 10 const propName = require('jsx-ast-utils/propName'); 11 11 const docsUrl = require('../util/docsUrl'); 12 const astUtil = require('../util/ast'); 12 13 const jsxUtil = require('../util/jsx'); 13 14 const report = require('../util/report'); … … 25 26 }; 26 27 28 /** @type {import('eslint').Rule.RuleModule} */ 27 29 module.exports = { 28 30 meta: { … … 84 86 85 87 function getNodeViolationType(node) { 86 const nodeType = node.type;87 88 if ( 88 89 !configuration.allowBind 89 && nodeType === 'CallExpression'90 && astUtil.isCallExpression(node) 90 91 && node.callee.type === 'MemberExpression' 91 92 && node.callee.property.type === 'Identifier' … … 94 95 return 'bindCall'; 95 96 } 96 if (node Type === 'ConditionalExpression') {97 if (node.type === 'ConditionalExpression') { 97 98 return getNodeViolationType(node.test) 98 99 || getNodeViolationType(node.consequent) 99 100 || getNodeViolationType(node.alternate); 100 101 } 101 if (!configuration.allowArrowFunctions && node Type === 'ArrowFunctionExpression') {102 if (!configuration.allowArrowFunctions && node.type === 'ArrowFunctionExpression') { 102 103 return 'arrowFunc'; 103 104 } 104 105 if ( 105 106 !configuration.allowFunctions 106 && (node Type === 'FunctionExpression' || nodeType === 'FunctionDeclaration')107 && (node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration') 107 108 ) { 108 109 return 'func'; 109 110 } 110 if (!configuration.allowBind && node Type === 'BindExpression') {111 if (!configuration.allowBind && node.type === 'BindExpression') { 111 112 return 'bindExpression'; 112 113 } … … 117 118 /** 118 119 * @param {string | number} violationType 119 * @param { any} variableName120 * @param {unknown} variableName 120 121 * @param {string | number} blockStart 121 122 */ … … 176 177 blockAncestors.length > 0 177 178 && variableViolationType 179 && 'kind' in node.parent 178 180 && node.parent.kind === 'const' // only support const right now 179 181 ) { 180 addVariableNameToSet( 181 variableViolationType, node.id.name, blockAncestors[0].range[0] 182 ); 182 addVariableNameToSet(variableViolationType, 'name' in node.id ? node.id.name : undefined, blockAncestors[0].range[0]); 183 183 } 184 184 }, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-no-leaked-render.js
rd565449 r0c6b92a 110 110 } 111 111 112 /**113 * @type {import('eslint').Rule.RuleModule}114 */115 112 /** @type {import('eslint').Rule.RuleModule} */ 116 113 module.exports = { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-no-literals.js
rd565449 r0c6b92a 9 9 const iterFrom = require('es-iterator-helpers/Iterator.from'); 10 10 const map = require('es-iterator-helpers/Iterator.prototype.map'); 11 const some = require('es-iterator-helpers/Iterator.prototype.some'); 12 const flatMap = require('es-iterator-helpers/Iterator.prototype.flatMap'); 13 const fromEntries = require('object.fromentries'); 14 const entries = require('object.entries'); 11 15 12 16 const docsUrl = require('../util/docsUrl'); … … 18 22 // ------------------------------------------------------------------------------ 19 23 20 function trimIfString(val) { 21 return typeof val === 'string' ? val.trim() : val; 24 /** 25 * @param {unknown} value 26 * @returns {string | unknown} 27 */ 28 function trimIfString(value) { 29 return typeof value === 'string' ? value.trim() : value; 22 30 } 31 32 const reOverridableElement = /^[A-Z][\w.]*$/; 33 const reIsWhiteSpace = /^[\s]+$/; 34 const jsxElementTypes = new Set(['JSXElement', 'JSXFragment']); 35 const standardJSXNodeParentTypes = new Set(['JSXAttribute', 'JSXElement', 'JSXExpressionContainer', 'JSXFragment']); 23 36 24 37 const messages = { 25 38 invalidPropValue: 'Invalid prop value: "{{text}}"', 39 invalidPropValueInElement: 'Invalid prop value: "{{text}}" in {{element}}', 26 40 noStringsInAttributes: 'Strings not allowed in attributes: "{{text}}"', 41 noStringsInAttributesInElement: 'Strings not allowed in attributes: "{{text}}" in {{element}}', 27 42 noStringsInJSX: 'Strings not allowed in JSX files: "{{text}}"', 43 noStringsInJSXInElement: 'Strings not allowed in JSX files: "{{text}}" in {{element}}', 28 44 literalNotInJSXExpression: 'Missing JSX expression container around literal string: "{{text}}"', 45 literalNotInJSXExpressionInElement: 'Missing JSX expression container around literal string: "{{text}}" in {{element}}', 29 46 }; 30 47 31 /** @type {import('eslint').Rule.RuleModule} */ 48 /** @type {Exclude<import('eslint').Rule.RuleModule['meta']['schema'], unknown[]>['properties']} */ 49 const commonPropertiesSchema = { 50 noStrings: { 51 type: 'boolean', 52 }, 53 allowedStrings: { 54 type: 'array', 55 uniqueItems: true, 56 items: { 57 type: 'string', 58 }, 59 }, 60 ignoreProps: { 61 type: 'boolean', 62 }, 63 noAttributeStrings: { 64 type: 'boolean', 65 }, 66 }; 67 68 /** 69 * @typedef RawElementConfigProperties 70 * @property {boolean} [noStrings] 71 * @property {string[]} [allowedStrings] 72 * @property {boolean} [ignoreProps] 73 * @property {boolean} [noAttributeStrings] 74 * 75 * @typedef RawOverrideConfigProperties 76 * @property {boolean} [allowElement] 77 * @property {boolean} [applyToNestedElements=true] 78 * 79 * @typedef {RawElementConfigProperties} RawElementConfig 80 * @typedef {RawElementConfigProperties & RawElementConfigProperties} RawOverrideConfig 81 * 82 * @typedef RawElementOverrides 83 * @property {Record<string, RawOverrideConfig>} [elementOverrides] 84 * 85 * @typedef {RawElementConfig & RawElementOverrides} RawConfig 86 * 87 * ---------------------------------------------------------------------- 88 * 89 * @typedef ElementConfigType 90 * @property {'element'} type 91 * 92 * @typedef ElementConfigProperties 93 * @property {boolean} noStrings 94 * @property {Set<string>} allowedStrings 95 * @property {boolean} ignoreProps 96 * @property {boolean} noAttributeStrings 97 * 98 * @typedef OverrideConfigProperties 99 * @property {'override'} type 100 * @property {string} name 101 * @property {boolean} allowElement 102 * @property {boolean} applyToNestedElements 103 * 104 * @typedef {ElementConfigType & ElementConfigProperties} ElementConfig 105 * @typedef {OverrideConfigProperties & ElementConfigProperties} OverrideConfig 106 * 107 * @typedef ElementOverrides 108 * @property {Record<string, OverrideConfig>} elementOverrides 109 * 110 * @typedef {ElementConfig & ElementOverrides} Config 111 * @typedef {Config | OverrideConfig} ResolvedConfig 112 */ 113 114 /** 115 * Normalizes the element portion of the config 116 * @param {RawConfig} config 117 * @returns {ElementConfig} 118 */ 119 function normalizeElementConfig(config) { 120 return { 121 type: 'element', 122 noStrings: !!config.noStrings, 123 allowedStrings: config.allowedStrings 124 ? new Set(map(iterFrom(config.allowedStrings), trimIfString)) 125 : new Set(), 126 ignoreProps: !!config.ignoreProps, 127 noAttributeStrings: !!config.noAttributeStrings, 128 }; 129 } 130 131 /** 132 * Normalizes the config and applies default values to all config options 133 * @param {RawConfig} config 134 * @returns {Config} 135 */ 136 function normalizeConfig(config) { 137 /** @type {Config} */ 138 const normalizedConfig = Object.assign(normalizeElementConfig(config), { 139 elementOverrides: {}, 140 }); 141 142 if (config.elementOverrides) { 143 normalizedConfig.elementOverrides = fromEntries( 144 flatMap( 145 iterFrom(entries(config.elementOverrides)), 146 (entry) => { 147 const elementName = entry[0]; 148 const rawElementConfig = entry[1]; 149 150 if (!reOverridableElement.test(elementName)) { 151 return []; 152 } 153 154 return [[ 155 elementName, 156 Object.assign(normalizeElementConfig(rawElementConfig), { 157 type: 'override', 158 name: elementName, 159 allowElement: !!rawElementConfig.allowElement, 160 applyToNestedElements: typeof rawElementConfig.applyToNestedElements === 'undefined' || !!rawElementConfig.applyToNestedElements, 161 }), 162 ]]; 163 } 164 ) 165 ); 166 } 167 168 return normalizedConfig; 169 } 170 171 const elementOverrides = { 172 type: 'object', 173 patternProperties: { 174 [reOverridableElement.source]: { 175 type: 'object', 176 properties: Object.assign( 177 { applyToNestedElements: { type: 'boolean' } }, 178 commonPropertiesSchema 179 ), 180 181 }, 182 }, 183 }; 184 32 185 module.exports = { 33 meta: {186 meta: /** @type {import('eslint').Rule.RuleModule["meta"]} */ ({ 34 187 docs: { 35 188 description: 'Disallow usage of string literals in JSX', … … 43 196 schema: [{ 44 197 type: 'object', 45 properties: { 46 noStrings: { 47 type: 'boolean', 48 }, 49 allowedStrings: { 50 type: 'array', 51 uniqueItems: true, 52 items: { 53 type: 'string', 54 }, 55 }, 56 ignoreProps: { 57 type: 'boolean', 58 }, 59 noAttributeStrings: { 60 type: 'boolean', 61 }, 62 }, 198 properties: Object.assign( 199 { elementOverrides }, 200 commonPropertiesSchema 201 ), 63 202 additionalProperties: false, 64 203 }], 65 } ,204 }), 66 205 67 206 create(context) { 68 const defaults = { 69 noStrings: false, 70 allowedStrings: [], 71 ignoreProps: false, 72 noAttributeStrings: false, 73 }; 74 const config = Object.assign({}, defaults, context.options[0] || {}); 75 config.allowedStrings = new Set(map(iterFrom(config.allowedStrings), trimIfString)); 76 77 function defaultMessageId() { 78 const ancestorIsJSXElement = arguments.length >= 1 && arguments[0]; 79 if (config.noAttributeStrings && !ancestorIsJSXElement) { 80 return 'noStringsInAttributes'; 81 } 82 if (config.noStrings) { 83 return 'noStringsInJSX'; 84 } 85 return 'literalNotInJSXExpression'; 86 } 87 207 /** @type {RawConfig} */ 208 const rawConfig = (context.options.length && context.options[0]) || {}; 209 const config = normalizeConfig(rawConfig); 210 211 const hasElementOverrides = Object.keys(config.elementOverrides).length > 0; 212 213 /** @type {Map<string, string>} */ 214 const renamedImportMap = new Map(); 215 216 /** 217 * Determines if the given expression is a require statement. Supports 218 * nested MemberExpresions. ie `require('foo').nested.property` 219 * @param {ASTNode} node 220 * @returns {boolean} 221 */ 222 function isRequireStatement(node) { 223 if (node.type === 'CallExpression') { 224 if (node.callee.type === 'Identifier') { 225 return node.callee.name === 'require'; 226 } 227 } 228 if (node.type === 'MemberExpression') { 229 return isRequireStatement(node.object); 230 } 231 232 return false; 233 } 234 235 /** @typedef {{ name: string, compoundName?: string }} ElementNameFragment */ 236 237 /** 238 * Gets the name of the given JSX element. Supports nested 239 * JSXMemeberExpressions. ie `<Namesapce.Component.SubComponent />` 240 * @param {ASTNode} node 241 * @returns {ElementNameFragment | undefined} 242 */ 243 function getJSXElementName(node) { 244 if (node.openingElement.name.type === 'JSXIdentifier') { 245 const name = node.openingElement.name.name; 246 return { 247 name: renamedImportMap.get(name) || name, 248 compoundName: undefined, 249 }; 250 } 251 252 /** @type {string[]} */ 253 const nameFragments = []; 254 255 if (node.openingElement.name.type === 'JSXMemberExpression') { 256 /** @type {ASTNode} */ 257 let current = node.openingElement.name; 258 while (current.type === 'JSXMemberExpression') { 259 if (current.property.type === 'JSXIdentifier') { 260 nameFragments.unshift(current.property.name); 261 } 262 263 current = current.object; 264 } 265 266 if (current.type === 'JSXIdentifier') { 267 nameFragments.unshift(current.name); 268 269 const rootFragment = nameFragments[0]; 270 if (rootFragment) { 271 const rootFragmentRenamed = renamedImportMap.get(rootFragment); 272 if (rootFragmentRenamed) { 273 nameFragments[0] = rootFragmentRenamed; 274 } 275 } 276 277 const nameFragment = nameFragments[nameFragments.length - 1]; 278 if (nameFragment) { 279 return { 280 name: nameFragment, 281 compoundName: nameFragments.join('.'), 282 }; 283 } 284 } 285 } 286 } 287 288 /** 289 * Gets all JSXElement ancestor nodes for the given node 290 * @param {ASTNode} node 291 * @returns {ASTNode[]} 292 */ 293 function getJSXElementAncestors(node) { 294 /** @type {ASTNode[]} */ 295 const ancestors = []; 296 297 let current = node; 298 while (current) { 299 if (current.type === 'JSXElement') { 300 ancestors.push(current); 301 } 302 303 current = current.parent; 304 } 305 306 return ancestors; 307 } 308 309 /** 310 * @param {ASTNode} node 311 * @returns {ASTNode} 312 */ 88 313 function getParentIgnoringBinaryExpressions(node) { 89 314 let current = node; … … 94 319 } 95 320 96 function getValidation(node) { 97 const values = [trimIfString(node.raw), trimIfString(node.value)]; 98 if (values.some((value) => config.allowedStrings.has(value))) { 99 return false; 100 } 101 321 /** 322 * @param {ASTNode} node 323 * @returns {{ parent: ASTNode, grandParent: ASTNode }} 324 */ 325 function getParentAndGrandParent(node) { 102 326 const parent = getParentIgnoringBinaryExpressions(node); 103 104 function isParentNodeStandard() {105 if (!/^[\s]+$/.test(node.value) && typeof node.value === 'string' && parent.type.includes('JSX')) {106 if (config.noAttributeStrings) {107 return parent.type === 'JSXAttribute' || parent.type === 'JSXElement';108 }109 if (!config.noAttributeStrings) {110 return parent.type !== 'JSXAttribute';111 }112 }113 114 return false;115 }116 117 const standard = isParentNodeStandard();118 119 if (config.noStrings) {120 return standard;121 }122 return standard && parent.type !== 'JSXExpressionContainer';123 }124 125 function getParentAndGrandParentType(node) {126 const parent = getParentIgnoringBinaryExpressions(node);127 const parentType = parent.type;128 const grandParentType = parent.parent.type;129 130 327 return { 131 328 parent, 132 parentType,133 grandParentType,134 329 grandParent: parent.parent, 135 330 }; 136 331 } 137 332 333 /** 334 * @param {ASTNode} node 335 * @returns {boolean} 336 */ 138 337 function hasJSXElementParentOrGrandParent(node) { 139 const parents = getParentAndGrandParentType(node); 140 const parentType = parents.parentType; 141 const grandParentType = parents.grandParentType; 142 143 return parentType === 'JSXFragment' || parentType === 'JSXElement' || grandParentType === 'JSXElement'; 144 } 145 146 function reportLiteralNode(node, messageId) { 147 const ancestorIsJSXElement = hasJSXElementParentOrGrandParent(node); 148 messageId = messageId || defaultMessageId(ancestorIsJSXElement); 149 338 const ancestors = getParentAndGrandParent(node); 339 return some(iterFrom([ancestors.parent, ancestors.grandParent]), (parent) => jsxElementTypes.has(parent.type)); 340 } 341 342 /** 343 * Determines whether a given node's value and its immediate parent are 344 * viable text nodes that can/should be reported on 345 * @param {ASTNode} node 346 * @param {ResolvedConfig} resolvedConfig 347 * @returns {boolean} 348 */ 349 function isViableTextNode(node, resolvedConfig) { 350 const textValues = iterFrom([trimIfString(node.raw), trimIfString(node.value)]); 351 if (some(textValues, (value) => resolvedConfig.allowedStrings.has(value))) { 352 return false; 353 } 354 355 const parent = getParentIgnoringBinaryExpressions(node); 356 357 let isStandardJSXNode = false; 358 if (typeof node.value === 'string' && !reIsWhiteSpace.test(node.value) && standardJSXNodeParentTypes.has(parent.type)) { 359 if (resolvedConfig.noAttributeStrings) { 360 isStandardJSXNode = parent.type === 'JSXAttribute' || parent.type === 'JSXElement'; 361 } else { 362 isStandardJSXNode = parent.type !== 'JSXAttribute'; 363 } 364 } 365 366 if (resolvedConfig.noStrings) { 367 return isStandardJSXNode; 368 } 369 370 return isStandardJSXNode && parent.type !== 'JSXExpressionContainer'; 371 } 372 373 /** 374 * Gets an override config for a given node. For any given node, we also 375 * need to traverse the ancestor tree to determine if an ancestor's config 376 * will also apply to the current node. 377 * @param {ASTNode} node 378 * @returns {OverrideConfig | undefined} 379 */ 380 function getOverrideConfig(node) { 381 if (!hasElementOverrides) { 382 return; 383 } 384 385 const allAncestorElements = getJSXElementAncestors(node); 386 if (!allAncestorElements.length) { 387 return; 388 } 389 390 for (const ancestorElement of allAncestorElements) { 391 const isClosestJSXAncestor = ancestorElement === allAncestorElements[0]; 392 393 const ancestor = getJSXElementName(ancestorElement); 394 if (ancestor) { 395 if (ancestor.name) { 396 const ancestorElements = config.elementOverrides[ancestor.name]; 397 const ancestorConfig = ancestor.compoundName 398 ? config.elementOverrides[ancestor.compoundName] || ancestorElements 399 : ancestorElements; 400 401 if (ancestorConfig) { 402 if (isClosestJSXAncestor || ancestorConfig.applyToNestedElements) { 403 return ancestorConfig; 404 } 405 } 406 } 407 } 408 } 409 } 410 411 /** 412 * @param {ResolvedConfig} resolvedConfig 413 * @returns {boolean} 414 */ 415 function shouldAllowElement(resolvedConfig) { 416 return resolvedConfig.type === 'override' && 'allowElement' in resolvedConfig && !!resolvedConfig.allowElement; 417 } 418 419 /** 420 * @param {boolean} ancestorIsJSXElement 421 * @param {ResolvedConfig} resolvedConfig 422 * @returns {string} 423 */ 424 function defaultMessageId(ancestorIsJSXElement, resolvedConfig) { 425 if (resolvedConfig.noAttributeStrings && !ancestorIsJSXElement) { 426 return resolvedConfig.type === 'override' ? 'noStringsInAttributesInElement' : 'noStringsInAttributes'; 427 } 428 429 if (resolvedConfig.noStrings) { 430 return resolvedConfig.type === 'override' ? 'noStringsInJSXInElement' : 'noStringsInJSX'; 431 } 432 433 return resolvedConfig.type === 'override' ? 'literalNotInJSXExpressionInElement' : 'literalNotInJSXExpression'; 434 } 435 436 /** 437 * @param {ASTNode} node 438 * @param {string} messageId 439 * @param {ResolvedConfig} resolvedConfig 440 */ 441 function reportLiteralNode(node, messageId, resolvedConfig) { 150 442 report(context, messages[messageId], messageId, { 151 443 node, 152 444 data: { 153 445 text: getText(context, node).trim(), 446 element: resolvedConfig.type === 'override' && 'name' in resolvedConfig ? resolvedConfig.name : undefined, 154 447 }, 155 448 }); … … 160 453 // -------------------------------------------------------------------------- 161 454 162 return { 455 return Object.assign(hasElementOverrides ? { 456 // Get renamed import local names mapped to their imported name 457 ImportDeclaration(node) { 458 node.specifiers 459 .filter((s) => s.type === 'ImportSpecifier') 460 .forEach((specifier) => { 461 renamedImportMap.set( 462 (specifier.local || specifier.imported).name, 463 specifier.imported.name 464 ); 465 }); 466 }, 467 468 // Get renamed destructured local names mapped to their imported name 469 VariableDeclaration(node) { 470 node.declarations 471 .filter((d) => ( 472 d.type === 'VariableDeclarator' 473 && isRequireStatement(d.init) 474 && d.id.type === 'ObjectPattern' 475 )) 476 .forEach((declaration) => { 477 declaration.id.properties 478 .filter((property) => ( 479 property.type === 'Property' 480 && property.key.type === 'Identifier' 481 && property.value.type === 'Identifier' 482 )) 483 .forEach((property) => { 484 renamedImportMap.set(property.value.name, property.key.name); 485 }); 486 }); 487 }, 488 } : false, { 163 489 Literal(node) { 164 if (getValidation(node) && (hasJSXElementParentOrGrandParent(node) || !config.ignoreProps)) { 165 reportLiteralNode(node); 490 const resolvedConfig = getOverrideConfig(node) || config; 491 492 const hasJSXParentOrGrandParent = hasJSXElementParentOrGrandParent(node); 493 if (hasJSXParentOrGrandParent && shouldAllowElement(resolvedConfig)) { 494 return; 495 } 496 497 if (isViableTextNode(node, resolvedConfig)) { 498 if (hasJSXParentOrGrandParent || !config.ignoreProps) { 499 reportLiteralNode(node, defaultMessageId(hasJSXParentOrGrandParent, resolvedConfig), resolvedConfig); 500 } 166 501 } 167 502 }, 168 503 169 504 JSXAttribute(node) { 170 const isNodeValueString = node && node.value && node.value.type === 'Literal' && typeof node.value.value === 'string' && !config.allowedStrings.has(node.value.value); 171 172 if (config.noStrings && !config.ignoreProps && isNodeValueString) { 173 const messageId = 'invalidPropValue'; 174 reportLiteralNode(node, messageId); 505 const isLiteralString = node.value && node.value.type === 'Literal' 506 && typeof node.value.value === 'string'; 507 const isStringLiteral = node.value && node.value.type === 'StringLiteral'; 508 509 if (isLiteralString || isStringLiteral) { 510 const resolvedConfig = getOverrideConfig(node) || config; 511 512 if ( 513 resolvedConfig.noStrings 514 && !resolvedConfig.ignoreProps 515 && !resolvedConfig.allowedStrings.has(node.value.value) 516 ) { 517 const messageId = resolvedConfig.type === 'override' ? 'invalidPropValueInElement' : 'invalidPropValue'; 518 reportLiteralNode(node, messageId, resolvedConfig); 519 } 175 520 } 176 521 }, 177 522 178 523 JSXText(node) { 179 if (getValidation(node)) { 180 reportLiteralNode(node); 524 const resolvedConfig = getOverrideConfig(node) || config; 525 526 if (shouldAllowElement(resolvedConfig)) { 527 return; 528 } 529 530 if (isViableTextNode(node, resolvedConfig)) { 531 const hasJSXParendOrGrantParent = hasJSXElementParentOrGrandParent(node); 532 reportLiteralNode(node, defaultMessageId(hasJSXParendOrGrantParent, resolvedConfig), resolvedConfig); 181 533 } 182 534 }, 183 535 184 536 TemplateLiteral(node) { 185 const parents = getParentAndGrandParentType(node); 186 const parentType = parents.parentType; 187 const grandParentType = parents.grandParentType; 188 const isParentJSXExpressionCont = parentType === 'JSXExpressionContainer'; 189 const isParentJSXElement = parentType === 'JSXElement' || grandParentType === 'JSXElement'; 190 191 if (isParentJSXExpressionCont && config.noStrings && (isParentJSXElement || !config.ignoreProps)) { 192 reportLiteralNode(node); 537 const ancestors = getParentAndGrandParent(node); 538 const isParentJSXExpressionCont = ancestors.parent.type === 'JSXExpressionContainer'; 539 const isParentJSXElement = ancestors.grandParent.type === 'JSXElement'; 540 541 if (isParentJSXExpressionCont) { 542 const resolvedConfig = getOverrideConfig(node) || config; 543 544 if ( 545 resolvedConfig.noStrings 546 && (isParentJSXElement || !resolvedConfig.ignoreProps) 547 ) { 548 reportLiteralNode(node, defaultMessageId(isParentJSXElement, resolvedConfig), resolvedConfig); 549 } 193 550 } 194 551 }, 195 } ;552 }); 196 553 }, 197 554 }; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js
rd565449 r0c6b92a 71 71 * @param {ASTNode} value The AST node being checked. 72 72 * @param {ASTNode} targetValue The AST node being checked. 73 * @returns { String | String[] | null} The string value, or null if not a string.73 * @returns {string | string[] | null} The string value, or null if not a string. 74 74 */ 75 75 function getStringFromValue(value, targetValue) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-no-useless-fragment.js
rd565449 r0c6b92a 8 8 9 9 const pragmaUtil = require('../util/pragma'); 10 const astUtil = require('../util/ast'); 10 11 const jsxUtil = require('../util/jsx'); 11 12 const docsUrl = require('../util/docsUrl'); … … 76 77 return node 77 78 && node.type === 'JSXExpressionContainer' 78 && node.expression 79 && node.expression.type === 'CallExpression'; 79 && astUtil.isCallExpression(node.expression); 80 80 } 81 81 -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-props-no-multi-spaces.js
rd565449 r0c6b92a 9 9 const eslintUtil = require('../util/eslint'); 10 10 const report = require('../util/report'); 11 const propsUtil = require('../util/props'); 11 12 12 13 const getSourceCode = eslintUtil.getSourceCode; … … 104 105 105 106 function containsGenericType(node) { 106 const nodeType Params = node.typeParameters;107 if (typeof nodeType Params === 'undefined') {107 const nodeTypeArguments = propsUtil.getTypeArguments(node); 108 if (typeof nodeTypeArguments === 'undefined') { 108 109 return false; 109 110 } 110 111 111 return nodeType Params.type === 'TSTypeParameterInstantiation';112 return nodeTypeArguments.type === 'TSTypeParameterInstantiation'; 112 113 } 113 114 … … 115 116 const name = node.name; 116 117 if (containsGenericType(node)) { 117 const type = node.typeParameters;118 const nodeTypeArguments = propsUtil.getTypeArguments(node); 118 119 119 120 return Object.assign( … … 123 124 range: [ 124 125 name.range[0], 125 type.range[1],126 nodeTypeArguments.range[1], 126 127 ], 127 128 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-props-no-spreading.js
rd565449 r0c6b92a 59 59 }, 60 60 custom: { 61 enum: [OPTIONS.enforce, OPTIONS.ignore], 62 }, 63 explicitSpread: { 61 64 enum: [OPTIONS.enforce, OPTIONS.ignore], 62 65 }, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-sort-default-props.js
rd565449 r0c6b92a 26 26 }; 27 27 28 /** @type {import('eslint').Rule.RuleModule} */ 28 29 module.exports = { 29 30 meta: { … … 58 59 * Get properties name 59 60 * @param {Object} node - Property. 60 * @returns { String} Property name.61 * @returns {string} Property name. 61 62 */ 62 63 function getPropertyName(node) { … … 79 80 * Checks if the Identifier node passed in looks like a defaultProps declaration. 80 81 * @param {ASTNode} node The node to check. Must be an Identifier node. 81 * @returns { Boolean} `true` if the node is a defaultProps declaration, `false` if not82 * @returns {boolean} `true` if the node is a defaultProps declaration, `false` if not 82 83 */ 83 84 function isDefaultPropsDeclaration(node) { … … 179 180 } 180 181 181 checkNode( node.parent.right);182 checkNode('right' in node.parent && node.parent.right); 182 183 }, 183 184 -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-sort-props.js
rd565449 r0c6b92a 13 13 const jsxUtil = require('../util/jsx'); 14 14 const report = require('../util/report'); 15 const propTypesSortUtil = require('../util/propTypesSort'); 15 16 const eslintUtil = require('../util/eslint'); 16 17 … … 21 22 // Rule Definition 22 23 // ------------------------------------------------------------------------------ 23 24 function isCallbackPropName(name) {25 return /^on[A-Z]/.test(name);26 }27 24 28 25 function isMultilineProp(node) { … … 86 83 87 84 if (options.callbacksLast) { 88 const aIsCallback = isCallbackPropName(aProp);89 const bIsCallback = isCallbackPropName(bProp);85 const aIsCallback = propTypesSortUtil.isCallbackPropName(aProp); 86 const bIsCallback = propTypesSortUtil.isCallbackPropName(bProp); 90 87 if (aIsCallback && !bIsCallback) { 91 88 return 1; … … 280 277 * Checks if the `reservedFirst` option is valid 281 278 * @param {Object} context The context of the rule 282 * @param { Boolean|Array<String>} reservedFirst The `reservedFirst` option283 * @return {Function |undefined} If an error is detected, a function to generate the error message, otherwise, `undefined`279 * @param {boolean | string[]} reservedFirst The `reservedFirst` option 280 * @return {Function | undefined} If an error is detected, a function to generate the error message, otherwise, `undefined` 284 281 */ 285 282 // eslint-disable-next-line consistent-return … … 426 423 const previousValue = memo.value; 427 424 const currentValue = decl.value; 428 const previousIsCallback = isCallbackPropName(previousPropName);429 const currentIsCallback = isCallbackPropName(currentPropName);425 const previousIsCallback = propTypesSortUtil.isCallbackPropName(previousPropName); 426 const currentIsCallback = propTypesSortUtil.isCallbackPropName(currentPropName); 430 427 431 428 if (ignoreCase) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-space-before-closing.js
rd565449 r0c6b92a 24 24 }; 25 25 26 /** @type {import('eslint').Rule.RuleModule} */ 26 27 module.exports = { 27 28 meta: { … … 59 60 60 61 const leftToken = getTokenBeforeClosingBracket(node); 61 const closingSlash = sourceCode.getTokenAfter(leftToken);62 const closingSlash = /** @type {import("eslint").AST.Token} */ (sourceCode.getTokenAfter(leftToken)); 62 63 63 64 if (leftToken.loc.end.line !== closingSlash.loc.start.line) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-access-state-in-setstate.js
rd565449 r0c6b92a 7 7 8 8 const docsUrl = require('../util/docsUrl'); 9 const astUtil = require('../util/ast'); 9 10 const componentUtil = require('../util/componentUtil'); 10 11 const report = require('../util/report'); … … 19 20 }; 20 21 22 /** @type {import('eslint').Rule.RuleModule} */ 21 23 module.exports = { 22 24 meta: { … … 33 35 create(context) { 34 36 function isSetStateCall(node) { 35 return node.type === 'CallExpression'37 return astUtil.isCallExpression(node) 36 38 && node.callee.property 37 39 && node.callee.property.name === 'setState' … … 73 75 // method containing this.state to the methods array 74 76 methods.forEach((method) => { 75 if ( node.callee.name === method.methodName) {77 if ('name' in node.callee && node.callee.name === method.methodName) { 76 78 let current = node.parent; 77 79 while (current.type !== 'Program') { 78 80 if (current.type === 'MethodDefinition') { 79 81 methods.push({ 80 methodName: current.key.name,82 methodName: 'name' in current.key ? current.key.name : undefined, 81 83 node: method.node, 82 84 }); … … 93 95 while (current.type !== 'Program') { 94 96 if (isFirstArgumentInSetStateCall(current, node)) { 95 const methodName = node.callee.name;97 const methodName = 'name' in node.callee ? node.callee.name : undefined; 96 98 methods.forEach((method) => { 97 99 if (method.methodName === methodName) { … … 110 112 MemberExpression(node) { 111 113 if ( 112 node.property.name === 'state' 114 'name' in node.property 115 && node.property.name === 'state' 113 116 && node.object.type === 'ThisExpression' 114 117 && isClassComponent(node) 115 118 ) { 119 /** @type {import("eslint").Rule.Node} */ 116 120 let current = node; 117 121 while (current.type !== 'Program') { … … 127 131 if (current.type === 'MethodDefinition') { 128 132 methods.push({ 129 methodName: current.key.name, 130 node, 131 }); 132 break; 133 } else if (current.type === 'FunctionExpression' && current.parent.key) { 133 methodName: 'name' in current.key ? current.key.name : undefined, 134 node, 135 }); 136 break; 137 } else if ( 138 current.type === 'FunctionExpression' 139 && 'key' in current.parent 140 && current.parent.key 141 ) { 134 142 methods.push({ 135 methodName: current.parent.key.name,143 methodName: 'name' in current.parent.key ? current.parent.key.name : undefined, 136 144 node, 137 145 }); … … 144 152 node, 145 153 scope: getScope(context, node), 146 variableName: current.id.name,154 variableName: 'name' in current.id ? current.id.name : undefined, 147 155 }); 148 156 break; … … 156 164 Identifier(node) { 157 165 // Checks if the identifier is a variable within an object 166 /** @type {import("eslint").Rule.Node} */ 158 167 let current = node; 159 168 while (current.parent.type === 'BinaryExpression') { … … 161 170 } 162 171 if ( 163 current.parent.value === current164 || current.parent.object === current172 ('value' in current.parent && current.parent.value === current) 173 || ('object' in current.parent && current.parent.object === current) 165 174 ) { 166 175 while (current.type !== 'Program') { … … 180 189 181 190 ObjectPattern(node) { 182 const isDerivedFromThis = node.parent.init && node.parent.init.type === 'ThisExpression';191 const isDerivedFromThis = 'init' in node.parent && node.parent.init && node.parent.init.type === 'ThisExpression'; 183 192 node.properties.forEach((property) => { 184 if (property && property.key && property.key.name === 'state' && isDerivedFromThis) { 193 if ( 194 property 195 && 'key' in property 196 && property.key 197 && 'name' in property.key 198 && property.key.name === 'state' 199 && isDerivedFromThis 200 ) { 185 201 vars.push({ 186 202 node: property.key, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-adjacent-inline-elements.js
rd565449 r0c6b92a 9 9 const isCreateElement = require('../util/isCreateElement'); 10 10 const report = require('../util/report'); 11 const astUtil = require('../util/ast'); 11 12 12 13 // ------------------------------------------------------------------------------ … … 63 64 return true; 64 65 } 65 if ( node.type === 'CallExpression'&& inlineNames.indexOf(node.arguments[0].value) > -1) {66 if (astUtil.isCallExpression(node) && inlineNames.indexOf(node.arguments[0].value) > -1) { 66 67 return true; 67 68 } … … 77 78 }; 78 79 80 /** @type {import('eslint').Rule.RuleModule} */ 79 81 module.exports = { 80 82 meta: { … … 118 120 return; 119 121 } 120 const children = node.arguments[2].elements;122 const children = 'elements' in node.arguments[2] ? node.arguments[2].elements : undefined; 121 123 validate(node, children); 122 124 }, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-array-index-key.js
rd565449 r0c6b92a 190 190 } 191 191 192 if (node.type === 'CallExpression' 193 && node.callee 194 && node.callee.type === 'MemberExpression' 195 && node.callee.object 196 && isArrayIndex(node.callee.object) 197 && node.callee.property 198 && node.callee.property.type === 'Identifier' 199 && node.callee.property.name === 'toString' 192 if ( 193 astUtil.isCallExpression(node) 194 && node.callee 195 && node.callee.type === 'MemberExpression' 196 && node.callee.object 197 && isArrayIndex(node.callee.object) 198 && node.callee.property 199 && node.callee.property.type === 'Identifier' 200 && node.callee.property.name === 'toString' 200 201 ) { 201 202 // key={bar.toString()} … … 206 207 } 207 208 208 if (node.type === 'CallExpression' 209 && node.callee 210 && node.callee.type === 'Identifier' 211 && node.callee.name === 'String' 212 && Array.isArray(node.arguments) 213 && node.arguments.length > 0 214 && isArrayIndex(node.arguments[0]) 209 if ( 210 astUtil.isCallExpression(node) 211 && node.callee 212 && node.callee.type === 'Identifier' 213 && node.callee.name === 'String' 214 && Array.isArray(node.arguments) 215 && node.arguments.length > 0 216 && isArrayIndex(node.arguments[0]) 215 217 ) { 216 218 // key={String(bar)} -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-children-prop.js
rd565449 r0c6b92a 18 18 * @param {ASTNode} node - The AST node being checked. 19 19 * @param {Context} context - The AST node being checked. 20 * @returns { Boolean} - True if node is a createElement call with a props20 * @returns {boolean} - True if node is a createElement call with a props 21 21 * object literal, False if not. 22 22 */ … … 38 38 }; 39 39 40 /** @type {import('eslint').Rule.RuleModule} */ 40 41 module.exports = { 41 42 meta: { … … 87 88 } 88 89 89 const props = node.arguments[1].properties; 90 const childrenProp = props.find((prop) => prop.key && prop.key.name === 'children'); 90 const props = 'properties' in node.arguments[1] ? node.arguments[1].properties : undefined; 91 const childrenProp = props.find((prop) => ( 92 'key' in prop 93 && prop.key 94 && 'name' in prop.key 95 && prop.key.name === 'children' 96 )); 91 97 92 98 if (childrenProp) { 93 if ( childrenProp.value && !isFunction(childrenProp.value)) {99 if ('value' in childrenProp && childrenProp.value && !isFunction(childrenProp.value)) { 94 100 report(context, messages.passChildrenAsArgs, 'passChildrenAsArgs', { 95 101 node, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-danger-with-children.js
rd565449 r0c6b92a 18 18 }; 19 19 20 /** @type {import('eslint').Rule.RuleModule} */ 20 21 module.exports = { 21 22 meta: { … … 86 87 * Checks to see if a node is a line break 87 88 * @param {ASTNode} node The AST node being checked 88 * @returns { Boolean} True if node is a line break, false if not89 * @returns {boolean} True if node is a line break, false if not 89 90 */ 90 91 function isLineBreak(node) { … … 120 121 node.callee 121 122 && node.callee.type === 'MemberExpression' 123 && 'name' in node.callee.property 122 124 && node.callee.property.name === 'createElement' 123 125 && node.arguments.length > 1 -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-danger.js
rd565449 r0c6b92a 30 30 /** 31 31 * Checks if a JSX attribute is dangerous. 32 * @param { String} name - Name of the attribute to check.32 * @param {string} name - Name of the attribute to check. 33 33 * @returns {boolean} Whether or not the attribute is dangerous. 34 34 */ -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-deprecated.js
rd565449 r0c6b92a 116 116 }; 117 117 118 /** @type {import('eslint').Rule.RuleModule} */ 118 119 module.exports = { 119 120 meta: { … … 227 228 return; 228 229 } 229 node.specifiers.filter(((s) => s.imported)).forEach((specifier) => { 230 checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier); 230 node.specifiers.filter(((s) => 'imported' in s && s.imported)).forEach((specifier) => { 231 // TODO, semver-major: remove `in` check as part of jsdoc->tsdoc migration 232 checkDeprecation(node, 'imported' in specifier && `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier); 231 233 }); 232 234 }, … … 234 236 VariableDeclarator(node) { 235 237 const reactModuleName = getReactModuleName(node); 236 const isRequire = node.init && node.init.callee && node.init.callee.name === 'require'; 238 const isRequire = node.init 239 && 'callee' in node.init 240 && node.init.callee 241 && 'name' in node.init.callee 242 && node.init.callee.name === 'require'; 237 243 const isReactRequire = node.init 244 && 'arguments' in node.init 238 245 && node.init.arguments 239 246 && node.init.arguments.length 240 && typeof MODULES[ node.init.arguments[0].value] !== 'undefined';247 && typeof MODULES['value' in node.init.arguments[0] ? node.init.arguments[0].value : undefined] !== 'undefined'; 241 248 const isDestructuring = node.id && node.id.type === 'ObjectPattern'; 242 249 … … 247 254 return; 248 255 } 249 node.id.properties.filter((p) => p.type !== 'RestElement' && p.key).forEach((property) => { 250 checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`, property); 256 257 ('properties' in node.id ? node.id.properties : undefined).filter((p) => p.type !== 'RestElement' && p.key).forEach((property) => { 258 checkDeprecation( 259 node, 260 'key' in property && 'name' in property.key && `${reactModuleName || pragma}.${property.key.name}`, 261 property 262 ); 251 263 }); 252 264 }, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-direct-mutation-state.js
rd565449 r0c6b92a 39 39 * Checks if the component is valid 40 40 * @param {Object} component The component to process 41 * @returns { Boolean} True if the component is valid, false if not.41 * @returns {boolean} True if the component is valid, false if not. 42 42 */ 43 43 function isValid(component) { 44 return Boolean(component && !component.mutateSetState);44 return !!component && !component.mutateSetState; 45 45 } 46 46 … … 74 74 * Determine if we should currently ignore assignments in this component. 75 75 * @param {?Object} component The component to process 76 * @returns { Boolean} True if we should skip assignment checks.76 * @returns {boolean} True if we should skip assignment checks. 77 77 */ 78 78 function shouldIgnoreComponent(component) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-find-dom-node.js
rd565449 r0c6b92a 17 17 }; 18 18 19 /** @type {import('eslint').Rule.RuleModule} */ 19 20 module.exports = { 20 21 meta: { … … 36 37 const callee = node.callee; 37 38 38 const isfindDOMNode = (callee.name === 'findDOMNode') 39 || (callee.property && callee.property.name === 'findDOMNode'); 40 if (!isfindDOMNode) { 39 const isFindDOMNode = ('name' in callee && callee.name === 'findDOMNode') || ( 40 'property' in callee 41 && callee.property 42 && 'name' in callee.property 43 && callee.property.name === 'findDOMNode' 44 ); 45 46 if (!isFindDOMNode) { 41 47 return; 42 48 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-invalid-html-attribute.js
rd565449 r0c6b92a 290 290 291 291 const singleAttributeParts = splitIntoRangedParts(node, /(\S+)/g); 292 for (const singlePart of singleAttributeParts){292 singleAttributeParts.forEach((singlePart) => { 293 293 const allowedTags = VALID_VALUES.get(attributeName).get(singlePart.value); 294 294 const reportingValue = singlePart.reportingValue; … … 330 330 }); 331 331 } 332 } 332 }); 333 333 334 334 const allowedPairsForAttribute = VALID_PAIR_VALUES.get(attributeName); 335 335 if (allowedPairsForAttribute) { 336 336 const pairAttributeParts = splitIntoRangedParts(node, /(?=(\b\S+\s*\S+))/g); 337 for (const pairPart of pairAttributeParts) { 338 for (const allowedPair of allowedPairsForAttribute) { 339 const pairing = allowedPair[0]; 340 const siblings = allowedPair[1]; 337 pairAttributeParts.forEach((pairPart) => { 338 allowedPairsForAttribute.forEach((siblings, pairing) => { 341 339 const attributes = pairPart.reportingValue.split('\u0020'); 342 340 const firstValue = attributes[0]; … … 358 356 } 359 357 } 360 } 361 } 358 }); 359 }); 362 360 } 363 361 364 362 const whitespaceParts = splitIntoRangedParts(node, /(\s+)/g); 365 for (const whitespacePart of whitespaceParts){363 whitespaceParts.forEach((whitespacePart) => { 366 364 const data = { attributeName }; 367 365 … … 387 385 }); 388 386 } 389 } 387 }); 390 388 } 391 389 … … 580 578 581 579 if (prop.value.type === 'ArrayExpression') { 582 for (const value of prop.value.elements){580 prop.value.elements.forEach((value) => { 583 581 checkPropValidValue(context, node, value, attribute); 584 } 582 }); 585 583 586 584 // eslint-disable-next-line no-continue … … 592 590 } 593 591 592 /** @type {import('eslint').Rule.RuleModule} */ 594 593 module.exports = { 595 594 meta: { … … 641 640 642 641 // ignore non-HTML elements 643 if ( !HTML_ELEMENTS.has(elemNameArg.value)) {642 if (typeof elemNameArg.value === 'string' && !HTML_ELEMENTS.has(elemNameArg.value)) { 644 643 return; 645 644 } … … 647 646 const attributes = new Set(context.options[0] || DEFAULT_ATTRIBUTES); 648 647 649 for (const attribute of attributes){648 attributes.forEach((attribute) => { 650 649 checkCreateProps(context, node, attribute); 651 } 650 }); 652 651 }, 653 652 }; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-is-mounted.js
rd565449 r0c6b92a 18 18 }; 19 19 20 /** @type {import('eslint').Rule.RuleModule} */ 20 21 module.exports = { 21 22 meta: { … … 39 40 return; 40 41 } 41 if (callee.object.type !== 'ThisExpression' || callee.property.name !== 'isMounted') { 42 if ( 43 callee.object.type !== 'ThisExpression' 44 || !('name' in callee.property) 45 || callee.property.name !== 'isMounted' 46 ) { 42 47 return; 43 48 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-multi-comp.js
rd565449 r0c6b92a 51 51 * Checks if the component is ignored 52 52 * @param {Object} component The component being checked. 53 * @returns { Boolean} True if the component is ignored, false if not.53 * @returns {boolean} True if the component is ignored, false if not. 54 54 */ 55 55 function isIgnored(component) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-object-type-as-default-prop.js
rd565449 r0c6b92a 10 10 const Components = require('../util/Components'); 11 11 const docsUrl = require('../util/docsUrl'); 12 const astUtil = require('../util/ast'); 12 13 const report = require('../util/report'); 13 14 … … 56 57 }); 57 58 } else if ( 58 propDefaultValueType === 'CallExpression'59 astUtil.isCallExpression(propDefaultValue.right) 59 60 && propDefaultValue.right.callee.type === 'Identifier' 60 61 && propDefaultValue.right.callee.name === 'Symbol' -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-redundant-should-component-update.js
rd565449 r0c6b92a 37 37 * Checks for shouldComponentUpdate property 38 38 * @param {ASTNode} node The AST node being checked. 39 * @returns { Boolean} Whether or not the property exists.39 * @returns {boolean} Whether or not the property exists. 40 40 */ 41 41 function hasShouldComponentUpdate(node) { … … 50 50 * Get name of node if available 51 51 * @param {ASTNode} node The AST node being checked. 52 * @return { String} The name of the node52 * @return {string} The name of the node 53 53 */ 54 54 function getNodeName(node) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-render-return-value.js
rd565449 r0c6b92a 18 18 }; 19 19 20 /** @type {import('eslint').Rule.RuleModule} */ 20 21 module.exports = { 21 22 meta: { … … 57 58 callee.object.type !== 'Identifier' 58 59 || !calleeObjectName.test(callee.object.name) 59 || callee.property.name !== 'render'60 || (!('name' in callee.property) || callee.property.name !== 'render') 60 61 ) { 61 62 return; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-set-state.js
rd565449 r0c6b92a 39 39 * Checks if the component is valid 40 40 * @param {Object} component The component to process 41 * @returns { Boolean} True if the component is valid, false if not.41 * @returns {boolean} True if the component is valid, false if not. 42 42 */ 43 43 function isValid(component) { 44 return Boolean(component && !component.useSetState);44 return !!component && !component.useSetState; 45 45 } 46 46 … … 50 50 */ 51 51 function reportSetStateUsages(component) { 52 let setStateUsage;53 52 for (let i = 0, j = component.setStateUsages.length; i < j; i++) { 54 setStateUsage = component.setStateUsages[i];53 const setStateUsage = component.setStateUsages[i]; 55 54 report(context, messages.noSetState, 'noSetState', { 56 55 node: setStateUsage, -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-string-refs.js
rd565449 r0c6b92a 9 9 const docsUrl = require('../util/docsUrl'); 10 10 const report = require('../util/report'); 11 const testReactVersion = require('../util/version').testReactVersion; 11 12 12 13 // ------------------------------------------------------------------------------ … … 43 44 44 45 create(context) { 46 const checkRefsUsage = testReactVersion(context, '< 18.3.0'); // `this.refs` is writable in React 18.3.0 and later, see https://github.com/facebook/react/pull/28867 45 47 const detectTemplateLiterals = context.options[0] ? context.options[0].noTemplateLiterals : false; 46 48 /** 47 49 * Checks if we are using refs 48 50 * @param {ASTNode} node The AST node being checked. 49 * @returns { Boolean} True if we are using refs, false if not.51 * @returns {boolean} True if we are using refs, false if not. 50 52 */ 51 53 function isRefsUsage(node) { … … 60 62 * Checks if we are using a ref attribute 61 63 * @param {ASTNode} node The AST node being checked. 62 * @returns { Boolean} True if we are using a ref attribute, false if not.64 * @returns {boolean} True if we are using a ref attribute, false if not. 63 65 */ 64 66 function isRefAttribute(node) { 65 return !!( 66 node.type === 'JSXAttribute' 67 && node.name 68 && node.name.name === 'ref' 69 ); 67 return node.type === 'JSXAttribute' 68 && !!node.name 69 && node.name.name === 'ref'; 70 70 } 71 71 … … 73 73 * Checks if a node contains a string value 74 74 * @param {ASTNode} node The AST node being checked. 75 * @returns { Boolean} True if the node contains a string value, false if not.75 * @returns {boolean} True if the node contains a string value, false if not. 76 76 */ 77 77 function containsStringLiteral(node) { 78 return !!( 79 node.value 78 return !!node.value 80 79 && node.value.type === 'Literal' 81 && typeof node.value.value === 'string' 82 ); 80 && typeof node.value.value === 'string'; 83 81 } 84 82 … … 86 84 * Checks if a node contains a string value within a jsx expression 87 85 * @param {ASTNode} node The AST node being checked. 88 * @returns { Boolean} True if the node contains a string value within a jsx expression, false if not.86 * @returns {boolean} True if the node contains a string value within a jsx expression, false if not. 89 87 */ 90 88 function containsStringExpressionContainer(node) { 91 return !!( 92 node.value 89 return !!node.value 93 90 && node.value.type === 'JSXExpressionContainer' 94 91 && node.value.expression 95 92 && ((node.value.expression.type === 'Literal' && typeof node.value.expression.value === 'string') 96 || (node.value.expression.type === 'TemplateLiteral' && detectTemplateLiterals)) 97 ); 93 || (node.value.expression.type === 'TemplateLiteral' && detectTemplateLiterals)); 98 94 } 99 95 100 96 return { 101 97 MemberExpression(node) { 102 if ( isRefsUsage(node)) {98 if (checkRefsUsage && isRefsUsage(node)) { 103 99 report(context, messages.thisRefsDeprecated, 'thisRefsDeprecated', { 104 100 node, … … 106 102 } 107 103 }, 104 108 105 JSXAttribute(node) { 109 106 if ( -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-typos.js
rd565449 r0c6b92a 8 8 const Components = require('../util/Components'); 9 9 const docsUrl = require('../util/docsUrl'); 10 const astUtil = require('../util/ast'); 10 11 const componentUtil = require('../util/componentUtil'); 11 12 const report = require('../util/report'); … … 110 111 ) { // PropTypes.myProp 111 112 checkValidPropType(node.property); 112 } else if ( node.object.type === 'CallExpression') {113 } else if (astUtil.isCallExpression(node.object)) { 113 114 checkValidPropTypeQualifier(node.property); 114 115 checkValidCallExpression(node.object); 115 116 } 116 } else if ( node.type === 'CallExpression') {117 } else if (astUtil.isCallExpression(node)) { 117 118 checkValidCallExpression(node); 118 119 } … … 195 196 if (node.specifiers.length >= 1) { 196 197 const propTypesSpecifier = node.specifiers.find((specifier) => ( 197 specifier.imported && specifier.imported.name === 'PropTypes' 198 specifier.imported 199 && specifier.imported.name === 'PropTypes' 198 200 )); 199 201 if (propTypesSpecifier) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unescaped-entities.js
rd565449 r0c6b92a 10 10 const jsxUtil = require('../util/jsx'); 11 11 const report = require('../util/report'); 12 const getMessageData = require('../util/message'); 12 13 13 14 // ------------------------------------------------------------------------------ … … 35 36 unescapedEntity: 'HTML entity, `{{entity}}` , must be escaped.', 36 37 unescapedEntityAlts: '`{{entity}}` can be escaped with {{alts}}.', 38 replaceWithAlt: 'Replace with `{{alt}}`.', 37 39 }; 38 40 … … 40 42 module.exports = { 41 43 meta: { 44 hasSuggestions: true, 42 45 docs: { 43 46 description: 'Disallow unescaped HTML entities from appearing in markup', … … 118 121 alts: entities[j].alternatives.map((alt) => `\`${alt}\``).join(', '), 119 122 }, 123 suggest: entities[j].alternatives.map((alt) => Object.assign( 124 getMessageData('replaceWithAlt', messages.replaceWithAlt), 125 { 126 data: { alt }, 127 fix(fixer) { 128 const lineToChange = i - node.loc.start.line; 129 130 const newText = node.raw.split('\n').map((line, idx) => { 131 if (idx === lineToChange) { 132 return line.slice(0, index) + alt + line.slice(index + 1); 133 } 134 135 return line; 136 }).join('\n'); 137 138 return fixer.replaceText(node, newText); 139 }, 140 } 141 )), 120 142 }); 121 143 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unknown-property.js
rd565449 r0c6b92a 416 416 * Note - these exclusions are not made by React core team, but `eslint-plugin-react` community. 417 417 * 418 * @param { String} name - Attribute name to be normalized419 * @returns { String} Result418 * @param {string} name - Attribute name to be normalized 419 * @returns {string} Result 420 420 */ 421 421 function normalizeAttributeCase(name) { … … 429 429 * then the attribute is a valid data attribute. 430 430 * 431 * @param { String} name - Attribute name to be tested431 * @param {string} name - Attribute name to be tested 432 432 * @returns {boolean} Result 433 433 */ … … 439 439 * Checks if an attribute name has at least one uppercase characters 440 440 * 441 * @param { String} name441 * @param {string} name 442 442 * @returns {boolean} Result 443 443 */ … … 450 450 * of standard aria property names 451 451 * 452 * @param { String} name - Attribute name to be tested453 * @returns { Boolean} Result452 * @param {string} name - Attribute name to be tested 453 * @returns {boolean} Result 454 454 */ 455 455 … … 461 461 * Extracts the tag name for the JSXAttribute 462 462 * @param {JSXAttribute} node - JSXAttribute being tested. 463 * @returns { String|null} tag name463 * @returns {string | null} tag name 464 464 */ 465 465 function getTagName(node) { 466 if (node && node.parent && node.parent.name && node.parent.name) { 466 if ( 467 node 468 && node.parent 469 && node.parent.name 470 ) { 467 471 return node.parent.name.name; 468 472 } … … 474 478 * something like <Foo.bar /> 475 479 * @param {JSXAttribute} node - JSXAttribute being tested. 476 * @returns { Boolean} result480 * @returns {boolean} result 477 481 */ 478 482 function tagNameHasDot(node) { … … 486 490 /** 487 491 * Get the standard name of the attribute. 488 * @param { String} name - Name of the attribute.489 * @param { String} context - eslint context490 * @returns { String | undefined} The standard name of the attribute, or undefined if no standard name was found.492 * @param {string} name - Name of the attribute. 493 * @param {object} context - eslint context 494 * @returns {string | undefined} The standard name of the attribute, or undefined if no standard name was found. 491 495 */ 492 496 function getStandardName(name, context) { … … 513 517 }; 514 518 519 /** @type {import('eslint').Rule.RuleModule} */ 515 520 module.exports = { 516 521 meta: { … … 593 598 594 599 // Some attributes are allowed on some tags only 595 const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) ? ATTRIBUTE_TAGS_MAP[/** @type {keyof ATTRIBUTE_TAGS_MAP} */ (name)] : null; 600 const allowedTags = has(ATTRIBUTE_TAGS_MAP, name) 601 ? ATTRIBUTE_TAGS_MAP[/** @type {keyof ATTRIBUTE_TAGS_MAP} */ (name)] 602 : null; 596 603 if (tagName && allowedTags) { 597 604 // Scenario 1A: Allowed attribute found where not supposed to, report it -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unsafe.js
rd565449 r0c6b92a 58 58 UNSAFE_componentWillMount: { 59 59 newMethod: 'componentDidMount', 60 details: 61 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 60 details: 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 62 61 }, 63 62 UNSAFE_componentWillReceiveProps: { 64 63 newMethod: 'getDerivedStateFromProps', 65 details: 66 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 64 details: 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 67 65 }, 68 66 UNSAFE_componentWillUpdate: { 69 67 newMethod: 'componentDidUpdate', 70 details: 71 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 68 details: 'See https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.', 72 69 }, 73 70 }; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unstable-nested-components.js
rd565449 r0c6b92a 6 6 'use strict'; 7 7 8 const minimatch = require('minimatch'); 8 9 const Components = require('../util/Components'); 9 10 const docsUrl = require('../util/docsUrl'); 11 const astUtil = require('../util/ast'); 10 12 const isCreateElement = require('../util/isCreateElement'); 11 13 const report = require('../util/report'); … … 24 26 /** 25 27 * Generate error message with given parent component name 26 * @param { String} parentName Name of the parent component, if known27 * @returns { String} Error message with parent component name28 * @param {string} parentName Name of the parent component, if known 29 * @returns {string} Error message with parent component name 28 30 */ 29 31 function generateErrorMessageWithParentName(parentName) { … … 32 34 33 35 /** 34 * Check whether given text starts with `render`. Comparison is case-sensitive. 35 * @param {String} text Text to validate 36 * @returns {Boolean} 37 */ 38 function startsWithRender(text) { 39 return (text || '').startsWith('render'); 36 * Check whether given text matches the pattern passed in. 37 * @param {string} text Text to validate 38 * @param {string} pattern Pattern to match against 39 * @returns {boolean} 40 */ 41 function propMatchesRenderPropPattern(text, pattern) { 42 return typeof text === 'string' && minimatch(text, pattern); 40 43 } 41 44 … … 63 66 * @param {ASTNode} node The AST node 64 67 * @param {Context} context eslint context 65 * @returns { Boolean} True if node is a `createElement` call, false if not68 * @returns {boolean} True if node is a `createElement` call, false if not 66 69 */ 67 70 function isCreateElementMatcher(node, context) { 68 71 return ( 69 node 70 && node.type === 'CallExpression' 72 astUtil.isCallExpression(node) 71 73 && isCreateElement(context, node) 72 74 ); … … 76 78 * Matcher used to check whether given node is a `ObjectExpression` 77 79 * @param {ASTNode} node The AST node 78 * @returns { Boolean} True if node is a `ObjectExpression`, false if not80 * @returns {boolean} True if node is a `ObjectExpression`, false if not 79 81 */ 80 82 function isObjectExpressionMatcher(node) { … … 85 87 * Matcher used to check whether given node is a `JSXExpressionContainer` 86 88 * @param {ASTNode} node The AST node 87 * @returns { Boolean} True if node is a `JSXExpressionContainer`, false if not89 * @returns {boolean} True if node is a `JSXExpressionContainer`, false if not 88 90 */ 89 91 function isJSXExpressionContainerMatcher(node) { … … 94 96 * Matcher used to check whether given node is a `JSXAttribute` of `JSXExpressionContainer` 95 97 * @param {ASTNode} node The AST node 96 * @returns { Boolean} True if node is a `JSXAttribute` of `JSXExpressionContainer`, false if not98 * @returns {boolean} True if node is a `JSXAttribute` of `JSXExpressionContainer`, false if not 97 99 */ 98 100 function isJSXAttributeOfExpressionContainerMatcher(node) { … … 108 110 * Matcher used to check whether given node is an object `Property` 109 111 * @param {ASTNode} node The AST node 110 * @returns { Boolean} True if node is a `Property`, false if not112 * @returns {boolean} True if node is a `Property`, false if not 111 113 */ 112 114 function isPropertyOfObjectExpressionMatcher(node) { … … 116 118 && node.parent.type === 'Property' 117 119 ); 118 }119 120 /**121 * Matcher used to check whether given node is a `CallExpression`122 * @param {ASTNode} node The AST node123 * @returns {Boolean} True if node is a `CallExpression`, false if not124 */125 function isCallExpressionMatcher(node) {126 return node && node.type === 'CallExpression';127 120 } 128 121 … … 133 126 * ``` 134 127 * @param {ASTNode} node The AST node 135 * @returns { Boolean} True if node is directly inside `map` call, false if not128 * @returns {boolean} True if node is directly inside `map` call, false if not 136 129 */ 137 130 function isMapCall(node) { … … 148 141 * @param {ASTNode} node The AST node 149 142 * @param {Context} context eslint context 150 * @returns { Boolean} True if node is a `ReturnStatement` of a React hook, false if not143 * @returns {boolean} True if node is a `ReturnStatement` of a React hook, false if not 151 144 */ 152 145 function isReturnStatementOfHook(node, context) { … … 159 152 } 160 153 161 const callExpression = getClosestMatchingParent(node, context, isCallExpressionMatcher);154 const callExpression = getClosestMatchingParent(node, context, astUtil.isCallExpression); 162 155 return ( 163 156 callExpression … … 175 168 * @param {ASTNode} node The AST node 176 169 * @param {Context} context eslint context 177 * @returns {Boolean} True if component is declared inside a render prop, false if not 178 */ 179 function isComponentInRenderProp(node, context) { 170 * @param {string} propNamePattern a pattern to match render props against 171 * @returns {boolean} True if component is declared inside a render prop, false if not 172 */ 173 function isComponentInRenderProp(node, context, propNamePattern) { 180 174 if ( 181 175 node … … 183 177 && node.parent.type === 'Property' 184 178 && node.parent.key 185 && startsWithRender(node.parent.key.name)179 && propMatchesRenderPropPattern(node.parent.key.name, propNamePattern) 186 180 ) { 187 181 return true; … … 212 206 213 207 // Starts with render, e.g. <Component renderFooter={() => <div />} /> 214 if ( startsWithRender(propName)) {208 if (propMatchesRenderPropPattern(propName, propNamePattern)) { 215 209 return true; 216 210 } … … 232 226 * ``` 233 227 * @param {ASTNode} node The AST node 234 * @returns {Boolean} True if component is declared inside a render property, false if not 235 */ 236 function isDirectValueOfRenderProperty(node) { 228 * @param {string} propNamePattern The pattern to match render props against 229 * @returns {boolean} True if component is declared inside a render property, false if not 230 */ 231 function isDirectValueOfRenderProperty(node, propNamePattern) { 237 232 return ( 238 233 node … … 241 236 && node.parent.key 242 237 && node.parent.key.type === 'Identifier' 243 && startsWithRender(node.parent.key.name)238 && propMatchesRenderPropPattern(node.parent.key.name, propNamePattern) 244 239 ); 245 240 } … … 248 243 * Resolve the component name of given node 249 244 * @param {ASTNode} node The AST node of the component 250 * @returns { String} Name of the component, if any245 * @returns {string} Name of the component, if any 251 246 */ 252 247 function resolveComponentName(node) { … … 287 282 type: 'boolean', 288 283 }, 284 propNamePattern: { 285 type: 'string', 286 }, 289 287 }, 290 288 additionalProperties: false, … … 294 292 create: Components.detect((context, components, utils) => { 295 293 const allowAsProps = context.options.some((option) => option && option.allowAsProps); 294 const propNamePattern = (context.options[0] || {}).propNamePattern || 'render*'; 296 295 297 296 /** … … 304 303 * ``` 305 304 * @param {ASTNode} node The AST node being checked 306 * @returns { Boolean} True if node is inside class component's render block, false if not305 * @returns {boolean} True if node is inside class component's render block, false if not 307 306 */ 308 307 function isInsideRenderMethod(node) { … … 332 331 * ``` 333 332 * @param {ASTNode} node The AST node being checked 334 * @returns { Boolean} True if given node a function component declared inside class component, false if not333 * @returns {boolean} True if given node a function component declared inside class component, false if not 335 334 */ 336 335 function isFunctionComponentInsideClassComponent(node) { … … 355 354 * ``` 356 355 * @param {ASTNode} node The AST node 357 * @returns { Boolean} True if node is declare inside `createElement` call's props, false if not356 * @returns {boolean} True if node is declare inside `createElement` call's props, false if not 358 357 */ 359 358 function isComponentInsideCreateElementsProp(node) { … … 378 377 * ``` 379 378 * @param {ASTNode} node The AST node being checked 380 * @returns { Boolean} True if node is a component declared inside prop, false if not379 * @returns {boolean} True if node is a component declared inside prop, false if not 381 380 */ 382 381 function isComponentInProp(node) { … … 400 399 * ``` 401 400 * @param {ASTNode} node The AST node being checked 402 * @returns { Boolean} True if node is a stateless component returning non-JSX, false if not401 * @returns {boolean} True if node is a stateless component returning non-JSX, false if not 403 402 */ 404 403 function isStatelessComponentReturningNull(node) { … … 428 427 if ( 429 428 // Support allowAsProps option 430 (isDeclaredInsideProps && (allowAsProps || isComponentInRenderProp(node, context )))429 (isDeclaredInsideProps && (allowAsProps || isComponentInRenderProp(node, context, propNamePattern))) 431 430 432 431 // Prevent reporting components created inside Array.map calls … … 438 437 439 438 // Do not mark objects containing render methods 440 || isDirectValueOfRenderProperty(node )439 || isDirectValueOfRenderProperty(node, propNamePattern) 441 440 442 441 // Prevent reporting nested class components twice -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unused-class-component-methods.js
rd565449 r0c6b92a 99 99 }; 100 100 101 /** @type {import('eslint').Rule.RuleModule} */ 101 102 module.exports = { 102 103 meta: { … … 249 250 .filter((prop) => prop.type === 'Property' && isKeyLiteralLike(prop, prop.key)) 250 251 .forEach((prop) => { 251 addUsedProperty( prop.key);252 addUsedProperty('key' in prop ? prop.key : undefined); 252 253 }); 253 254 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unused-prop-types.js
rd565449 r0c6b92a 14 14 const docsUrl = require('../util/docsUrl'); 15 15 const report = require('../util/report'); 16 17 /** 18 * Checks if the component must be validated 19 * @param {Object} component The component to process 20 * @returns {boolean} True if the component must be validated, false if not. 21 */ 22 function mustBeValidated(component) { 23 return !!component && !component.ignoreUnusedPropTypesValidation; 24 } 16 25 17 26 // ------------------------------------------------------------------------------ … … 65 74 /** 66 75 * Checks if the prop is ignored 67 * @param { String} name Name of the prop to check.68 * @returns { Boolean} True if the prop is ignored, false if not.76 * @param {string} name Name of the prop to check. 77 * @returns {boolean} True if the prop is ignored, false if not. 69 78 */ 70 79 function isIgnored(name) { … … 73 82 74 83 /** 75 * Checks if the component must be validated76 * @param {Object} component The component to process77 * @returns {Boolean} True if the component must be validated, false if not.78 */79 function mustBeValidated(component) {80 return Boolean(81 component82 && !component.ignoreUnusedPropTypesValidation83 );84 }85 86 /**87 84 * Checks if a prop is used 88 85 * @param {ASTNode} node The AST node being checked. 89 86 * @param {Object} prop Declared prop object 90 * @returns { Boolean} True if the prop is used, false if not.87 * @returns {boolean} True if the prop is used, false if not. 91 88 */ 92 89 function isPropUsed(node, prop) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unused-state.js
rd565449 r0c6b92a 11 11 12 12 const docsUrl = require('../util/docsUrl'); 13 const ast = require('../util/ast');13 const astUtil = require('../util/ast'); 14 14 const componentUtil = require('../util/componentUtil'); 15 15 const report = require('../util/report'); … … 45 45 46 46 function isThisExpression(node) { 47 return ast .unwrapTSAsExpression(uncast(node)).type === 'ThisExpression';47 return astUtil.unwrapTSAsExpression(uncast(node)).type === 'ThisExpression'; 48 48 } 49 49 … … 66 66 67 67 function isSetStateCall(node) { 68 const unwrappedCalleeNode = ast .unwrapTSAsExpression(node.callee);68 const unwrappedCalleeNode = astUtil.unwrapTSAsExpression(node.callee); 69 69 70 70 return ( … … 79 79 }; 80 80 81 /** @type {import('eslint').Rule.RuleModule} */ 81 82 module.exports = { 82 83 meta: { … … 175 176 // destructures `this.state`. 176 177 function handleStateDestructuring(node) { 177 for (const prop of node.properties){178 node.properties.forEach((prop) => { 178 179 if (prop.type === 'Property') { 179 180 addUsedStateField(prop.key); … … 184 185 classInfo.aliases.add(getName(prop.argument)); 185 186 } 186 } 187 }); 187 188 } 188 189 … … 190 191 // AssignmentExpressions and VariableDeclarators. 191 192 function handleAssignment(left, right) { 192 const unwrappedRight = ast .unwrapTSAsExpression(right);193 const unwrappedRight = astUtil.unwrapTSAsExpression(right); 193 194 194 195 switch (left.type) { … … 202 203 handleStateDestructuring(left); 203 204 } else if (isThisExpression(unwrappedRight) && classInfo.aliases) { 204 for (const prop of left.properties){205 left.properties.forEach((prop) => { 205 206 if (prop.type === 'Property' && getName(prop.key) === 'state') { 206 207 const name = getName(prop.value); … … 211 212 } 212 213 } 213 } 214 }); 214 215 } 215 216 break; … … 221 222 function reportUnusedFields() { 222 223 // Report all unused state fields. 223 for (const node of classInfo.stateFields){224 classInfo.stateFields.forEach((node) => { 224 225 const name = getName(node.key); 225 226 if (!classInfo.usedStateFields.has(name)) { … … 231 232 }); 232 233 } 233 } 234 }); 234 235 } 235 236 … … 293 294 } 294 295 295 const unwrappedNode = ast .unwrapTSAsExpression(node);296 const unwrappedArgumentNode = ast .unwrapTSAsExpression(unwrappedNode.arguments[0]);296 const unwrappedNode = astUtil.unwrapTSAsExpression(node); 297 const unwrappedArgumentNode = astUtil.unwrapTSAsExpression(unwrappedNode.arguments[0]); 297 298 298 299 // If we're looking at a `this.setState({})` invocation, record all the … … 309 310 && unwrappedArgumentNode.type === 'ArrowFunctionExpression' 310 311 ) { 311 const unwrappedBodyNode = ast .unwrapTSAsExpression(unwrappedArgumentNode.body);312 const unwrappedBodyNode = astUtil.unwrapTSAsExpression(unwrappedArgumentNode.body); 312 313 313 314 if (unwrappedBodyNode.type === 'ObjectExpression') { … … 331 332 // If we see state being assigned as a class property using an object 332 333 // expression, record all the fields of that object as state fields. 333 const unwrappedValueNode = ast .unwrapTSAsExpression(node.value);334 const unwrappedValueNode = astUtil.unwrapTSAsExpression(node.value); 334 335 335 336 const name = getName(node.key); … … 432 433 } 433 434 434 if (parent.key.name === 'getInitialState') { 435 if ( 436 'key' in parent 437 && 'name' in parent.key 438 && parent.key.name === 'getInitialState' 439 ) { 435 440 const body = node.body.body; 436 441 const lastBodyNode = body[body.length - 1]; … … 453 458 } 454 459 455 const unwrappedLeft = ast .unwrapTSAsExpression(node.left);456 const unwrappedRight = ast .unwrapTSAsExpression(node.right);460 const unwrappedLeft = astUtil.unwrapTSAsExpression(node.left); 461 const unwrappedRight = astUtil.unwrapTSAsExpression(node.right); 457 462 458 463 // Check for assignments like `this.state = {}` … … 464 469 ) { 465 470 // Find the nearest function expression containing this assignment. 471 /** @type {import("eslint").Rule.Node} */ 466 472 let fn = node; 467 473 while (fn.type !== 'FunctionExpression' && fn.parent) { … … 494 500 return; 495 501 } 496 if (isStateReference(ast .unwrapTSAsExpression(node.object))) {502 if (isStateReference(astUtil.unwrapTSAsExpression(node.object))) { 497 503 // If we see this.state[foo] access, give up. 498 504 if (node.computed && node.property.type !== 'Literal') { … … 503 509 addUsedStateField(node.property); 504 510 // If we see a `this.state` access in a CallExpression, give up. 505 } else if (isStateReference(node) && node.parent.type === 'CallExpression') {511 } else if (isStateReference(node) && astUtil.isCallExpression(node.parent)) { 506 512 classInfo = null; 507 513 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/prefer-exact-props.js
rd565449 r0c6b92a 7 7 const Components = require('../util/Components'); 8 8 const docsUrl = require('../util/docsUrl'); 9 const astUtil = require('../util/ast'); 9 10 const propsUtil = require('../util/props'); 10 11 const propWrapperUtil = require('../util/propWrapper'); … … 82 83 function isNonExactPropWrapperFunction(node) { 83 84 return ( 84 node 85 && node.type === 'CallExpression' 85 astUtil.isCallExpression(node) 86 86 && !propWrapperUtil.isExactPropWrapperFunction(context, getText(context, node.callee)) 87 87 ); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/prefer-stateless-function.js
rd565449 r0c6b92a 71 71 body.length === 1 72 72 && body[0].type === 'ExpressionStatement' 73 && body[0].expression.type === 'CallExpression'73 && astUtil.isCallExpression(body[0].expression) 74 74 && body[0].expression.callee.type === 'Super' 75 75 ); … … 192 192 * Check if a given AST node have any other properties the ones available in stateless components 193 193 * @param {ASTNode} node The AST node being checked. 194 * @returns { Boolean} True if the node has at least one other property, false if not.194 * @returns {boolean} True if the node has at least one other property, false if not. 195 195 */ 196 196 function hasOtherProperties(node) { … … 355 355 scope = scope.upper; 356 356 } 357 const isRender = blockNode && blockNode.key && blockNode.key.name === 'render'; 357 const isRender = blockNode 358 && blockNode.key 359 && blockNode.key.name === 'render'; 358 360 const allowNull = testReactVersion(context, '>= 15.0.0'); // Stateless components can return null since React 15 359 361 const isReturningJSX = utils.isReturningJSX(node, !allowNull); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/prop-types.js
rd565449 r0c6b92a 65 65 /** 66 66 * Checks if the prop is ignored 67 * @param { String} name Name of the prop to check.68 * @returns { Boolean} True if the prop is ignored, false if not.67 * @param {string} name Name of the prop to check. 68 * @returns {boolean} True if the prop is ignored, false if not. 69 69 */ 70 70 function isIgnored(name) { … … 90 90 * Internal: Checks if the prop is declared 91 91 * @param {Object} declaredPropTypes Description of propTypes declared in the current component 92 * @param { String[]} keyList Dot separated name of the prop to check.92 * @param {string[]} keyList Dot separated name of the prop to check. 93 93 * @returns {boolean} True if the prop is declared, false if not. 94 94 */ … … 149 149 * Checks if the prop is declared 150 150 * @param {ASTNode} node The AST node being checked. 151 * @param { String[]} names List of names of the prop to check.152 * @returns { Boolean} True if the prop is declared, false if not.151 * @param {string[]} names List of names of the prop to check. 152 * @returns {boolean} True if the prop is declared, false if not. 153 153 */ 154 154 function isDeclaredInComponent(node, names) { … … 191 191 * @param {Object} component The current component to process 192 192 * @param {Array} list The all components to process 193 * @returns { Boolean} True if the component is nested False if not.193 * @returns {boolean} True if the component is nested False if not. 194 194 */ 195 195 function checkNestedComponent(component, list) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/require-optimization.js
rd565449 r0c6b92a 51 51 * Checks to see if our component is decorated by PureRenderMixin via reactMixin 52 52 * @param {ASTNode} node The AST node being checked. 53 * @returns { Boolean} True if node is decorated with a PureRenderMixin, false if not.53 * @returns {boolean} True if node is decorated with a PureRenderMixin, false if not. 54 54 */ 55 55 function hasPureRenderDecorator(node) { … … 78 78 * Checks to see if our component is custom decorated 79 79 * @param {ASTNode} node The AST node being checked. 80 * @returns { Boolean} True if node is decorated name with a custom decorated, false if not.80 * @returns {boolean} True if node is decorated name with a custom decorated, false if not. 81 81 */ 82 82 function hasCustomDecorator(node) { … … 86 86 for (let i = 0; i < allowLength; i++) { 87 87 for (let j = 0, l = node.decorators.length; j < l; j++) { 88 const expression = node.decorators[j].expression; 88 89 if ( 89 node.decorators[j].expression90 && node.decorators[j].expression.name === allowDecorators[i]90 expression 91 && expression.name === allowDecorators[i] 91 92 ) { 92 93 return true; … … 102 103 * Checks if we are declaring a shouldComponentUpdate method 103 104 * @param {ASTNode} node The AST node being checked. 104 * @returns { Boolean} True if we are declaring a shouldComponentUpdate method, false if not.105 * @returns {boolean} True if we are declaring a shouldComponentUpdate method, false if not. 105 106 */ 106 107 function isSCUDeclared(node) { 107 return Boolean( 108 node 109 && node.name === 'shouldComponentUpdate' 110 ); 108 return !!node && node.name === 'shouldComponentUpdate'; 111 109 } 112 110 … … 114 112 * Checks if we are declaring a PureRenderMixin mixin 115 113 * @param {ASTNode} node The AST node being checked. 116 * @returns { Boolean} True if we are declaring a PureRenderMixin method, false if not.114 * @returns {boolean} True if we are declaring a PureRenderMixin method, false if not. 117 115 */ 118 116 function isPureRenderDeclared(node) { … … 127 125 } 128 126 129 return Boolean(130 node127 return ( 128 !!node 131 129 && node.key.name === 'mixins' 132 130 && hasPR -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/self-closing-comp.js
rd565449 r0c6b92a 10 10 const report = require('../util/report'); 11 11 12 const optionDefaults = { component: true, html: true }; 13 14 function isComponent(node) { 15 return ( 16 node.name 17 && (node.name.type === 'JSXIdentifier' || node.name.type === 'JSXMemberExpression') 18 && !jsxUtil.isDOMComponent(node) 19 ); 20 } 21 22 function childrenIsEmpty(node) { 23 return node.parent.children.length === 0; 24 } 25 26 function childrenIsMultilineSpaces(node) { 27 const childrens = node.parent.children; 28 29 return ( 30 childrens.length === 1 31 && (childrens[0].type === 'Literal' || childrens[0].type === 'JSXText') 32 && childrens[0].value.indexOf('\n') !== -1 33 && childrens[0].value.replace(/(?!\xA0)\s/g, '') === '' 34 ); 35 } 36 12 37 // ------------------------------------------------------------------------------ 13 38 // Rule Definition 14 39 // ------------------------------------------------------------------------------ 15 16 const optionDefaults = { component: true, html: true };17 40 18 41 const messages = { … … 50 73 51 74 create(context) { 52 function isComponent(node) {53 return (54 node.name55 && (node.name.type === 'JSXIdentifier' || node.name.type === 'JSXMemberExpression')56 && !jsxUtil.isDOMComponent(node)57 );58 }59 60 function childrenIsEmpty(node) {61 return node.parent.children.length === 0;62 }63 64 function childrenIsMultilineSpaces(node) {65 const childrens = node.parent.children;66 67 return (68 childrens.length === 169 && (childrens[0].type === 'Literal' || childrens[0].type === 'JSXText')70 && childrens[0].value.indexOf('\n') !== -171 && childrens[0].value.replace(/(?!\xA0)\s/g, '') === ''72 );73 }74 75 75 function isShouldBeSelfClosed(node) { 76 76 const configuration = Object.assign({}, optionDefaults, context.options[0]); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/sort-comp.js
rd565449 r0c6b92a 235 235 * Get properties name 236 236 * @param {Object} node - Property. 237 * @returns { String} Property name.237 * @returns {string} Property name. 238 238 */ 239 239 function getPropertyName(node) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/sort-default-props.js
rd565449 r0c6b92a 23 23 }; 24 24 25 /** @type {import('eslint').Rule.RuleModule} */ 25 26 module.exports = { 26 27 meta: { … … 53 54 * Get properties name 54 55 * @param {Object} node - Property. 55 * @returns { String} Property name.56 * @returns {string} Property name. 56 57 */ 57 58 function getPropertyName(node) { … … 74 75 * Checks if the Identifier node passed in looks like a defaultProps declaration. 75 76 * @param {ASTNode} node The node to check. Must be an Identifier node. 76 * @returns { Boolean} `true` if the node is a defaultProps declaration, `false` if not77 * @returns {boolean} `true` if the node is a defaultProps declaration, `false` if not 77 78 */ 78 79 function isDefaultPropsDeclaration(node) { … … 173 174 } 174 175 175 checkNode( node.parent.right);176 checkNode('right' in node.parent && node.parent.right); 176 177 }, 177 178 }; -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/sort-prop-types.js
rd565449 r0c6b92a 5 5 'use strict'; 6 6 7 const astUtil = require('../util/ast'); 7 8 const variableUtil = require('../util/variable'); 8 9 const propsUtil = require('../util/props'); … … 34 35 } 35 36 return getText(context, node.key || node.argument); 36 }37 38 function getValueName(node) {39 return node.type === 'Property' && node.value.property && node.value.property.name;40 }41 42 function isCallbackPropName(propName) {43 return /^on[A-Z]/.test(propName);44 }45 46 function isRequiredProp(node) {47 return getValueName(node) === 'isRequired';48 }49 50 function isShapeProp(node) {51 return Boolean(52 node && node.callee && node.callee.property && node.callee.property.name === 'shape'53 );54 }55 56 function toLowerCase(item) {57 return String(item).toLowerCase();58 37 } 59 38 … … 146 125 let prevPropName = getKey(context, prev); 147 126 let currentPropName = getKey(context, curr); 148 const previousIsRequired = isRequiredProp(prev);149 const currentIsRequired = isRequiredProp(curr);150 const previousIsCallback = isCallbackPropName(prevPropName);151 const currentIsCallback = isCallbackPropName(currentPropName);127 const previousIsRequired = propTypesSortUtil.isRequiredProp(prev); 128 const currentIsRequired = propTypesSortUtil.isRequiredProp(curr); 129 const previousIsCallback = propTypesSortUtil.isCallbackPropName(prevPropName); 130 const currentIsCallback = propTypesSortUtil.isCallbackPropName(currentPropName); 152 131 153 132 if (ignoreCase) { 154 prevPropName = toLowerCase(prevPropName);155 currentPropName = toLowerCase(currentPropName);133 prevPropName = String(prevPropName).toLowerCase(); 134 currentPropName = String(currentPropName).toLowerCase(); 156 135 } 157 136 … … 208 187 209 188 function checkNode(node) { 210 switch (node && node.type) { 211 case 'ObjectExpression': 212 checkSorted(node.properties); 213 break; 214 case 'Identifier': { 215 const propTypesObject = variableUtil.findVariableByName(context, node, node.name); 216 if (propTypesObject && propTypesObject.properties) { 217 checkSorted(propTypesObject.properties); 218 } 219 break; 220 } 221 case 'CallExpression': { 222 const innerNode = node.arguments && node.arguments[0]; 223 if (propWrapperUtil.isPropWrapperFunction(context, node.callee.name) && innerNode) { 224 checkNode(innerNode); 225 } 226 break; 227 } 228 default: 229 break; 189 if (!node) { 190 return; 191 } 192 193 if (node.type === 'ObjectExpression') { 194 checkSorted(node.properties); 195 } else if (node.type === 'Identifier') { 196 const propTypesObject = variableUtil.findVariableByName(context, node, node.name); 197 if (propTypesObject && propTypesObject.properties) { 198 checkSorted(propTypesObject.properties); 199 } 200 } else if (astUtil.isCallExpression(node)) { 201 const innerNode = node.arguments && node.arguments[0]; 202 if (propWrapperUtil.isPropWrapperFunction(context, node.callee.name) && innerNode) { 203 checkNode(innerNode); 204 } 230 205 } 231 206 } … … 261 236 return Object.assign({ 262 237 CallExpression(node) { 263 if (!sortShapeProp || ! isShapeProp(node) || !(node.arguments && node.arguments[0])) {238 if (!sortShapeProp || !propTypesSortUtil.isShapeProp(node) || !(node.arguments && node.arguments[0])) { 264 239 return; 265 240 } -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/static-property-placement.js
rd565449 r0c6b92a 100 100 * Checks if we are declaring context in class 101 101 * @param {ASTNode} node 102 * @returns { Boolean} True if we are declaring context in class, false if not.102 * @returns {boolean} True if we are declaring context in class, false if not. 103 103 */ 104 104 function isContextInClass(node) { -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/style-prop-object.js
rd565449 r0c6b92a 19 19 }; 20 20 21 /** @type {import('eslint').Rule.RuleModule} */ 21 22 module.exports = { 22 23 meta: { … … 81 82 && node.arguments.length > 1 82 83 ) { 83 if ( node.arguments[0].name) {84 if ('name' in node.arguments[0] && node.arguments[0].name) { 84 85 // store name of component 85 86 const componentName = node.arguments[0].name; … … 92 93 } 93 94 if (node.arguments[1].type === 'ObjectExpression') { 94 const style = node.arguments[1].properties.find((property) => property.key && property.key.name === 'style' && !property.computed); 95 if (style) { 95 const style = node.arguments[1].properties.find((property) => ( 96 'key' in property 97 && property.key 98 && 'name' in property.key 99 && property.key.name === 'style' 100 && !property.computed 101 )); 102 103 if (style && 'value' in style) { 96 104 if (style.value.type === 'Identifier') { 97 105 checkIdentifiers(style.value); -
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/void-dom-elements-no-children.js
rd565449 r0c6b92a 48 48 const noChildrenInVoidEl = 'Void DOM element <{{element}} /> cannot receive children.'; 49 49 50 /** @type {import('eslint').Rule.RuleModule} */ 50 51 module.exports = { 51 52 meta: { … … 120 121 } 121 122 122 const elementName = args[0].value;123 const elementName = 'value' in args[0] ? args[0].value : undefined; 123 124 124 125 if (!isVoidDOMElement(elementName)) { … … 145 146 146 147 const hasChildrenPropOrDanger = props.some((prop) => { 147 if (! prop.key) {148 if (!('key' in prop) || !prop.key || !('name' in prop.key)) { 148 149 return false; 149 150 }
Note:
See TracChangeset
for help on using the changeset viewer.