Skip to content

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
merged 42 commits into from
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 Sep 23, 2022
5b1bdcb
Add author
gefgu Sep 23, 2022
db4c59b
Update before contributing section
gefgu Sep 23, 2022
952cbcc
Add link to MIT license
gefgu Sep 23, 2022
9403750
Update some javascript references to typescript
gefgu Sep 23, 2022
8e15c7d
Remove testing section
gefgu Sep 23, 2022
f5a901a
Add ts standard guide
gefgu Sep 23, 2022
c8b62c9
Remove style script in guidelines
gefgu Sep 23, 2022
8d2f913
Update JS example to TS
gefgu Sep 23, 2022
f832d9d
Fix redundant naming in example
gefgu Sep 24, 2022
f807183
Add typescript guidelines
gefgu Sep 24, 2022
da9159a
chore: Add discord server
gefgu Sep 25, 2022
5fc8b1b
Fix: change "implementation" to plural
gefgu Sep 25, 2022
7cc1e42
Fix: add comma
gefgu Sep 25, 2022
bc32437
fix: change auto-close tag
gefgu Sep 25, 2022
95798fe
fix: add correct spelling
gefgu Sep 25, 2022
54cafba
fix: improper discouragement of filenames.
gefgu Sep 25, 2022
b4138ae
docs: add commit messages guidelines
gefgu Sep 25, 2022
c0bd950
docs: fix missing space
gefgu Sep 25, 2022
7bc3cd5
docs: add missing verb
gefgu Sep 25, 2022
1c66244
docs: add chore tag
gefgu Sep 26, 2022
a5facf2
docs: add docs tag usage example
gefgu Sep 26, 2022
55dec46
Update CONTRIBUTING.md
gefgu Sep 26, 2022
834eaf4
docs: add community help in documentation
gefgu Sep 26, 2022
4af8fb0
docs: add consistency to contribution lists
gefgu Sep 28, 2022
66df7be
docs: fix spelling mistake
gefgu Sep 28, 2022
54c92b7
docs: fix typescript misspelling
gefgu Sep 28, 2022
2dd2c11
docs: fix documentation misspelling
gefgu Sep 28, 2022
a6ce8e2
docs: fix word usage in example
gefgu Sep 28, 2022
aceaa02
docs: fix misspelling in module system section
gefgu Sep 28, 2022
8be2860
docs: remove apply of style guidelines
gefgu Sep 28, 2022
fafb56b
docs: add correct camelcase type for vars
gefgu Sep 28, 2022
91dfa52
docs: add more idiomatic example
gefgu Sep 28, 2022
d3856f7
docs: improve js guidelines
gefgu Sep 28, 2022
17b048e
docs: fix guidelines regarding 'any'
gefgu Sep 28, 2022
9dca6fb
docs: fix guidelines about null and undefined
gefgu Sep 28, 2022
aac7c62
docs: fix guidelines about external libraries
gefgu Sep 28, 2022
9fd1cbf
docs: remove author and date of writing
gefgu Sep 28, 2022
4e404ad
docs: fix guidelines about ecmascript
gefgu Sep 28, 2022
9105eb1
docs: fix guidelines about redundant naming
gefgu Sep 28, 2022
b232253
docs: fix semantic commit messages guidelines
gefgu Sep 28, 2022
8f4fac9
Update naming conventions
appgurueu Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions CONTRIBUTING.md
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
- **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`
- `docs: add contributing guidelines`
- `test: add test for quicksort algorithm`

#### 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!