From 6168042df662bd7e1ee6518b45325ae314a82017 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:32:39 -0300 Subject: [PATCH 01/42] Add contribution guidelines copy from js repo --- CONTRIBUTING.md | 146 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..38950ec7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,146 @@ +# Contributing guidelines + +## Before contributing + +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 any doubt on the contributing guide, please feel free to +[state it clearly in an issue](https://github.com/TheAlgorithms/Javascript/issues/new). + +## 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 [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. + +**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. + +If you submit a pull request that resolves an open issue, please help us to keep our issue list small by adding +`fixes: #{$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 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 +manipulations can use data types, classes, or functions of existing JavaScript 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.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, which bring 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()`. + +#### Testing + +Be confident that your code works. When was the last time you committed a code change, your build failed, and half of +your app stopped working? Mine was last week. Writing tests for our Algorithms will help us ensure the implementations +are air tight even after multiple fixes and code changes. + +We use [Jest](https://jestjs.io/) to run unit tests on our algorithms. It provides a very readable and expressive way to +structure your test code. + +It is advised that the algorithm file (module) does not contain any "live" code but rather just exports the function(s) +needed to execute the algorithm. Your test code can import those function(s), call them with the appropriate parameters +and inspect the outcome. Example: [RatInAMaze.test.js](Backtracking/tests/RatInAMaze.test.js). + +Please refrain from using `console` in your implementation AND test code. + +You can (and should!) run all tests locally before committing your changes: + +```shell +npm test +``` + +If you want save some time and just run a specific test: + +```shell +# this will run any test file where the filename matches "koch" +npm test -- koch +``` + +You can also start Jest in "watch" mode: + +```shell +npm test -- --watchAll +``` + +This will run all tests and watch source and test files for changes. When a change is made, the tests will run again. + +#### Coding Style + +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 + +```shell +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 +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. + +```js +function sumOfArray(arrayOfNumbers) { + let sum = 0 + for (let i = 0; i < arrayOfNumbers.length; i++) { + sum += arrayOfNumbers[i] + } + 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! + +Writer [@itsvinayak](https://github.com/itsvinayak), May 2020. \ No newline at end of file From 5b1bdcb8736945cb3f43d4ee116242c9e07d8b31 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:34:11 -0300 Subject: [PATCH 02/42] Add author --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38950ec7..3110cc95 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,4 +143,4 @@ function sumOfArray(arrayOfNumbers) { - **Be consistent in the use of these guidelines when submitting.** - Happy coding! -Writer [@itsvinayak](https://github.com/itsvinayak), May 2020. \ No newline at end of file +Writer [@gefgu](https://github.com/gefgu), September 2022. \ No newline at end of file From db4c59bf07af87b89f6a20bc6ba881442ea37624 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:34:28 -0300 Subject: [PATCH 03/42] Update before contributing section --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3110cc95..e993260d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,9 @@ ## Before contributing -Welcome to [TheAlgorithms/Javascript](https://github.com/TheAlgorithms/Javascript)! Before sending your pull requests, +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/Javascript/issues/new). +[state it clearly in an issue](https://github.com/TheAlgorithms/TypeScript/issues/new). ## Contributing From 952cbcc90fb20789dec6f3d27de7a1c61491004e Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:35:41 -0300 Subject: [PATCH 04/42] Add link to MIT license --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e993260d..990be0f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ 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 [GNU License](LICENSE) once your pull request is 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 implementation** is welcome! For example, new solutions to a problem, different representations of a graph data From 9403750a2fa0c8e15822a81e67b6c6863b8c9a3e Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:38:07 -0300 Subject: [PATCH 05/42] Update some javascript references to typescript --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 990be0f6..fc1c03fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,20 +45,20 @@ Algorithms should be packaged in a way that would make it easy for readers to pu 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. +- use TypScript 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. +- raise TypeScript 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 +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 JavaScript packages but each algorithm in this repo +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.js` is allowed but `userprofile.js`,`Userprofile.js`,`user-Profile.js`,`userProfile.js` are +- **Example:** `UserProfile.ts` is allowed but `userprofile.ts`,`Userprofile.ts`,`user-Profile.ts`,`userProfile.ts` are not. #### Module System From 8e15c7dff6859b41f594ef3f69a8ee8f13829c44 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:38:59 -0300 Subject: [PATCH 06/42] Remove testing section --- CONTRIBUTING.md | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc1c03fe..0d74f0df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,42 +67,6 @@ We use the [ES Module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-de It roughly means you will need to use `export` and `import` statements instead of `module.exports` and `require()`. -#### Testing - -Be confident that your code works. When was the last time you committed a code change, your build failed, and half of -your app stopped working? Mine was last week. Writing tests for our Algorithms will help us ensure the implementations -are air tight even after multiple fixes and code changes. - -We use [Jest](https://jestjs.io/) to run unit tests on our algorithms. It provides a very readable and expressive way to -structure your test code. - -It is advised that the algorithm file (module) does not contain any "live" code but rather just exports the function(s) -needed to execute the algorithm. Your test code can import those function(s), call them with the appropriate parameters -and inspect the outcome. Example: [RatInAMaze.test.js](Backtracking/tests/RatInAMaze.test.js). - -Please refrain from using `console` in your implementation AND test code. - -You can (and should!) run all tests locally before committing your changes: - -```shell -npm test -``` - -If you want save some time and just run a specific test: - -```shell -# this will run any test file where the filename matches "koch" -npm test -- koch -``` - -You can also start Jest in "watch" mode: - -```shell -npm test -- --watchAll -``` - -This will run all tests and watch source and test files for changes. When a change is made, the tests will run again. - #### Coding Style To maximize the readability and correctness of our code, we require that new submissions follow the From f5a901ac5092affc300e0438af3f7cbcd9a12048 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:42:25 -0300 Subject: [PATCH 07/42] Add ts standard guide --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d74f0df..a4a1b02f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,7 +70,7 @@ It roughly means you will need to use `export` and `import` statements instead o #### Coding Style To maximize the readability and correctness of our code, we require that new submissions follow the -[JavaScript Standard Style](https://standardjs.com/). +[TypeScript Standard Style](https://github.com/standard/ts-standard). Before committing, please run From c8b62c98fa4e470cec1b5af6fb10f29b05ac0ba0 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:43:49 -0300 Subject: [PATCH 08/42] Remove style script in guidelines --- CONTRIBUTING.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4a1b02f..d0a98c07 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,12 +72,6 @@ It roughly means you will need to use `export` and `import` statements instead o 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). -Before committing, please run - -```shell -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 wrong, fix it and run standard again. From 8d2f913cd04c2a1f6ba767a459895c071508c880 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Fri, 23 Sep 2022 16:44:55 -0300 Subject: [PATCH 09/42] Update JS example to TS --- CONTRIBUTING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0a98c07..9e54b355 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,13 +81,13 @@ A few (but not all) of the things to keep in mind: - Names start with a letter. - Follow code indentation: Always use 2 spaces for indentation of code blocks. -```js -function sumOfArray(arrayOfNumbers) { - let sum = 0 +```ts +function sumOfArray(arrayOfNumbers: number[]): number { + let sum = 0; for (let i = 0; i < arrayOfNumbers.length; i++) { - sum += arrayOfNumbers[i] + sum += arrayOfNumbers[i]; } - return sum + return sum; } ``` @@ -101,4 +101,4 @@ function sumOfArray(arrayOfNumbers) { - **Be consistent in the use of these guidelines when submitting.** - Happy coding! -Writer [@gefgu](https://github.com/gefgu), September 2022. \ No newline at end of file +Writer [@gefgu](https://github.com/gefgu), September 2022. From f832d9d94333199e99d97d36cdb3cad724d15d70 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Sat, 24 Sep 2022 08:32:34 -0300 Subject: [PATCH 10/42] Fix redundant naming in example --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e54b355..a8f4ac8b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,12 +82,12 @@ A few (but not all) of the things to keep in mind: - Follow code indentation: Always use 2 spaces for indentation of code blocks. ```ts -function sumOfArray(arrayOfNumbers: number[]): number { - let sum = 0; - for (let i = 0; i < arrayOfNumbers.length; i++) { - sum += arrayOfNumbers[i]; +function sum(arr: number[]): number { + let total = 0; + for (let i = 0; i < arr.length; i++) { + total += arr[i]; } - return sum; + return total; } ``` From f807183d77b71538be5876877bf249ab190af052 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Sat, 24 Sep 2022 09:21:14 -0300 Subject: [PATCH 11/42] Add typescript guidelines --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a8f4ac8b..597fe0da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,6 +96,18 @@ function sum(arr: number[]): number { - 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 the use of `any` type. Create an interface/class instead. +- Don't prefix Interfaces with `I`. +- Prefer not to use `null` nor `undefined` for explicit unavailability. + +```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`. - 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.** From da9159abdea222aedd0902ecb338006a315c95ab Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:01:17 -0300 Subject: [PATCH 12/42] chore: Add discord server Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 597fe0da..3aff2f8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ 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). +[state it clearly in an issue](https://github.com/TheAlgorithms/TypeScript/issues/new) or on our [**Discord server**](https://discord.gg/c7MnfGFGa6). ## Contributing From 5fc8b1b0c3d77b9f3a404f4952db22b9efe06a36 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:03:49 -0300 Subject: [PATCH 13/42] Fix: change "implementation" to plural Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3aff2f8e..e8e0aa68 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ referenced and used by learners from around the globe. Being one of our contribu - 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 implementation** is welcome! For example, new solutions to a problem, different representations of a graph data +**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. From 7cc1e42259c72df3139bf58f902e011e302e4454 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:04:07 -0300 Subject: [PATCH 14/42] Fix: add comma Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e8e0aa68..d0df8142 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ referenced and used by learners from around the globe. Being one of our contribu - 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. +structure, or algorithm designs with different complexity. **Improving comments** and **writing proper tests** are also highly welcome. From bc32437b475ad755ca019b94407abab7ee2aec33 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:05:29 -0300 Subject: [PATCH 15/42] fix: change auto-close tag Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0df8142..22040e94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ We appreciate any contribution, from fixing grammar mistakes to implementing com section if you are contributing to your work. If you submit a pull request that resolves an open issue, please help us to keep our issue list small by adding -`fixes: #{$ISSUE_NO}` to your commit message. GitHub will use this tag to auto-close the issue if your PR is merged. +`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? From 95798fe710e3559816e9617ccbda0a25b63d17b5 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:06:26 -0300 Subject: [PATCH 16/42] fix: add correct spelling Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22040e94..3f9440fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,7 @@ should add unique value. #### 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.ts` is allowed but `userprofile.ts`,`Userprofile.ts`,`user-Profile.ts`,`userProfile.ts` are not. From 54cafba8ae67b8a9c2d0c77bf69707ca36aa259c Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Sun, 25 Sep 2022 09:07:56 -0300 Subject: [PATCH 17/42] fix: improper discouragement of filenames. Co-authored-by: David Leal --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f9440fe..8c871fa6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,8 +58,7 @@ should add unique value. - Filenames should use the UpperCamelCase (PascalCase) style. - There should be no spaces in filenames. -- **Example:** `UserProfile.ts` is allowed but `userprofile.ts`,`Userprofile.ts`,`user-Profile.ts`,`userProfile.ts` are - not. +- **Example:** `UserProfile.ts` is allowed. Do not use `userprofile.ts`, `Userprofile.ts`, `user-Profile.ts`, `userProfile.ts`; these methods are discouraged. #### Module System From b4138aed957a45d5b99b934a6695cd99aa1e7141 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Sun, 25 Sep 2022 09:23:12 -0300 Subject: [PATCH 18/42] docs: add commit messages guidelines --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c871fa6..02e474c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,6 +60,18 @@ should add unique value. - 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. +#### Commit Messages Formatting + +- Prefer to use the following format: `: `. If necessary, put any extrainformation in the description. +- Commit types include (but not limited to): + - **docs**: Documentantion only changes + - **feat**: A new feature + - **fix**: A bug fix +- **Examples**: + - `feat: add quicksort algorithm` + - `chore: fix spelling` + - `fix: improper error message` + #### 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. From c0bd9505d6e80d3e0dd8cbe39bfd93aa3bc65d6a Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Sun, 25 Sep 2022 09:27:49 -0300 Subject: [PATCH 19/42] docs: fix missing space --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02e474c2..746f9cc9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,7 @@ should add unique value. #### Commit Messages Formatting -- Prefer to use the following format: `: `. If necessary, put any extrainformation in the description. +- Prefer to use the following format: `: `. If necessary, put any extra information in the description. - Commit types include (but not limited to): - **docs**: Documentantion only changes - **feat**: A new feature From 7bc3cd566f9874aa63e54300d5401ad13637b25b Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Sun, 25 Sep 2022 09:29:17 -0300 Subject: [PATCH 20/42] docs: add missing verb --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 746f9cc9..9c14bf57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ should add unique value. #### Commit Messages Formatting - Prefer to use the following format: `: `. If necessary, put any extra information in the description. -- Commit types include (but not limited to): +- Commit types include (but are not limited to): - **docs**: Documentantion only changes - **feat**: A new feature - **fix**: A bug fix From 1c662446b991677f9ae04157048bd166f4c59463 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:57:38 -0300 Subject: [PATCH 21/42] docs: add chore tag Co-authored-by: David Leal --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c14bf57..7732b75f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,6 +67,7 @@ should add unique value. - **docs**: Documentantion only changes - **feat**: A new feature - **fix**: A bug fix + - **chore**: Miscellaneous stuff that does not match any of the above - **Examples**: - `feat: add quicksort algorithm` - `chore: fix spelling` From a5facf22b8f75a73b0c7f34a0caf6eda797ea4c5 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:57:59 -0300 Subject: [PATCH 22/42] docs: add docs tag usage example Co-authored-by: David Leal --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7732b75f..5bdd4d0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,6 +72,7 @@ should add unique value. - `feat: add quicksort algorithm` - `chore: fix spelling` - `fix: improper error message` + - `docs: add contributing guidelines` #### Module System From 55dec46b59c7f5a51470328492187766e7c036fc Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:10:53 -0300 Subject: [PATCH 23/42] Update CONTRIBUTING.md Co-authored-by: David Leal --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5bdd4d0d..b174ca24 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,7 @@ should add unique value. - **feat**: A new feature - **fix**: A bug fix - **chore**: Miscellaneous stuff that does not match any of the above + - **Examples**: - `feat: add quicksort algorithm` - `chore: fix spelling` From 834eaf485167d564a656d70157f6c6db661e8df0 Mon Sep 17 00:00:00 2001 From: Gustavo Santos <53129852+gefgu@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:11:13 -0300 Subject: [PATCH 24/42] docs: add community help in documentation Co-authored-by: David Leal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b174ca24..c1da6188 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,4 +127,4 @@ let foo: { x: number, y?: number } = { x:123 }; - **Be consistent in the use of these guidelines when submitting.** - Happy coding! -Writer [@gefgu](https://github.com/gefgu), September 2022. +Written by [**@gefgu**](https://github.com/gefgu) and community, September 2022. From 4af8fb00e05006c537c5df5b8b32b80205a3f74a Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:00:04 -0300 Subject: [PATCH 25/42] docs: add consistency to contribution lists --- CONTRIBUTING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1da6188..f05578cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 TypScript 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. +- Have intuitive class and function names that make their purpose clear to readers. +- Use TypScript 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 From 66df7bedfe7d6514e4949ba13262b1e280412f35 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:01:09 -0300 Subject: [PATCH 26/42] docs: fix spelling mistake --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f05578cc..b0127893 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ structure, or algorithm designs with different complexity. ### Contribution We appreciate any contribution, from fixing grammar mistakes to implementing complex algorithms. Please read this -section if you are contributing to your work. +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. From 54c92b7c4e4b3235e913302a4acaa489f0f17f5d Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:02:15 -0300 Subject: [PATCH 27/42] docs: fix typescript misspelling --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b0127893..8b7029c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ Algorithms should be packaged in a way that would make it easy for readers to pu 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. +- 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. From 2dd2c1116f36d9b254c23bdd1495c66bb733f1c6 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:02:51 -0300 Subject: [PATCH 28/42] docs: fix documentation misspelling --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b7029c7..0f8431dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,7 +64,7 @@ should add unique value. - Prefer to use the following format: `: `. If necessary, put any extra information in the description. - Commit types include (but are not limited to): - - **docs**: Documentantion only changes + - **docs**: Documentation only changes - **feat**: A new feature - **fix**: A bug fix - **chore**: Miscellaneous stuff that does not match any of the above From a6ce8e21bcc3bb7ebe102df1b019357b1dbf47eb Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:03:30 -0300 Subject: [PATCH 29/42] docs: fix word usage in example --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f8431dd..b3343f87 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ should add unique value. - 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. +- **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 From aceaa02bd801a4c8eb389b3a2a70296eb64454a6 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:05:40 -0300 Subject: [PATCH 30/42] docs: fix misspelling in module system section --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3343f87..16cb8d91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,7 +77,7 @@ should add unique value. #### 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. +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()`. From 8be2860ff52d7291cb81cbc6bf849991955b6896 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:09:41 -0300 Subject: [PATCH 31/42] docs: remove apply of style guidelines --- CONTRIBUTING.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16cb8d91..e16b7c70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,9 +86,6 @@ It roughly means you will need to use `export` and `import` statements instead o 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 -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). From fafb56b60188b999c629736e30fea492c9031e80 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:10:58 -0300 Subject: [PATCH 32/42] docs: add correct camelcase type for vars --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e16b7c70..8177d4d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,7 +88,7 @@ To maximize the readability and correctness of our code, we require that new sub 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). +- Use `lowerCamelCase` 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. From 91dfa52425c893f51de09708aed0486414ae9d49 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:13:47 -0300 Subject: [PATCH 33/42] docs: add more idiomatic example --- CONTRIBUTING.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8177d4d0..70330b79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,9 +95,7 @@ A few (but not all) of the things to keep in mind: ```ts function sum(arr: number[]): number { let total = 0; - for (let i = 0; i < arr.length; i++) { - total += arr[i]; - } + for (const elem of arr) total += elem; return total; } ``` From d3856f7b913ae339762f2f1e4871e2df0dd59242 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:14:59 -0300 Subject: [PATCH 34/42] docs: improve js guidelines --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70330b79..668cd831 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,10 +100,9 @@ function sum(arr: number[]): number { } ``` -- 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`. +- 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 strongly recommend the use of ECMAScript 6. - Avoid the use of `any` type. Create an interface/class instead. - Don't prefix Interfaces with `I`. From 17b048e5bf52c43e827b5ede56762b6415265e74 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:17:43 -0300 Subject: [PATCH 35/42] docs: fix guidelines regarding 'any' --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 668cd831..ef619495 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,7 +104,7 @@ function sum(arr: number[]): number { - Use only `let` and `const`, never use `var` - Prefer proper input/output of your functions over side effects. - We strongly recommend the use of ECMAScript 6. -- Avoid the use of `any` type. Create an interface/class instead. +- Only use `any` if appropriate. Prefer to create proper types instead. - Don't prefix Interfaces with `I`. - Prefer not to use `null` nor `undefined` for explicit unavailability. From 9dca6fb3f1acaf1e26204e0200e57f3ba0a803d5 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:21:45 -0300 Subject: [PATCH 36/42] docs: fix guidelines about null and undefined --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef619495..1ed1653d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -106,7 +106,7 @@ function sum(arr: number[]): number { - We strongly recommend the use of ECMAScript 6. - Only use `any` if appropriate. Prefer to create proper types instead. - Don't prefix Interfaces with `I`. -- Prefer not to use `null` nor `undefined` for explicit unavailability. +- Prefer using optional fields over `null` or `undefined`. ```ts // BAD From aac7c621d3e0fa668130a6a934b3db4f438854c5 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:24:05 -0300 Subject: [PATCH 37/42] docs: fix guidelines about external libraries --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1ed1653d..f5b82cda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,7 +116,7 @@ let foo = { x: 123, y: undefined }; let foo: { x: number, y?: number } = { x:123 }; ``` - Annotate arrays as `foos: Foo[]` instead of `foos: Array`. -- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms. +- Refrain from importing external libraries. Implement the algorithms "from scratch". - Most importantly: - **Be consistent in the use of these guidelines when submitting.** - Happy coding! From 9fd1cbf19851585bb2f3487218b6828bfda10a92 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:24:29 -0300 Subject: [PATCH 38/42] docs: remove author and date of writing --- CONTRIBUTING.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5b82cda..ac8539c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -119,6 +119,4 @@ let foo: { x: number, y?: number } = { x:123 }; - Refrain from importing external libraries. Implement the algorithms "from scratch". - 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. + - Happy coding! \ No newline at end of file From 4e404adf7382b5f9ecd3ec33c2ec1eeacbf82173 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:27:29 -0300 Subject: [PATCH 39/42] docs: fix guidelines about ecmascript --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac8539c7..11e416fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,7 +103,7 @@ function sum(arr: number[]): number { - 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 strongly recommend the use of ECMAScript 6. +- We required the use of TypeScript. - Only use `any` if appropriate. Prefer to create proper types instead. - Don't prefix Interfaces with `I`. - Prefer using optional fields over `null` or `undefined`. From 9105eb1f37f7b386dc0c58ac6ad1e4abff4f1d97 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:29:43 -0300 Subject: [PATCH 40/42] docs: fix guidelines about redundant naming --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11e416fd..203f88d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,7 +105,7 @@ function sum(arr: number[]): number { - 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. -- Don't prefix Interfaces with `I`. +- 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 From b2322536a192cc53be8787443668613456edf03f Mon Sep 17 00:00:00 2001 From: Gustavo Santos Date: Tue, 27 Sep 2022 21:34:08 -0300 Subject: [PATCH 41/42] docs: fix semantic commit messages guidelines --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 203f88d1..a99d6365 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,13 +67,15 @@ should add unique value. - **docs**: Documentation only changes - **feat**: A new feature - **fix**: A bug fix - - **chore**: Miscellaneous stuff that does not match any of the above + - **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` + - `docs: add contributing guidelines` + - `test: add test for quicksort algorithm` #### Module System From 8f4fac9524e509d1057b420140d0540ef29ed8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Wed, 28 Sep 2022 10:44:38 +0200 Subject: [PATCH 42/42] Update naming conventions --- CONTRIBUTING.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a99d6365..3eb08bc4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,9 +90,12 @@ To maximize the readability and correctness of our code, we require that new sub A few (but not all) of the things to keep in mind: -- Use `lowerCamelCase` 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. +- 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 { @@ -108,17 +111,18 @@ function sum(arr: number[]): number { - 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`. +- 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 }; +let foo: { x: number, y?: number } = { x: 123 }; ``` + - Annotate arrays as `foos: Foo[]` instead of `foos: Array`. - Refrain from importing external libraries. Implement the algorithms "from scratch". - Most importantly: - **Be consistent in the use of these guidelines when submitting.** - - Happy coding! \ No newline at end of file + - Happy coding!