(dir)
| 399 | }; |
| 400 | |
| 401 | const lintCheckDocs = async (dir) => { |
| 402 | const { |
| 403 | default: {ESLint}, |
| 404 | } = await import('eslint'); |
| 405 | const esLint = new ESLint({ |
| 406 | overrideConfig: { |
| 407 | rules: { |
| 408 | 'import/no-unresolved': 0, |
| 409 | 'no-console': 0, |
| 410 | 'react/prop-types': 0, |
| 411 | 'react-hooks/rules-of-hooks': 0, |
| 412 | '@typescript-eslint/no-unused-expressions': 0, |
| 413 | 'max-len': [ |
| 414 | 2, |
| 415 | {code: 80, ignorePattern: '^(\\s+\\* )?((im|ex)ports?|// ->)\\W.*'}, |
| 416 | ], |
| 417 | }, |
| 418 | }, |
| 419 | }); |
| 420 | const {default: prettier} = await import('prettier'); |
| 421 | const prettierConfig = await getPrettierConfig(); |
| 422 | const docConfig = {...prettierConfig, printWidth: 75}; |
| 423 | |
| 424 | const filePaths = []; |
| 425 | ['.js', '.d.ts'].forEach((extension) => |
| 426 | forEachDeepFile(dir, (filePath) => filePaths.push(filePath), extension), |
| 427 | ); |
| 428 | await allOf(filePaths, async (filePath) => { |
| 429 | const code = await promises.readFile(filePath, UTF8); |
| 430 | await allOf( |
| 431 | [...(code.matchAll(LINT_BLOCKS) ?? [])], |
| 432 | async ([_, hint, docBlock]) => { |
| 433 | if (hint?.trim() == 'override') { |
| 434 | return; // can't lint orphaned TS methods |
| 435 | } |
| 436 | const code = docBlock.replace(/\n +\* ?/g, '\n').trimStart(); |
| 437 | let pretty = code; |
| 438 | if (!(await prettier.check(code, docConfig))) { |
| 439 | pretty = await prettier.format(code, docConfig); |
| 440 | writeFileSync( |
| 441 | filePath, |
| 442 | readFileSync(filePath, UTF8).replace( |
| 443 | docBlock, |
| 444 | '\n' + |
| 445 | pretty |
| 446 | .trim() |
| 447 | .split('\n') |
| 448 | .map((line) => (line == '' ? ' *' : ' * ' + line)) |
| 449 | .join('\n') + |
| 450 | '\n * ', |
| 451 | ), |
| 452 | UTF8, |
| 453 | ); |
| 454 | } |
| 455 | const results = await esLint.lintText(pretty); |
| 456 | if ( |
| 457 | results.filter( |
| 458 | (result) => result.errorCount > 0 || result.warningCount > 0, |
no test coverage detected
searching dependent graphs…