You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Welcome to [TheAlgorithms/Javascript](https://github.com/TheAlgorithms/Javascript)! Before sending your pull requests,
make sure that you **read the whole guidelines**. If you have anydoubt on the contributing guide, please feel free to
[stateit clearly in an issue](https://github.com/TheAlgorithms/Javascript/issues/new).
Welcome to [TheAlgorithms/JavaScript](https://github.com/TheAlgorithms/JavaScript)! Before sending your pull requests,
make sure that you **read the whole guidelines**. If you have anydoubts about the contributing guide, please feel free to
[statethem clearly in an issue](https://github.com/TheAlgorithms/JavaScript/issues/new) or by joining our [Discord community](https://the-algorithms.com/discord).
## Contributing
Expand All
@@ -15,11 +15,11 @@ referenced and used by learners from around the globe. Being one of our contribu
- You did your work - plagiarism is not allowed.
- Any plagiarized work will not be merged.
- Your work will be distributed under [GNULicense](LICENSE) once your pull request is merged.
- Your work will be distributed underthe[GNUGPLv3.0](https://github.com/TheAlgorithms/JavaScript/blob/master/LICENSE) once your pull request is merged.
- Your submitted work must fulfill our styles and standards.
**Newimplementation**is welcome! For example, new solutions to a problem, different representations of a graph data
structure or algorithm designs with different complexity.
**Newimplementations**are welcome! For example, new solutions to a problem, different representations of a graph data
structure, or algorithm designs with different complexity.
**Improving comments** and **writing proper tests** are also highly welcome.
Expand DownExpand Up
@@ -52,18 +52,38 @@ Algorithms should:
Algorithms in this repo should not be how-to examples for existing JavaScript packages. Instead, they should perform
internal calculations or manipulations to convert input values into different output values. Those calculations or
manipulations can use data types, classes, or functions of existing JavaScript packages but each algorithm in this repo
should add unique value.
should add a unique value.
#### Commit guidelines
- Follow [**Conventional Commits**](https://www.conventionalcommits.org/en/v1.0.0/) guidelines at all times.
- Use one of the following prefixes (there might be other miscellaneous prefixes, though).
- fix: A bug fix in an algorithm, workflow, configuration/settings, etc..
- feat: A new feature, such as new algorithms, new workflows, etc..
- docs: Documentation changes or fixes, like improving the contributing guidelines, fixing a typo, etc..
- test: Correct existing tests or add new ones.
- chore: Miscellaneous changes that do not match any of the above.
Examples of best commit messages.
```txt
fix: fixed error in XYZ algorithm
feat: re-work the CI workflow
docs: improve the contributing guidelines
test: add self-tests for XYZ algorithm
chore: update readme badges
```
#### File Naming Convention
-filenames should use the UpperCamelCase (PascalCase) style.
-Filenames should use the UpperCamelCase (PascalCase) style.
- There should be no spaces in filenames.
- **Example:** `UserProfile.js` is allowed but `userprofile.js`,`Userprofile.js`,`user-Profile.js`,`userProfile.js` are
not.
#### Module System
We use the [ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) system, whichbring an
We use the [ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) system, whichbrings an
official, standardized module system to JavaScript.
It roughly means you will need to use `export` and `import` statements instead of `module.exports` and `require()`.
Expand All
@@ -83,34 +103,34 @@ and inspect the outcome. Example: [RatInAMaze.test.js](Backtracking/tests/RatInA
Please refrain from using `console` in your implementation AND test code.
First you should install all dependencies using:
First, you should install all dependencies using:
```shell
```bash
npm install
```
You can (and should!) run all tests locally before committing your changes:
```shell
```bash
npm test
```
If you want save some time and just run a specific test:
If you wanttosave some time and just run a specific test:
```shell
```bash
# This will run any test file where the filename contains "koch" (no need to specify folder path)
npm test -- koch
```
You can also start Jest in "watch" mode:
```shell
```bash
npm test -- --watchAll
```
We also prepared a helper script that runs tests only for changed files:
```shell
```bash
npm run test-changed
```
Expand All
@@ -121,9 +141,9 @@ This will run all tests and watch source and test files for changes. When a chan
To maximize the readability and correctness of our code, we require that new submissions follow the
[JavaScript Standard Style](https://standardjs.com/).
Before committing, please run
Before committing, please run:
```shell
```bash
npm run style
```
Expand All
@@ -134,7 +154,7 @@ A few (but not all) of the things to keep in mind:
- Use camelCase with the leading character as lowercase for identifier names (variables and functions).
- Follow code indentation: Always use 2 spaces for code-block indentation.
```js
function sumOfArray(arrayOfNumbers) {
Expand All
@@ -158,4 +178,4 @@ function sumOfArray(arrayOfNumbers) {
- **Be consistent in the use of these guidelines when submitting.**
- Happy coding!
Writer [@itsvinayak](https://github.com/itsvinayak), May 2020.
Writer [@itsvinayak](https://github.com/itsvinayak) and contributors, May 2020.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.