Skip to content

Commit aecf31d

Browse files
committed
Update README, index.js, issue and pull request templates, and LICENSE file
1 parent 21958ac commit aecf31d

File tree

5 files changed

+146
-29
lines changed

5 files changed

+146
-29
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Additional context**
27+
Add any other context about the problem here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] This change requires a documentation update
15+
16+
## How Has This Been Tested?
17+
18+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
19+
20+
- [ ] Test A
21+
- [ ] Test B
22+
23+
## Checklist:
24+
25+
- [ ] My code follows the style guidelines of this project
26+
- [ ] I have performed a self-review of my own code
27+
- [ ] I have commented my code, particularly in hard-to-understand areas
28+
- [ ] I have made corresponding changes to the documentation
29+
- [ ] My changes generate no new warnings
30+
- [ ] I have added tests that prove my fix is effective or that my feature works
31+
- [ ] New and existing unit tests pass locally with my changes

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [year] [fullname]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
# js-quality-starter
22

3-
A starter repository for JavaScript projects with pre-configured linting, formatting, testing, and CI using GitHub Actions.
3+
A template repository for modern JavaScript projects with pre-configured linting, formatting, testing, and CI/CD using GitHub Actions.
4+
45

56
This template provides a solid foundation for any new JavaScript project, ensuring code quality and consistency from the start.
67

