(dir = SCHEMA_DIR)
| 127 | } |
| 128 | |
| 129 | function lintSchemas(dir = SCHEMA_DIR) { |
| 130 | const violations = []; |
| 131 | for (const file of walkFiles(dir, ['.json'])) { |
| 132 | let doc; |
| 133 | try { |
| 134 | doc = JSON.parse(fs.readFileSync(file, 'utf8')); |
| 135 | } catch { |
| 136 | continue; |
| 137 | } |
| 138 | if (!doc || !Array.isArray(doc.examples)) continue; |
| 139 | for (let i = 0; i < doc.examples.length; i++) { |
| 140 | const example = doc.examples[i]; |
| 141 | // Schema example shape varies: some wrap payloads in `{ description, data }`, |
| 142 | // others place the payload directly in the array element. |
| 143 | const data = |
| 144 | example && typeof example === 'object' && 'data' in example ? example.data : example; |
| 145 | for (const found of walkPaginationObjects(data)) { |
| 146 | const violation = checkPagination(found.pagination); |
| 147 | if (violation) { |
| 148 | violations.push({ |
| 149 | file: path.relative(REPO_ROOT, file), |
| 150 | location: `examples[${i}].${found.pathSoFar.join('.')}`, |
| 151 | rule: violation.rule, |
| 152 | }); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | return violations; |
| 158 | } |
| 159 | |
| 160 | function lintStoryboards(dir = STORYBOARD_DIR) { |
| 161 | const violations = []; |
no test coverage detected