{"id":20670333,"url":"https://github.com/enonic/clean-code","last_synced_at":"2026-04-09T12:04:40.559Z","repository":{"id":138957331,"uuid":"225198643","full_name":"enonic/clean-code","owner":"enonic","description":"🛁 Clean Code concepts adapted for the Enonic projects","archived":false,"fork":false,"pushed_at":"2020-07-20T09:51:20.000Z","size":21,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-10T16:45:58.803Z","etag":null,"topics":["clean-code","css","design-patterns","git","typescript"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enonic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-01T17:14:39.000Z","updated_at":"2020-07-20T09:51:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a4b45f8-d6a7-4b13-890d-280e02a1361c","html_url":"https://github.com/enonic/clean-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/enonic/clean-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enonic%2Fclean-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enonic%2Fclean-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enonic%2Fclean-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enonic%2Fclean-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enonic","download_url":"https://codeload.github.com/enonic/clean-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enonic%2Fclean-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274137721,"owners_count":25228675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-code","css","design-patterns","git","typescript"],"created_at":"2024-11-16T20:19:36.713Z","updated_at":"2025-12-30T21:27:55.876Z","avatar_url":"https://github.com/enonic.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"**Clean Code**\n===\n\nClean Code concepts adapted for the Enonic projects.\n\n## **Table of Contents**\n\n1. [Introduction](#introduction)\n2. [Git](#git)\n   * [Commits](#commits)\n   * [Pull Requests](#pull-requests)\n3. [TypeScript](#typescript)\n   * [Variables](#variables)\n   * [Functions](#functions)\n   * [Classes](#classes)\n3. [CSS](#css)\n\u003cbr/\u003e [License](#license)\n\n## **Introduction**\n\nWhile the original Robert C. Martin's book [_Clean Code_][3] represents a guide to producing readable, reusable, and refactorable code, this document will also describe the principles of creating compatible applications for the [Enonic][1] [XP][2]. Some parts of this document can be used as a style guide since it touches not only the TypeScript, but also a CSS, application structure, and even Git commits.\n\nIt's recommended to read the following first:\n\n* [Clean Code][3] by Robert C. Martin;\n* [Clean Code JavaScript][4] adaptation by [Ryan McDermott][5];\n* [Clean Code TypeScript][6] adaptation by [Labs42][7];\n* [Pro Git][8] Book;\n* [Git Commit][9] article by [Chris Beams][10].\n\n## **Git**\n\nThis part describes the rules of the Enonic workflow while working with Git. For the detailed overview of the basic commit principles see the separate [article][9].\n\n## Commits\n\n### Use issue title as commit subject\n\n**Bad:**\n\n```bash\ngit commit -m \"Changes to confirmation dialog\"\n```\n\n**Good:**\n\n```bash\ngit commit -m \"Confirmation not working #77\"\n```\n\n### Non-task commit subject must be short, descriptive, and neutral\n\n:warning: Avoid non-task commits.\n\nThe sentence \"*Applying this commit will* \\*commit subject\\*\" must make sense.\n\n**Bad:**\n\n```bash\ngit commit -m \"fixed console errors.\"\n```\n\n**Good:**\n\n```bash\ngit commit -m \"Fix exception on dialog initial load\"\n```\n\n## Pull Requests\n\n### Add the same person to Reviewers and Assignees lists\n\nWhen you create a Pull Request and know exactly who should review it, add this person both to the Reviewers and Assignees lists.\n\n**Bad:**\n\n```\nReviewers:\n  - John Smith\n\nAssignees:\n```\n\n**Good:**\n\n```\nReviewers:\n  - John Smith\n\nAssignees:\n  - John Smith\n```\n\n### Add at least two reviewers\n\nWhen you create a Pull Request consider adding at least two reviewers to it, and avait both to complete a review. It is not always possible but desireable for team knowlage sharing.\n\n**Bad:**\n\n```\nReviewers:\n  - John Smith\n```\n\n**Good:**\n\n```\nReviewers:\n  - John Smith\n  - Jaine Doe\n```\n\n### Pool request for a bugfix\n\nFirst bugfix pool request should always be issued for the master branch (bugfix branch should have a name `issue-{issue#}` ex. `issue-1234`).\nAfter Pool Request was approved and merged into master branch create separate pool request for all version branches this fix should be applied to (branches should have a name `issue-{issue#}-{version#}` ex. `issue-1234-7.3`)\nBugfix pool request must be one-commit. Sqash miltiplie commits into one before and after Pool request review adjustments.\n\nExample: Bug #8225 has to be fixed in supported versions 6.15, 7.2 and 7.3\n\n- Create a branch issue-8225 based on master\n- Create a PR from issue-8225 branch\n- Assign reviewers\n- Wait for reviewes to approve PR\n- Rebase and merge PR into master. Delete branch if not deleted automatically.\n- Create a backprot branch `issue-8225-6.15` based on 6.15 version branch and PR with a fix\n- Create a backprot branch `issue-8225-7.2` based on 7.2 version branch and PR with a fix\n- Create a backprot branch `issue-8225-7.3` based on 7.3 version branch and PR with a fix\n- Assign repository owner (administrator) for review on each PR\n- Owners rebase merge and delete individual PRs into corresponding version branches.\n\n## **TypeScript**\n\n## Variables\n\n### Use verbs at the beginning of the boolean variable names\n\nThis rule works exactly the opposite for class or object properties.\n\n**Bad:**\n\n```typescript\nconst enabled = this.hasClass('enabled');\nconst updatable = input != null \u0026\u0026 !input.disabled;\n```\n\n**Good:**\n\n```typescript\nconst isEnabled = this.hasClass('enabled');\nconst canBeUpdated = input != null \u0026\u0026 !input.disabled;\n```\n\n## Functions\n\n--\n\n## Classes\n\n### Use Object to pass several parameters to the constructor\n\nWhen passing more than 3 parameters to the `constructor` (more than 2, if there are at least one optional parameter), use the configuration object.\n\n**Bad:**\n\n```typescript\nclass ModalDialog {\n  constructor(title: string, className?: string, closeCallback?: () =\u003e void) {\n    // ...\n  }\n}\n\nconst closeCallback = () =\u003e { /* do something */ };\nconst dialog = new ModalDialog(title, null, closeCallback);\n```\n\n**Good:**\n\n```typescript\ninterface ModalDialogConfig {\n  title: string;\n  className?: string;\n  closeCallback?: () =\u003e void;\n}\n\nclass ModalDialog {\n  constructor(config: ModalDialogConfig) {\n    // ...\n  }\n}\n\nconst title = 'My Dialog';\nconst closeCallback = () =\u003e { /* do something */ };\n\nconst dialog = new ModalDialog({title, closeCallback});\n```\n\n## **CSS**\n\n## **License**\n\n[MIT](LICENSE) © [Enonic][1]\n\n\u003c!-- Links --\u003e\n\n[1]: https://enonic.com/\n[2]: https://enonic.com/products/enonic-xp\n[3]: https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882\n[4]: https://github.com/ryanmcdermott/clean-code-javascript\n[5]: https://github.com/ryanmcdermott\n[6]: https://github.com/labs42io/clean-code-typescript\n[7]: https://github.com/labs42io\n[8]: https://git-scm.com/book/\n[9]: https://chris.beams.io/posts/git-commit/\n[10]: https://github.com/cbeams\n [base-license-url]: http://creativecommons.org/licenses/by-nc-nd/4.0/\n[base-license-image]: http://mirrors.creativecommons.org/presskit/buttons/80x15/svg/by-nc-sa.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenonic%2Fclean-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenonic%2Fclean-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenonic%2Fclean-code/lists"}