7-
## Features
8+
## What's Inside?
9+
10+
This template comes pre-configured with a suite of modern, industry-standard tools to ensure your project maintains high code quality.
11+
12+
| Tool | Purpose |
13+
| :------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
14+
| **[ESLint](https://eslint.org/)** | Statically analyzes your code to quickly find and fix problems. It's configured with recommended rules to enforce best practices. |
15+
| **[Prettier](https://prettier.io/)** | An opinionated code formatter that enforces a consistent style across your entire codebase, eliminating arguments over code style. |
16+
| **[Jest](https://jestjs.io/)** | A delightful JavaScript Testing Framework with a focus on simplicity. It's set up and ready for you to write unit and integration tests. |
17+
| **[Husky](https://typicode.github.io/husky/)** | Manages Git hooks to make it easy to run scripts at specific stages, like before a commit. |
18+
| **[lint-staged](https://github.com/okonet/lint-staged)** | Works with Husky to run linters and formatters on your staged files *before* they are committed, ensuring no bad code gets in. |
19+
| **[GitHub Actions](https://github.com/features/actions)** | Automates your workflow with two pre-configured CI pipelines for validating code on `main` and all other feature branches. |
820

9-
- **Linting** with [ESLint](https://eslint.org/) to find and fix problems in your JavaScript code.
10-
- **Formatting** with [Prettier](https://prettier.io/) for a consistent code style.
11-
- **Testing** with [Jest](https://jestjs.io/) as the testing framework.
12-
- **CI/CD** with [GitHub Actions](https://github.com/features/actions) to automate linting, formatting checks, and testing on every push and pull request.
13-
- **Pre-commit Hooks** with [Husky](https://typicode.github.io/husky/) and [lint-staged](https://github.com/okonet/lint-staged) to lint and format your code before you even commit it.
1421

1522
## Getting Started
1623

1724
### Using as a Template
1825

19-
Click the "Use this template" button on the GitHub repository page to create a new repository with the same directory structure and files.
26+
1. Click the **"Use this template"** button on the GitHub repository page.
27+
2. Select **"Create a new repository"**.
28+
3. Give your new repository a name and description.
29+
4. Clone your new repository to your local machine.
2030

2131
### Manual Setup
2232

2333
1. Clone the repository:
2434

2535
```bash
26-
git clone https://github.com/your-username/js-quality-starter.git
27-
cd js-quality-starter
36+
git clone https://github.com/your-username/your-new-repo.git
37+
cd your-new-repo
2838
```
39+
This will install all dependencies and also run the `prepare` script, which sets up the Husky pre-commit hooks automatically.
40+
41+
3. Start coding!
2942

30-
2. Install dependencies:
31-
```bash
32-
npm install
33-
```
3443

3544
## Available Scripts
3645

@@ -44,19 +53,48 @@ In the project directory, you can run:
4453

4554
## How It Works
4655

47-
### Pre-commit Hook
56+
### Pre-commit Hooks
57+
58+
This project uses `Husky` and `lint-staged` to run `eslint --fix` and `prettier --write` on staged `.js` files every time you make a commit. This automated quality gate ensures that no code that violates the style guide ever gets into the codebase.
59+
60+
If a file has linting or formatting errors, the tools will attempt to fix them automatically. If they can, the fixed code is what gets committed. If they can't, the commit is aborted so you can fix the issues manually.
61+
62+
63+
### CI/CD Pipelines
64+
65+
This template includes two GitHub Actions workflows located in the `.github/workflows` directory:
66+
67+
1. **`ci.yml`**: This workflow runs on every push and pull request to the `main` branch. It acts as a final validation gate, ensuring that all tests, linting, and formatting checks pass before code is merged.
68+
2. **`feature-branch-ci.yml`**: This workflow runs on all branches *except* `main`. It provides early feedback on feature branches, running the same set of checks to ensure quality throughout the development process.
69+
70+
Both workflows perform the following steps across multiple Node.js versions (18.x, 20.x):
71+
72+
1. **Install dependencies** using `npm ci` for fast, reliable installs.
73+
2. **Lint code** with `npm run lint`.
74+
3. **Check formatting** with `npm run format`.
75+
4. **Run tests** with `npm test`.
76+
77+
## Customization
78+
79+
This template is a starting point. You can easily customize it to fit your project's needs:
80+
81+
- **Linting Rules**: Modify the `.eslintrc.js` file to add or change ESLint rules.
82+
- **Formatting Options**: Adjust the `.prettierrc` file to change Prettier's formatting options.
83+
- **Testing**: The `jest.config.js` file can be configured for more advanced testing scenarios.
84+
- **CI/CD**: Edit the workflow files in `.github/workflows` to add new steps, such as deployment or notifications.
4885
49-
This project uses `husky` and `lint-staged` to run `eslint --fix` and `prettier --write` on staged `.js` files every time you make a commit. This ensures that no code that violates the style guide gets into the codebase.
86+
## Contributing
5087
51-
After running `npm install`, the `prepare` script sets up the husky hooks.
88+
Contributions are welcome! If you're using this template and have ideas for improvement, please feel free to open an issue or submit a pull request.
5289

53-
### CI Pipeline
90+
1. **Fork** the repository.
91+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`).
92+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
93+
4. Push to the branch (`git push origin feature/AmazingFeature`).
94+
5. Open a **Pull Request**.
5495

55-
The `.github/workflows/ci.yml` file defines a GitHub Actions workflow that runs on every push and pull request to the `main` branch. It performs the following checks on Node.js 18.x and 20.x:
96+
Please use the provided Pull Request and Issue templates.
5697

57-
1. Installs dependencies.
58-
2. Runs `npm run lint` to check for linting errors.
59-
3. Runs `npm run format` to check for formatting errors.
60-
4. Runs `npm test` to execute the test suite.
98+
## License
6199

62-
This ensures that all code in the `main` branch is high quality and passes all checks.
100+
This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
2-
* Adds two numbers together.
3-
* @param {number} a The first number.
4-
* @param {number} b The second number.
5-
* @returns {number} The sum of the two numbers.
2+
* A simple function to demonstrate testing.
3+
* @param {number} a - The first number.
4+
* @param {number} b - The second number.
5+
* @returns {number} The sum of a and b.
66
*/
77
function add(a, b) {
88
return a + b;
99
}
1010

11-
module.exports = add;
11+
module.exports = { add };

0 commit comments

Comments
 (0)