![]() ![]() ![]() If the lint-staged with two jobs, linting and code formatting, is bound with a pre-commit hook through the husky, the jobs will be automatically triggered on every trial of a Git commit. When those two tools are combined together, it becomes very powerful static code analysis pipeline. For example, a code formatter can be executed in pre-commit stage of the Git by configuring the code formatter's command in the husky's config. The husky is a Git commit hook tool which allows developers to easily run any scripts/commands on all Git hooks without manually write a Git hook script. You can check the example configuration of the tool in the package.json file at the lint-staged section. This allows developers to keep & use their code style locally. It can also enforce code style silently by running code formatter. In other words, it can be final stage for ensuring no errors(technically static code error) go into the repository. It has been commonly used for linting codes right before commit. The lint-staged is a runner which runs linters against staged Git files. ![]() You can run prettier with: npm run format In this project, pre-commit binding is done by husky + lint-staged(see right next section for details). If it is triggered in the pre-commit stage, the code formatting can be done automatically before a commit is made, letting developers do not have to care about code format totally. The Prettier can be powerful when it is bound in Git's pre-commit stage. By using the tool, developers can have a common code format easily and what is more important is they do not to be stressed about formatting anymore. eslint-config-prettier module turns off all rules that are unnecessary or might conflict with Prettier and eslint-plugin-prettier let the ESLint report any ESLint-specific issues, excluding issues conflict with Prettier).Ī code formatting tool that enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. Therefore, this project only uses the code-quality rule of the ESLint and delegate the formatting rule to the Prettier(Technically the term 'delegation' is wrong. The formatting rule overlaps with the one and only feature of the Prettier but it is not as powerful as the Prettier. Linters basically have two categories of rules: formatting rules and code-quality rules. You can check sample API by making a HTTP GET request with the following URL: Table of contentsĪ static code analysis tool for JavaScript codes. Another express.js boilerplate for creating REST API server □ Quick Overview □ npx base-express-app-starter ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |