Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

Bug reports

When reporting a bug please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Documentation improvements

If you find any issue in our online documentation please open an issue.

jsthermalcomfort could always use more documentation, whether as part of the official jsthermalcomfort docs, in JSDocs, or even on the web in blog posts, articles, and such.

Feature requests and feedback

The best way to send feedback is to file an issue at https://github.com/FedericoTartarini/jsthermalcomfort/issues

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that code contributions are welcome :)

Local development

To set up jsthermalcomfort for local development:

  1. Fork jsthermalcomfort (look for the “Fork” button).

  2. Clone your fork locally. Fetch and pull all the updates from the main branch before you do anything:

    git clone git@github.com:FedericoTartarini/jsthermalcomfort.git
  3. Create a branch for local development. The naming rule for new branch are, as follows:

    • If this update is for a new feature Feature/feature_name_here
    • If this update is for bug fix Fix/bug_name_here
    • If this update is for documentation Documentation/doc_name_here

    You can create a branch locally using the following command. Make sure you only push updates to this new branch only:

    git checkout -b name-of-your-bugfix-or-feature

    Now you can make your changes locally.

  4. When you’re done making changes run all tests using Jest:

    • Install dependencies
    npm install
    npm run test
    • Run prettier to format your code:
    npm run format
    • Commit your changes:
    git add .
    git commit -m "Your detailed description of your changes."
    • Update the docs:
    npm run docs
    • Commit your documentation changes:
    git add .
    git commit -m "Your detailed description of your changes."
    • Push your branch to GitHub:
    git push origin name-of-your-bugfix-or-feature
  5. Submit a pull request after you have done all your modifications and tested your work. The pull request should include a detailed description of your work:

    • What this pull request is about
    • Have you tested your work
    • Will this work affect other component in the product

Pull Request Guidelines

If you need some code review or feedback while you’re developing the code just make the pull request.

For merging, you should:

  • Include passing tests (run npm run test).
  • Update documentation when there’s new API, functionality etc.

Documentation

We are using JSDoc and documentation.js to automatically build the documentation.

All the files needed to generate the documentation can be found in the docs_theme repository. After updating the Markdown files, please run the command:

npm run docs

Please ignore the docs folder, this folder contains all the files generated by the above command.

How to Add a New Thermal Comfort Model

To add a new model to the library, follow these steps:

1. Create the Model File

Create a new JavaScript file in src/models/ (e.g., my_new_model.js).

2. Implement the Logic and Add JSDoc

Implement your model function and ensure it is documented correctly using JSDoc.

Requirements for JSDoc:

  • Use @public to indicate it is part of the public API.
  • Use @memberof models to ensure it is partitioned correctly in the documentation.
  • Provide clear @param and @returns descriptions.

Example:

/**
 * @public
 * @memberof models
 * @name my_new_model
 * @description Calculates a new thermal comfort index.
 *
 * @param {number} tdb Dry bulb air temperature [°C]
 * @param {number} rh Relative humidity [%]
 * @returns {number} The calculated index value.
 */
export function my_new_model(tdb, rh) {
  // your implementation here
}

3. Register the Model

Export your new function in src/models/index.js:

import { my_new_model } from "./my_new_model.js";

export default {
  // ... existing models
  my_new_model,
};

4. Update Documentation Display Name

To ensure your model has a human-readable title in the documentation, add it to the displayNameMap in docs_theme/index.js:

const displayNameMap = {
  // ... existing mappings
  my_new_model: "My New Premium Model (MNPM)",
};

How to Update Documentation

The documentation is generated from JSDoc comments using a custom theme in docs_theme/.

1. Modify the Theme

  • Templates: Edit .ejs files in docs_theme/ to change the HTML structure.
  • Styles: Edit docs_theme/assets/style.css for visual changes.
  • Logic: Edit docs_theme/index.js to change how comments are partitioned or how pages are generated.

2. Build and Verify Locally

Run the following command to build the documentation to the docs/ folder:

npm run docs

You can then open docs/index.html in your browser to verify the changes.


Developer Workflow

  • Install Dependencies: npm ci
  • Run Tests: npm test
  • Format Code: npm run format (Please run this before committing!)
  • Lint Check: npm run check:format

Please ensure all tests pass and your code is correctly formatted before submitting a Pull Request.

How to publish a new version of jsthermalcomfort

Releases are published from Git tags by GitHub Actions. Local builds are not required for publishing.

  1. Ensure your branch is merged to main and CI is green.
  2. Bump the package version with npm:
    • Patch release: npm version patch
    • Minor release: npm version minor
    • Major release: npm version major
    • Exact version: npm version 1.2.3
  3. Push the commit and tags:
    git push && git push --tags
  4. Pushing a v* tag (for example v1.0.3) triggers the publish workflow.

The publish workflow runs checks (npm run check:format, npm test, npm run build) and then runs npm publish in CI.