Skip to content

Major refactor, documentation overhaul, and community best practices#248

Merged
avoidwork merged 65 commits intomasterfrom
tweaks
Mar 25, 2026
Merged

Major refactor, documentation overhaul, and community best practices#248
avoidwork merged 65 commits intomasterfrom
tweaks

Conversation

@avoidwork
Copy link
Copy Markdown
Owner

@avoidwork avoidwork commented Mar 24, 2026

Summary

This PR introduces significant improvements to filesize.js, including comprehensive documentation updates, new community guidelines, and enhanced tooling configuration.

Key Changes

🚀 Performance & Correctness

  • Simplified partial() implementation: Replaced deep cloning with destructuring for cleaner, faster immutability
    • Primitive values are frozen at creation time via destructuring
    • Simpler code path, no JSON serialization overhead
    • Properly handles NaN, Infinity, and other edge cases
  • Fixed forced exponent behavior: exponent option now properly prevents auto-increment in:
    • calculateOptimizedValue() - bits auto-increment respects forced exponent
    • applyPrecisionHandling() - scientific notation normalization respects forced exponent
    • filesize() - rounding-based auto-increment respects forced exponent
  • Improved sourcemap handling: ensureNewline() plugin now uses generateBundle() instead of renderChunk() to preserve sourcemaps in minified builds
  • Fixed padding with negative numbers: Decimal separator detection now correctly skips the minus sign

📚 Documentation

  • New CONTRIBUTING.md: Comprehensive contribution guidelines with testing, code style, and PR process
  • Enhanced README.md:
    • "Why filesize.js?" section
    • TypeScript usage examples
    • Browser/CDN usage examples
    • Updated project stats (149 tests, correct line counts)
    • Links to CONTRIBUTING and CHANGELOG
  • Updated AGENTS.md: Current implementation details, partial() destructuring approach, autoExponent pattern
  • Fixed TECHNICAL_DOCUMENTATION.md: Security notes, regex patterns, examples

🔧 Tooling

  • New .oxlintrc.json: Configured with no-unused-vars and no-console rules
  • Removed ESLint: Switched entirely to oxlint (Rust-based, faster)
  • Updated rollup.config.js: Streamlined plugin configuration
    🧪 Testing
  • 149 tests (up from 139) with 100% coverage maintained
  • New tests for:
    • exponent: NaN behavior with precision
    • Forced exponent with bits auto-increment
    • applyPrecisionHandling() exponent parameter
    • German locale padding with grouping separators

📝 Type Definitions

  • Updated types/helpers.d.ts:
    • Added exponent: number parameter to applyPrecisionHandling()
    • Added symbol?: string parameter to handleZeroValue()
    • Added autoExponent?: boolean parameter to calculateOptimizedValue()

Breaking Changes

None. All changes are backward compatible.

Testing

npm test

149 tests passing, 100% coverage maintained

Checklist

  • All tests pass
  • 100% test coverage maintained
  • Code is formatted (npm run format:fix)
  • No linting errors (npm run lint)
  • Documentation updated
  • Build successful (npm run build)

@avoidwork avoidwork self-assigned this Mar 24, 2026
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Mar 24, 2026

🤖 Augment PR Summary

Summary: This PR modernizes project tooling and documentation while refining a few edge cases in the filesize() formatting pipeline.

Changes:

  • Replaces ESLint/Mocha/c8 workflows with oxlint/oxfmt and Node’s built-in node:test runner (adds watch + experimental coverage scripts).
  • Adds Oxide configuration files (.oxlintrc.json, .oxfmtrc.json) and updates Husky’s pre-commit hook to run npm test directly.
  • Updates filesize() and helper functions to better respect forced vs auto exponent behavior (bits auto-increment + precision scientific-notation normalization).
  • Adjusts number-padding/formatting behavior for negative values and locale-formatted strings, with expanded unit tests for locale + padding scenarios.
  • Refreshes benchmarks (formatting/structure) and rebuilds dist/* outputs accordingly.
  • Substantially rewrites README and adds new API/reference docs (docs/API.md) plus contributor guidance (AGENTS.md).
  • Bumps copyright year to 2026.

Technical Notes: Rollup config now includes an output plugin to ensure generated artifacts end with a trailing newline, and typings/docs/examples were updated to reflect current output formats.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 4 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@avoidwork
Copy link
Copy Markdown
Owner Author

augment review

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@avoidwork avoidwork changed the title Tweaks Major refactor, documentation overhaul, and community best practices Mar 25, 2026
@avoidwork avoidwork merged commit 1106cbb into master Mar 25, 2026
2 checks passed
@avoidwork avoidwork deleted the tweaks branch March 25, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant