Skip to content

Conversation

@BelfordZ
Copy link
Contributor

@BelfordZ BelfordZ commented May 22, 2025

User description

Summary

  • test the prettier-ignore-log-lines.js helper
  • document how to run the script

Testing

  • npm test
  • npx jest test/unit/scripts/prettier-ignore-log-lines.test.ts

PR Type

Tests, Documentation


Description

  • Add unit tests for prettier-ignore-log-lines.js script

  • Document usage of the script in README.md

  • Ensure script correctly adds ignore comments to long log lines

  • Clarify script behavior and invocation instructions


Changes walkthrough 📝

Relevant files
Tests
prettier-ignore-log-lines.test.ts
Add comprehensive tests for prettier-ignore-log-lines script

test/unit/scripts/prettier-ignore-log-lines.test.ts

  • Introduce unit tests for the prettier-ignore-log-lines.js script
  • Test insertion of ignore comments for long instrumentation log lines
  • Verify short and unrelated lines remain unchanged
  • Use temporary files to simulate script execution
  • +50/-0   
    Documentation
    README.md
    Document usage of prettier-ignore-log-lines script             

    README.md

  • Add documentation for prettier-ignore-log-lines.js script usage
  • Explain purpose and invocation of the script
  • Clarify which files and lines are affected
  • +14/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 95
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Test Resource Cleanup

    Ensure that temporary directories and files created during tests are always cleaned up, even if an error occurs during script execution. Consider using try/finally blocks to guarantee cleanup.

    function runScriptWithFile(content: string): string {
      const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'prettier-test-'))
      const srcDir = path.join(tmpDir, 'src')
      fs.mkdirSync(srcDir)
      const filePath = path.join(srcDir, 'file.ts')
      fs.writeFileSync(filePath, content + '\n')
      const result = spawnSync('node', [scriptPath], { cwd: tmpDir })
      if (result.status !== 0) {
        throw new Error(result.stderr.toString())
      }
      const output = fs.readFileSync(filePath, 'utf8')
      fs.rmSync(tmpDir, { recursive: true, force: true })
      return output.trimEnd()
    }

    @github-actions
    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants