Skip to content

Conversation

@balemoc
Copy link

@balemoc balemoc commented Sep 5, 2025

@stonelasley Hey long time no see, I just saw this wonderful project. I figured out that it needs some love.

This pull request modernizes the project's linting and testing infrastructure, replacing deprecated tools and updating configurations for improved maintainability and compatibility. It also introduces additional unit tests for barcode readers and refactors test code for clarity and consistency.

Tooling and Configuration Updates:

  • Switched from TSLint to ESLint for linting, adding a new eslint.config.mjs with recommended configurations for both JavaScript and TypeScript, and updated the corresponding npm scripts in package.json to use ESLint. [1] [2]
  • Replaced Jest with Vitest as the test runner, updating test scripts and related dependencies in package.json.
  • Updated TypeScript and Prettier versions, and added new dev dependencies for ESLint, TypeScript, and Vitest.

Test Suite Improvements:

  • Added comprehensive tests for the decodeOrThrow method in Code39Reader, BaseGtinReader, and Code128Reader, ensuring correct handling of symbology, raw values, and embedded data. [1] [2] [3]
  • Refactored test code to use modern TypeScript syntax, removed unnecessary TSLint directives, and made type annotations more concise and consistent across test files. [1] [2] [3] [4] [5] [6] [7] [8]

Code Clean-up and Minor Fixes:

  • Removed unused or redundant test helper methods and improved the clarity of test assertions. [1] [2] [3] [4] [5] [6] [7]

New features

Introduced ParsedBarcode to deprecate BarcodeValue

Modern, strongly-typed class for parsed barcode results.
Uses a strictly-typed [values] array (BarcodeValueEntry[]), where each entry has a (string or AICode) and a [value](string | number | Date | undefined).
Provides the method getApplicationIdentifier to retrieve a value by its application identifier code in a type-safe way.
Omits legacy fields and methods like [pluck] [errorMessage], and [success]) for a cleaner, more focused API.
Ensures immutability for its main properties via readonly.

Legacy implementation, now marked as deprecated (BarcodeValue)

Fixes #42 #43

@stonelasley
Copy link
Owner

@balemoc you are a machine. thank you, sir!

@balemoc balemoc marked this pull request as ready for review September 8, 2025 16:28
Copy link

@freshbyteadmin freshbyteadmin left a comment

Choose a reason for hiding this comment

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

Thanks @balemoc

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.

Improve typing and organization

3 participants