mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
merge: consistent list syntax in CONTRIBUTING.md
(#921)
* feat: add style and run scripts on pre-commit hooks * Update package-lock.json * Update CONTRIBUTING.md * Add period at the end of lines
This commit is contained in:
@ -13,10 +13,10 @@ make sure that you **read the whole guidelines**. If you have any doubt on the c
|
||||
We are very happy that you consider implementing algorithms and data structures for others! This repository is
|
||||
referenced and used by learners from around the globe. Being one of our contributors, you agree and confirm that:
|
||||
|
||||
* You did your work - plagiarism is not allowed.
|
||||
* Any plagiarized work will not be merged.
|
||||
* Your work will be distributed under [GNU License](LICENSE) once your pull request is merged.
|
||||
* Your submitted work must fulfill our styles and standards.
|
||||
- You did your work - plagiarism is not allowed.
|
||||
- Any plagiarized work will not be merged.
|
||||
- Your work will be distributed under [GNU License](LICENSE) once your pull request is merged.
|
||||
- Your submitted work must fulfill our styles and standards.
|
||||
|
||||
**New implementation** is welcome! For example, new solutions to a problem, different representations of a graph data
|
||||
structure or algorithm designs with different complexity.
|
||||
@ -35,19 +35,19 @@ If you submit a pull request that resolves an open issue, please help us to keep
|
||||
|
||||
An Algorithm is one or more functions (or classes) that:
|
||||
|
||||
* take one or more inputs,
|
||||
* perform some internal calculations or data manipulations,
|
||||
* return one or more outputs,
|
||||
* have minimal side effects.
|
||||
- take one or more inputs.
|
||||
- perform some internal calculations or data manipulations.
|
||||
- return one or more outputs.
|
||||
- have minimal side effects.
|
||||
|
||||
Algorithms should be packaged in a way that would make it easy for readers to put them into larger programs.
|
||||
|
||||
Algorithms should:
|
||||
|
||||
* have intuitive class and function names that make their purpose clear to readers
|
||||
* use JavaScript naming conventions and intuitive variable names to ease comprehension
|
||||
* be flexible to take different input values
|
||||
* raise JavaScript exceptions (RangeError, etc.) on erroneous input values
|
||||
- have intuitive class and function names that make their purpose clear to readers.
|
||||
- use JavaScript naming conventions and intuitive variable names to ease comprehension.
|
||||
- be flexible to take different input values.
|
||||
- raise JavaScript exceptions (RangeError, etc.) on erroneous input values.
|
||||
|
||||
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
|
||||
@ -56,9 +56,9 @@ should add unique value.
|
||||
|
||||
#### File Naming Convention
|
||||
|
||||
* 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
|
||||
- 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
|
||||
@ -114,32 +114,35 @@ Before committing, please run
|
||||
npm run style
|
||||
```
|
||||
|
||||
in order to apply the coding style (where it can be done automatically). If an error is shown, please figure out what's
|
||||
In order to apply the coding style (where it can be done automatically). If an error is shown, please figure out what's
|
||||
wrong, fix it and run standard again.
|
||||
|
||||
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)
|
||||
* Names start with a letter
|
||||
* Follow code indentation: Always use 2 spaces for indentation of code blocks
|
||||
- Use camelCase with the leading character as lowercase for identifier names (variables and functions).
|
||||
- Names start with a letter.
|
||||
- Follow code indentation: Always use 2 spaces for indentation of code blocks.
|
||||
|
||||
```js
|
||||
function sumOfArray (arrayOfNumbers) {
|
||||
function sumOfArray(arrayOfNumbers) {
|
||||
let sum = 0
|
||||
|
||||
for (let i = 0; i < arrayOfNumbers.length; i++) {
|
||||
sum += arrayOfNumbers[i]
|
||||
}
|
||||
return (sum)
|
||||
|
||||
return sum
|
||||
}
|
||||
```
|
||||
*
|
||||
* Avoid using global variables and avoid `==`
|
||||
* Please use `let` over `var`
|
||||
* Please refrain from using `console.log` or any other console methods
|
||||
* **Absolutely** don't use `alert`
|
||||
* We strongly recommend the use of ECMAScript 6
|
||||
* Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms
|
||||
* Most importantly:
|
||||
* **Be consistent in the use of these guidelines when submitting**
|
||||
* Happy coding!
|
||||
|
||||
- Avoid using global variables and avoid `==`.
|
||||
- Please use `let` over `var`.
|
||||
- Please refrain from using `console.log` or any other console methods.
|
||||
- **Absolutely** don't use `alert`.
|
||||
- We strongly recommend the use of ECMAScript 6.
|
||||
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
|
||||
- Most importantly:
|
||||
- **Be consistent in the use of these guidelines when submitting.**
|
||||
- Happy coding!
|
||||
|
||||
Writer [@itsvinayak](https://github.com/itsvinayak), May 2020.
|
||||
|
Reference in New Issue
Block a user