DEV Community

Mayank Singh Kushwah
Mayank Singh Kushwah

Posted on

Implementing Best Practices for Developing an NPM Package with Automated Testing and Deployment

In this repository, I have implemented an npm package that contains some useful common functions. These functions should be tested using unit test cases, and the syntax and format should be checked by ESLint during development.

Before committing the code, I have set up a pre-commit hook that checks the unit test cases and code coverage. If all the unit test cases pass, the code is ready for the commit. Additionally, I have set up a commit message format using the conventional commit standard, and the files are automatically formatted using Prettier before committing.

To push the code, you need to create a branch and generate a pull request. Once the pull request is created, SonarQube checks the code for bugs, code smells, vulnerabilities, and shows the code coverage. If there are any bugs, the pull request will not be accepted by the admin.

Once the pull request is accepted, it is merged into the main branch. After the merge, a workflow is triggered that generates the documentation of our functions and deploys it to the GitHub Pages.

If you create a tag and release the branch, an npm package is automatically created and published on the official npm package site. To download or install the package, you can run the command "npm install".

GitHub Repository URL
Documentation GitHub Pages URL
NPM Package URL
SonarQube Report

Top comments (0)