Changing the Code
Learn how to contribute a code change to CanJS. Read the Making a New Package guide on how to make a plugin to CanJS.
Now that your computer is set up to develop CanJS locally, you can make changes in your local repository.
The CanJS projects generally follow the GitHub flow. This section will briefly explain how you can make changes on your computer and submit a pull request to have those changes merged into the main project.
Creating a new branch
Starting in the CanJS repository you have cloned to your computer, you can create a new branch:
git checkout -b your-branch-name
Replace your-branch-name
with the name of your feature branch, e.g. git checkout -b html5-fix
to create a html5-fix
branch.
Style guide
Where possible, our code generally follows jQuery’s coding conventions.
Where possible, CanJS code uses:
- Tabs not spaces
- JSHint
- CommonJS not ES6
- jQuery’s coding conventions
Updating tests
The test
directory contains files related to testing the code in the repository. When fixing bugs or writing new features, you should update the existing tests or create new tests to cover your changes.
After updating the tests, run npm test
to make sure the tests pass.
Updating the documentation
The docs
and guides
directories contain the files used to generate CanJS.com.
Submitting a pull request
Once you’ve made your changes and run the tests, you can push your branch to GitHub:
git push origin your-branch-name
Make sure you replace your-branch-name
with the name of your branch. For example, git push origin html5-fix
.
Next, submit a pull request! On GitHub, navigate to Pull Requests and click the “New Pull Request” button. Give your PR a meaningful title and provide details about the change in the description, including a link to the issue(s) your PR addresses. If applicable, please include a screenshot or gif to demonstrate your change. This makes it easier for reviewers to verify that it works for them. LICEcap is a great tool for making gifs.
When finished, press “Send pull request”. The core team will be notified of your submission and will let you know of any problems or a targeted release date.
GitHub has additional documentation on creating a pull request from a fork that you might find useful.
If you enjoy making these kinds of fixes and want to directly influence CanJS’s direction, consider joining our Core team.