-
-
Notifications
You must be signed in to change notification settings - Fork 432
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 all 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,128 @@ | ||
# 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 this repository. | ||
|
||
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 TypeScript naming conventions and intuitive variable names to ease comprehension. | ||
- 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 naming conventions are discouraged. | ||
|
||
#### 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**: Documentation only changes | ||
- **feat**: A new feature | ||
- **fix**: A bug fix | ||
gefgu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **test**: Adding or fixing tests | ||
- **chore**: CI / code quality / minor quality of life improvements | ||
|
||
- **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` | ||
- `test: add test for quicksort algorithm` | ||
|
||
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 brings an official, standardized module system to TypeScript. | ||
|
||
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). | ||
|
||
A few (but not all) of the things to keep in mind: | ||
|
||
- Naming conventions: | ||
- Names always start with a letter (not with an underscore). | ||
- Use `UpperCamelCase` for classes, interfaces & types. | ||
- Use `lowerCamelCase` for functions and local variables. | ||
- Use `SCREAMING_SNAKE_CASE` for global ("universal") constants. | ||
- Code indentation: Always use 2 spaces for indentation of code blocks. | ||
|
||
```ts | ||
function sum(arr: number[]): number { | ||
let total = 0; | ||
for (const elem of arr) total += elem; | ||
return total; | ||
} | ||
``` | ||
|
||
- Avoid using global variables and avoid `==` (use `===` instead). | ||
- Use only `let` and `const`, never use `var` | ||
- Prefer proper input/output of your functions over side effects. | ||
- We required the use of TypeScript. | ||
- Only use `any` if appropriate. Prefer to create proper types instead. | ||
- No redundant naming. Don't prefix interfaces with `I`, class members with `m`, function with `func` or `f`, etc. | ||
- Prefer using optional fields over `null` or `undefined`. | ||
|
||
```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>`. | ||
- Refrain from importing external libraries. Implement the algorithms "from scratch". | ||
- Most importantly: | ||
- **Be consistent in the use of these guidelines when submitting.** | ||
- Happy coding! |
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.