| 264 | } |
| 265 | |
| 266 | async function sourceUseReading() { |
| 267 | const source = await readFile(join(FIXTURE, UNUSED_IMPORT_PROBE.file), 'utf8'); |
| 268 | const outsideImportDeclarations = source.split('\n') |
| 269 | .filter((line) => !/^\s*import\b/.test(line)) |
| 270 | .join('\n'); |
| 271 | return { |
| 272 | sourceImportCount: (source.match(/^\s*import\s*\{[^}]*\binsert\b[^}]*\}\s*from\s*['"][^'"]+['"];?\s*$/gm) ?? []).length, |
| 273 | sourceUseCount: (outsideImportDeclarations.match(/\binsert\b/g) ?? []).length, |
| 274 | }; |
| 275 | } |
| 276 | |
| 277 | async function beforeTextReading() { |
| 278 | const encoded = await readFile(BEFORE_LEVELS, 'utf8'); |