Skip to content

AddESLint workflow and fix linter errors - #6

Merged
JR-1991 merged 13 commits into
masterfrom
add-eslint-action
Sep 27, 2025
Merged

JR-1991 merged 13 commits into
masterfrom
add-eslint-action

Conversation

@JR-1991

@JR-1991 JR-1991 commented Sep 27, 2025

Copy link
Copy Markdown
Member

This pull request introduces several improvements focused on code quality, type safety, and maintainability across the codebase. The most significant changes include the addition of ESLint and Husky for automated linting and pre-commit checks, enhanced TypeScript type safety (especially for API responses and function arguments), and the adoption of the papaparse library for more robust TSV parsing. There are also minor bug fixes and improvements to development documentation.

Code Quality & Tooling Enhancements:

  • Added ESLint configuration (eslint.config.mts) and integrated Husky and lint-staged for pre-commit linting, with scripts and configuration updates in package.json and a new .husky/pre-commit hook. This ensures code style and error checking on every commit. [1] [2] [3]
  • Expanded the README.md with a new "Development" section detailing code quality tools, scripts, pre-commit hooks, and setup instructions for contributors.

Type Safety & API Response Improvements:

  • Refactored the PDB fetcher (src/fetcher/pdb.ts) to define explicit TypeScript interfaces for API responses and internal data structures, improving maintainability and type safety throughout the data fetching and mapping logic. [1] [2] [3] [4] [5] [6]
  • Updated function signatures and event types in src/llm.ts to use unknown instead of any for better type safety, and improved event handler typings. [1] [2] [3] [4] [5] [6] [7] [8]

Parsing and Data Handling:

  • Replaced custom TSV parsing logic in the Rhea fetcher (src/fetcher/rhea.ts) with the papaparse library for more robust and maintainable parsing, including improved error handling for malformed data. [1] [2]
  • Improved file type checks in src/input-types.ts by using more precise TypeScript types for file extension checks. [1] [2]

Minor Bug Fixes and Cleanups:

  • Updated upload methods in UserQuery and SystemQuery to remove unused parameters and improved typings for file stream handling in PDFUpload. [1] [2] [3] [4]
  • Improved error handling in fetchPubChem to properly log unknown errors.
  • Minor dependency and import cleanups in test and implementation files.

These changes collectively improve the reliability, maintainability, and developer experience of the project.

- Install husky and lint-staged as dev dependencies
- Configure pre-commit hook to run ESLint on staged files
- Add npm scripts for linting (lint, lint:check)
- Update README with comprehensive development documentation
- Set up automatic code quality enforcement before commits
Introduces TypeScript interfaces for PDB API data structures, including PdbEntryData, PdbPolymerEntityData, RawCitationData, RcsbPrimaryCitation, and RcsbEntryInfo. Updates the PDBClient to use these types for improved type safety and code clarity.
Updated the catch block to handle both Error instances and unknown error types, ensuring that error messages are logged appropriately regardless of the error type.
Replaces manual TSV parsing logic in RheaClient with papaparse for improved reliability and maintainability. Adds papaparse and its type definitions as dependencies in package.json.
Introduces eslint.config.mts with recommended settings for JavaScript and TypeScript, including browser globals and plugin support.
Updated type assertions for array includes checks to use more precise types. Removed unused 'client' parameter from 'upload' methods in UserQuery and SystemQuery. Improved type safety for stream name assignment in PDFUpload.
Deleted an unnecessary test comment at the end of the llm.ts file to clean up the code.
Changed 'responses' from let to const and added explicit typing for pdbResults. Also updated the export to cast the function type for better type safety.
Inserted blank lines before lists in the README to enhance formatting and readability.
The SmallMolecule import in pubchem.integration.test.ts was unused and has been removed to clean up the code.
Updated the UserQuery upload test to call upload() without passing the mockClient argument, reflecting changes in the method signature or usage.
Introduces a lint workflow that runs ESLint on the src directory for every push and pull request. The workflow sets up Node.js, installs dependencies, and checks out the code before running the linter.
@JR-1991 JR-1991 self-assigned this Sep 27, 2025
@JR-1991 JR-1991 added this to EnzymeML Sep 27, 2025
@JR-1991 JR-1991 added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Sep 27, 2025
@JR-1991
JR-1991 merged commit 40c4213 into master Sep 27, 2025
3 checks passed
@JR-1991
JR-1991 deleted the add-eslint-action branch September 27, 2025 10:16
@github-project-automation github-project-automation Bot moved this to Done in EnzymeML Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant