Thank you for contributing to codistica-js!
Before starting, be sure you have installed:
In order to guarantee harmony to the repository, any code modification should follow the rules stated in this file.
Use ES6 standard.
import {importedSomething} from 'file'; // YEAH
const importedSomething = require('file'); // NOPE
let a = 5; // YEAH
var a = 5; // YIKES
export {exportedSomething} // :-)
module.export = exportedSomething // :-(For the react package, Flow typing standard will also help us.
Add as many comments as needed so others understand whats going on. Comments should be in capital letters and close to where it is referring. Example:
// PRINTING NUMBERS 1 UP TO 3.
[1, 2, 3].forEach((n) => {
console.log(n)
});If you think any new or existing code can be reused, it would be better to add it as a new module, class or constant!
Any new function or class should be documented with JSdocs. It facilitates typechecking without intruding the code, easing any further access to the code. Any documentation should have description, param (type and description) and returns. Use other piece codes to guide yourself.
e.g.
/**
* @description Adds one to the input.
* @param {number} input - input number.
* @returns {number} input plus one.
*/
function addOne(input) {
return input + 1;
}Every modification to the code should have a corresponding testing adaptation.
Running internal tests it is important to catch any unexpected behavior:
yarn test:quickor
yarn build
yarn test(NOTE: The repository has to be built for tests to work, thats why yarn test by itself won't work.)
Tests are located under the __Tests__ file of each package, having the same
file structure as the src directory.
Every module should have a test that runs every single line of the code, so be sure any addition/modification/removal of code should have its respective test change.
To add a test, create a new .js file on the correct directory
<FILENAME OF MODULE>.test. Write the test and export it to its parent
index.test.js file. (You can see previous tests to guide yourself).
Testing uses Chai's Assertion library to run tests. Thus a testing module may look like this:
import {assert} from 'chai';
import {mainFunction} from 'mainFunction file path';
function mainFunctionTest() {
describe('mainFunction()', () => {
it('Should return true.', () => {
assert.isTrue(mainFunction('testParam'));
});
});
}
export {mainFunctionTest};In order to have an organized workflow, be sure to split any modification to different packages onto separate commits. Commits should have the following description:
[<TAG>][<PACKAGE-NAME>] - <DESCRIPTION>.Available tags:
- [DOCS] - For documentation related commits.
- [FIX] - Bug and other code fixes.
- [MERGE] - Merging previous features into a branch.
- [NEW] - Addition of something new.
- [POLISH] - Code rewritten.
- [REFACTOR] - File renaming.
- [TESTS] - Addition/modification of tests.
Available package names: See packages section on README.MD (NOTE: a pre-commit pre-hook will run to validate any commit message, be sure you do not have pre-hooks disabled)
Once the hard job is done, its the moment for a pull request. This is the way to implement your changes to the code base and be published in the next release!. But hold on! before putting the pull request, let the community know your contributions to codistica-js!
On the CHANGELOG.md files of the interested packages, add your contribution under the 'Unreleased' title (and under the section(s) that better matches your contribution). Sections can be:
- New Features
- Bug Fixes
- Documentation
- Polish
Your contribution may look like this:
Brief description ([#<Issue number>], [@<your github username>])(NOTE: if you prefer, you can keep your username anonymous, just write "Anonymous" instead of your github username)
Then, at the bottom of the CHANGELOG file, under the 'CONTRIBUTORS' section, link your username to your github profile link:
<!--CONTRIBUTORS-->
[@<your github username>]: <Your github profile link>
Finally, link the issue number to the actual issue that originated your pull request under the 'ISSUES' section:
<!--ISSUES-->
[#<Issue number>]: <issue link>
(NOTE: If your contribution has no issue related, you may avoid this part)
Finally, create a new pull request from your branch to develop.
Fill the template and submit the pull request for review from the codistica team!.