-
-
Notifications
You must be signed in to change notification settings - Fork 445
Feat: add contribution guidelines #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
appgurueu
merged 42 commits into
TheAlgorithms:master
from
gefgu:feat/add-contribution-guidelines
Sep 28, 2022
Merged
Changes from 24 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6168042
Add contribution guidelines copy from js repo
gefgu 5b1bdcb
Add author
gefgu db4c59b
Update before contributing section
gefgu 952cbcc
Add link to MIT license
gefgu 9403750
Update some javascript references to typescript
gefgu 8e15c7d
Remove testing section
gefgu f5a901a
Add ts standard guide
gefgu c8b62c9
Remove style script in guidelines
gefgu 8d2f913
Update JS example to TS
gefgu f832d9d
Fix redundant naming in example
gefgu f807183
Add typescript guidelines
gefgu da9159a
chore: Add discord server
gefgu 5fc8b1b
Fix: change "implementation" to plural
gefgu 7cc1e42
Fix: add comma
gefgu bc32437
fix: change auto-close tag
gefgu 95798fe
fix: add correct spelling
gefgu 54cafba
fix: improper discouragement of filenames.
gefgu b4138ae
docs: add commit messages guidelines
gefgu c0bd950
docs: fix missing space
gefgu 7bc3cd5
docs: add missing verb
gefgu 1c66244
docs: add chore tag
gefgu a5facf2
docs: add docs tag usage example
gefgu 55dec46
Update CONTRIBUTING.md
gefgu 834eaf4
docs: add community help in documentation
gefgu 4af8fb0
docs: add consistency to contribution lists
gefgu 66df7be
docs: fix spelling mistake
gefgu 54c92b7
docs: fix typescript misspelling
gefgu 2dd2c11
docs: fix documentation misspelling
gefgu a6ce8e2
docs: fix word usage in example
gefgu aceaa02
docs: fix misspelling in module system section
gefgu 8be2860
docs: remove apply of style guidelines
gefgu fafb56b
docs: add correct camelcase type for vars
gefgu 91dfa52
docs: add more idiomatic example
gefgu d3856f7
docs: improve js guidelines
gefgu 17b048e
docs: fix guidelines regarding 'any'
gefgu 9dca6fb
docs: fix guidelines about null and undefined
gefgu aac7c62
docs: fix guidelines about external libraries
gefgu 9fd1cbf
docs: remove author and date of writing
gefgu 4e404ad
docs: fix guidelines about ecmascript
gefgu 9105eb1
docs: fix guidelines about redundant naming
gefgu b232253
docs: fix semantic commit messages guidelines
gefgu 8f4fac9
Update naming conventions
appgurueu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Contributing guidelines | ||
|
||
## Before contributing | ||
|
||
Welcome to [TheAlgorithms/TypeScript](https://github.com/TheAlgorithms/TypeScript)! Before sending your pull requests, | ||
make sure that you **read the whole guidelines**. If you have any doubt on the contributing guide, please feel free to | ||
[state it clearly in an issue](https://github.com/TheAlgorithms/TypeScript/issues/new) or on our [**Discord server**](https://discord.gg/c7MnfGFGa6). | ||
|
||
## Contributing | ||
|
||
### Contributor | ||
|
||
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 [MIT License](LICENSE) once your pull request is merged. | ||
- Your submitted work must fulfill our styles and standards. | ||
|
||
**New implementations** 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. | ||
|
||
### Contribution | ||
|
||
We appreciate any contribution, from fixing grammar mistakes to implementing complex algorithms. Please read this | ||
section if you are contributing to your work. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If you submit a pull request that resolves an open issue, please help us to keep our issue list small by adding | ||
`closes: #{$ISSUE_NO}` to your commit message. GitHub will use this tag to auto-close the issue if your PR is merged. | ||
|
||
#### What is an Algorithm? | ||
|
||
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. | ||
|
||
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 TypScript naming conventions and intuitive variable names to ease comprehension. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- be flexible to take different input values. | ||
- raise TypeScript exceptions (RangeError, etc.) on erroneous input values. | ||
|
||
Algorithms in this repo should not be how-to examples for existing TypeScript 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 TypeScript packages but each algorithm in this repo | ||
should add unique value. | ||
|
||
#### File Naming Convention | ||
|
||
- Filenames should use the UpperCamelCase (PascalCase) style. | ||
- There should be no spaces in filenames. | ||
- **Example:** `UserProfile.ts` is allowed. Do not use `userprofile.ts`, `Userprofile.ts`, `user-Profile.ts`, `userProfile.ts`; these methods are discouraged. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Commit Messages Formatting | ||
|
||
- Prefer to use the following format: `<type>: <short summary>`. If necessary, put any extra information in the description. | ||
- Commit types include (but are not limited to): | ||
- **docs**: Documentantion only changes | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **feat**: A new feature | ||
- **fix**: A bug fix | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **chore**: Miscellaneous stuff that does not match any of the above | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- **Examples**: | ||
- `feat: add quicksort algorithm` | ||
- `chore: fix spelling` | ||
- `fix: improper error message` | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- `docs: add contributing guidelines` | ||
|
||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Module System | ||
|
||
We use the [ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/) system, which bring an official, standardized module system to JavaScript. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
It roughly means you will need to use `export` and `import` statements instead of `module.exports` and `require()`. | ||
|
||
#### Coding Style | ||
|
||
To maximize the readability and correctness of our code, we require that new submissions follow the | ||
[TypeScript Standard Style](https://github.com/standard/ts-standard). | ||
|
||
In order to apply the coding style (where it can be done automatically). If an error is shown, please figure out what's | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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). | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Names start with a letter. | ||
- Follow code indentation: Always use 2 spaces for indentation of code blocks. | ||
|
||
```ts | ||
function sum(arr: number[]): number { | ||
let total = 0; | ||
for (let i = 0; i < arr.length; i++) { | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
total += arr[i]; | ||
} | ||
return total; | ||
} | ||
``` | ||
|
||
- Avoid using global variables and avoid `==`. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Please use `let` over `var`. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Please refrain from using `console.log` or any other console methods. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Absolutely** don't use `alert`. | ||
- We strongly recommend the use of ECMAScript 6. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Avoid the use of `any` type. Create an interface/class instead. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Don't prefix Interfaces with `I`. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Prefer not to use `null` nor `undefined` for explicit unavailability. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```ts | ||
// BAD | ||
let foo = { x: 123, y: undefined }; | ||
|
||
// GOOD | ||
let foo: { x: number, y?: number } = { x:123 }; | ||
``` | ||
- Annotate arrays as `foos: Foo[]` instead of `foos: Array<Foo>`. | ||
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Most importantly: | ||
- **Be consistent in the use of these guidelines when submitting.** | ||
- Happy coding! | ||
|
||
Written by [**@gefgu**](https://github.com/gefgu) and community, September 2022. | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Uh oh!
There was an error while loading. Please reload this page.