{"record":{"id":"dbff0a1b6670d9d4","repo":"dianping/cat","slug":"expected-none-flex-grow-flex-shrink","errorCode":null,"errorMessage":"Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '{}'.","messagePattern":"Expected \\(none \\| \\[ <flex-grow> <flex-shrink>\\? \\|\\| <flex-basis> \\]\\) but found '(.+?)'\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-css.js","lineNumber":5653,"sourceCode":"                            if (expression.peek()) {\n                                result = ValidationTypes.isType(expression, \"<flex-basis>\");\n                            } else {\n                                result = true;\n                            }\n                        } else if (ValidationTypes.isType(expression, \"<flex-basis>\")) {\n                            result = expression.peek() === null;\n                        }\n                    } else {\n                        result = true;\n                    }\n                } else if (ValidationTypes.isType(expression, \"<flex-basis>\")) {\n                    result = true;\n                }\n            }\n\n            if (!result) {\n                part = expression.peek();\n                throw new ValidationError(\"Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '\" + expression.value.text + \"'.\", part.line, part.col);\n            }\n\n            return result;\n        }\n    }\n};\n\nparserlib.css = {\nColors              :Colors,\nCombinator          :Combinator,\nParser              :Parser,\nPropertyName        :PropertyName,\nPropertyValue       :PropertyValue,\nPropertyValuePart   :PropertyValuePart,\nMediaFeature        :MediaFeature,\nMediaQuery          :MediaQuery,\nSelector            :Selector,\nSelectorPart        :SelectorPart,","sourceCodeStart":5635,"sourceCodeEnd":5671,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-css.js#L5635-L5671","documentation":"A custom validator for the flex shorthand in the bundled parserlib (worker-css.js:~5653) inside the ACE CSS worker. It hand-checks the CSS3 flex grammar 'none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]' because the generic matcher cannot express it; when the value doesn't fit, it throws ValidationError with this fixed message. Note the thrown position uses peek()'s coordinates while the message shows expression.value.text — minor inconsistency, but harmless.","triggerScenarios":"Invalid flex shorthand such as 'flex: 1 2 3 4' (too many numbers), 'flex: none 1', 'flex: auto red', or 'flex: 0 0' (two numbers but basis missing is fine — 'flex: 0 0' is actually two numbers... only invalid shapes throw). Any sequence that is neither the keyword 'none' nor number(s) optionally followed by a width keyword/length.","commonSituations":"Learning the 1-3 component flex syntax ('flex: 1' vs 'flex: 1 1 0%'), using units on grow/shrink ('flex: 1px 1'), or old grammars not accepting calc()/new keywords as <flex-basis>.","solutions":["Rewrite as 'flex: none' or 'flex: <grow> <shrink>? <basis>?' with unitless numbers and a valid width for basis (e.g. 'flex: 1 1 0%').","Remember grow/shrink must be plain <number>; only basis takes units/keywords.","If your value is valid per current spec but flagged, upgrade parserlib/the worker bundle (this custom validator is old).","Use longhands (flex-grow, flex-shrink, flex-basis) to sidestep the shorthand validator."],"exampleFix":"/* before */\n.item { flex: 1 2 3 4; }\n\n/* after */\n.item { flex: 1 2 0%; }","handlingStrategy":"validation","validationCode":"// Check the flex shorthand shape before emitting:\nfunction flexOk(v) {\n  if (v === 'none' || v === 'initial' || v === 'auto') return true;\n  return /^(?:\\d+)(?:\\s+\\d+)?(?:\\s+(?:0+\\.?\\d*%|auto|\\d+(?:px|em|rem|%)))?$/.test(v.trim());\n}\nflexOk('1 1 0%'); // true","typeGuard":null,"tryCatchPattern":"try {\n  validateProperty('flex', value);\n} catch (ex) {\n  if (ex instanceof ValidationError) { collect(ex); } else throw ex;\n}","preventionTips":["Keep flex to 1-3 components: unitless grow, optional unitless shrink, optional basis with units or 'auto'.","Never put units on grow/shrink.","Use longhands (flex-grow/flex-shrink/flex-basis) to avoid the custom validator entirely."],"tags":["css","ace-editor","parserlib","flexbox","validation","lint"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}