Contributing to Numeral.js

Contributions are welcome! Please follow these guidelines to help us review your pull requests smoothly.

Important: Please create your branch from and submit pull requests to the develop branch. All pull requests must include the appropriate tests.

Development Setup

  1. Fork the repository on GitHub.

  2. Clone your fork locally:

    git clone https://github.com/your-username/Numeral-js.git
    cd Numeral-js

  3. Install development dependencies using npm. This will also install Grunt, the task runner used for this project.

    npm install

  4. Create a new branch for your feature or bug fix. Branch off of the develop branch.

    git checkout -b your-feature-name develop

Making Changes

  • Code: Make your changes to the relevant files in the src/ directory.
  • Tests: Add or update tests for your changes. Tests are crucial for maintaining the library's quality.
    • Core library tests are in tests/numeral.js.
    • Format-specific tests are in tests/formats/.
    • Locale-specific tests are in tests/locales/.

Running Tests

To run the test suite, use the default Grunt task:

grunt

This command will lint the code, build the library, and run tests using Mocha (for Node) and Karma (for browsers).

Building the Project

When your changes are complete and all tests are passing, run grunt dist to compile and minify all source files into the root directory and the min/ directory.

grunt dist

Submitting a Pull Request

  1. Commit your changes with a clear and descriptive message.
  2. Push your branch to your fork on GitHub:

    git push origin your-feature-name

  3. Open a pull request from your branch to the develop branch of the main adamwdraper/Numeral-js repository.

  4. Provide a clear description of the changes in your pull request.

Guidelines for Locales

  • When naming locale files, use the ISO 639-1 language codes supplemented by ISO 3166-1 country codes when necessary (e.g., fr-ca.js).
  • Locale translations will not be merged without corresponding unit tests. Please see tests/locales/en-gb.js for an example.