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
-
Fork the repository on GitHub.
-
Clone your fork locally:
git clone https://github.com/your-username/Numeral-js.git cd Numeral-js -
Install development dependencies using npm. This will also install Grunt, the task runner used for this project.
npm install -
Create a new branch for your feature or bug fix. Branch off of the
developbranch.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/.
- Core library tests are in
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
- Commit your changes with a clear and descriptive message.
-
Push your branch to your fork on GitHub:
git push origin your-feature-name -
Open a pull request from your branch to the
developbranch of the mainadamwdraper/Numeral-jsrepository. - 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.jsfor an example.