{"id":13907247,"url":"https://github.com/showdownjs/code-style","last_synced_at":"2025-04-11T16:52:19.904Z","repository":{"id":25958824,"uuid":"29400636","full_name":"showdownjs/code-style","owner":"showdownjs","description":"Code-style and Orientations for showdown and related projects","archived":false,"fork":false,"pushed_at":"2019-08-14T07:18:26.000Z","size":188,"stargazers_count":12,"open_issues_count":0,"forks_count":126,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-25T12:53:39.306Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/showdownjs.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}},"created_at":"2015-01-17T18:15:40.000Z","updated_at":"2024-03-10T08:22:33.000Z","dependencies_parsed_at":"2022-08-07T11:16:12.937Z","dependency_job_id":null,"html_url":"https://github.com/showdownjs/code-style","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showdownjs%2Fcode-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showdownjs%2Fcode-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showdownjs%2Fcode-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showdownjs%2Fcode-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/showdownjs","download_url":"https://codeload.github.com/showdownjs/code-style/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248443246,"owners_count":21104369,"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","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":[],"created_at":"2024-08-06T23:01:50.981Z","updated_at":"2025-04-11T16:52:19.878Z","avatar_url":"https://github.com/showdownjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"Shodown Code Style and Orientations\n===================================\n\nCode-style for showdown and related projects.\n\n## Introduction\nIn this file, you can check the the code styling, rules and commit message convetions for showdown and it's related projects. It's roughly based on [Google JavaScript Style Guide][1] and [AngularJS Git Commit Msg Convention][8]. Using these rules is strongly advisable when contributing to showdown projects.\nIn this repository you can also find a [.editorconfig][2], [.jshintrc][3] and [.jscs.json][4] file that you can use to automatically enforce\nthese rules (if your IDE supports it).\n\nFor more information, check the [editorconfig][5], [jshint][6] and [jscs][7] project pages.\n\n\n## Tabs and indentation\n - **DO NOT USE** tab character, use spaces instead\n - Tab size is 2 spaces\n - Indentation is 1 tab size (2 spaces)\n - Continuation indent is 1 tab size\n - Multiple variable declaration MUST BE chopped and aligned (4 spaces, usually)\n - Empty lines MUST not keep indents\n - Blank lines CAN be added for readability\n - 2 consecutive blank lines are allowed\n - 'case' branches in switch statements MUST BE indented\n\n\n```javascript\nfunction foo() {\n  var bar = 'bar',\n      baz = 1;\n\n  if (bar === 'bar') {\n    alert('something');\n  }\n}\n```\n\n## Semicolons and quotation\n  - **Statements must ALWAYS be terminated with semicolon**. However, multiple variable declaration is allowed.\n  - Single quotes are preferred to double quotes. Exceptionally, double quotes might be used if single quotes would require escaping\n\n\n```javascript\nvar foo = 'some string',\n    baz = \"I'm using single quotes inside\";\n```\n\n\n## Spaces\n\n### Before parenthesis\n  - **DO NOT ADD** before:\n    - function declaration\n    - function call\n\n\n```javascript\nfunction foo() {\n  return 0;\n}\n\nfoo();\n```\n\n\n  - **ADD** before:\n    - 'if'\n    - 'for'\n    - 'while'\n    - 'switch'\n    - 'catch'\n    - in function expression\n\n\n```javascript\nif (i \u003e 10) {\n  for (var j = 0; j \u003c 10; j++) {\n    switch (j) {\n      case 0:\n        value = 'zero';\n        break;\n      case 1:\n        value = 'one';\n        break;\n    }\n  }\n}\n```\n\n### Around operators\n  - **ADD** around:\n    - assignment operators (=, +=, ...)\n    - logical operators (\u0026\u0026, ||)\n    - equality operators (==, ===, !=, !==)\n    - relational operators (\u003c, \u003e, \u003c=, \u003e=)\n    - bitwise operators (\u0026, |, ^, ...)\n    - additive operators (+, -) and multiplication operators (*,/,%)\n    - shift operators (\u003c\u003c,\u003e\u003e,\u003e\u003e\u003e, ...)\n\n\n```javascript\nvar a = 0,\n    b = (i == j || j \u003e 5),\n    c = (j \u003c\u003c 2) \u0026 4,\n    d += 1,\n    e = a + d;\n```\n\n  - **DO NOT ADD** around:\n    - unary operators (!, -, +, ++, --)\n\n\n```javascript\nj++;\nbar = !foo;\n```\n\n### Before left brace\n  - **ADD** before:\n    - function\n    - 'if'\n    - 'else'\n    - 'for'\n    - 'while'\n    - 'do'\n    - 'switch'\n    - 'try'\n    - 'catch'\n    - 'finally'\n\n### Before keywords\n  - **ADD** before:\n    - 'else'\n    - 'while'\n    - 'catch'\n    - 'finally'\n\n\n```javascript\nvar foo = function () {\n  if (bar) {\n    try {\n      baz();\n    } catch (e) {\n      alert('Failure: ' + e.message);\n    } finally {\n      reset(a, i);\n    }\n  } else {\n    bazinga();\n  }\n}\n```\n\n### Within\n  - **DO NOT ADD** within:\n    - brackets\n    - object literal braces\n    - function call, function declaration, 'if', 'for', 'while', 'switch' or 'catch' parentheses\n\n### In ternary operators\n  - **ADD**\n    - before '?'\n    - after '?'\n    - before ':'\n    - after ':'\n\n\n```javascript\nvar c = j \u003e 5 ? 'GT 5' : 'LE 5';\n```\n\n\n### Other\n  - **ADD**\n    - after comma\n    - after property name-value separator (:)\n  - **DO NOT ADD**\n    - before comma\n    - before semicolon\n    - before property name-value separator (:)\n\n## Braces\nWe use **egyptian braces**. That means braces are **ALWAYS** placed at the **End of Line**\nAlso, braces are required in every block elements, even if they are oneliners ('if', 'while', 'do...while', 'try...catch...finally', etc...)\n\n## Wrapping\nWe use a soft wrap of 120 characters long. Also:\n  - Comments MAY wrap at right margin\n  - Function declaration arguments MAY wrap if long and aligned when multiline.\n  - Function call arguments MAY wrap if long and aligned when multiline.\n  - Object literals MUST ALWAYS BE chopped\n  - Multiple variable declaration MUST BE chopped and aligned (4 spaces, usually)\n\n\n```javascript\nfoo(a, b, c, d); // Line comment\n                 // which can be\n                 // wrapped if\n                 // long.\nfoo(a, b, c, d\n    e, f, g, h, i);\n\nfunction foo(a, b, c, d, bla,\n             ble, bli, blu) {\n\n}\n```\n\n---------------------------------------------------------------\n\n## Commit message convention\n\nWe use the [AngularJS Git Commit Msg Convention][8] because it enables us to:\n- automatically generate the changelog with pointers to the appropriate issues and commits\n- simple navigatie through the git history, focusing on important things while ignoring trivial changes\n\n\n### Format of the commit message:\n```bash\n\u003ctype\u003e(\u003cscope\u003e): \u003csubject\u003e\n\n\u003cbody\u003e\n\n\u003cfooter\u003e\n```\n\n\n### Message subject (first line)\nFirst line cannot be longer than 70 characters, second line is always blank and\nother lines should be wrapped at 80 characters. The type and scope should\nalways be lowercase as shown below.\n\n#### Allowed `\u003ctype\u003e` values:\n\n- **feat** (new feature for the user, not a new feature for build script)\n- **fix** (bug fix for the user, not a fix to a build script)\n- **docs** (changes to the documentation)\n- **style** (formatting, missing semi colons, etc; no production code change)\n- **refactor** (refactoring production code, eg. renaming a variable)\n- **test** (adding missing tests, refactoring tests; no production code change)\n- **chore** (updating grunt tasks etc; no production code change)\n\n#### Example `\u003cscope\u003e` values:\n\n- list-parser\n- loader\n- extension-registering\n- showdown-options\n- etc.\n\nThe `\u003cscope\u003e` can be empty (eg. if the change is a global or difficult\nto assign to a single component), in which case the parentheses are\nomitted.\n\n\n### Message body\n* uses the imperative, present tense: “change” not “changed” nor “changes”\n* includes motivation for the change and contrasts with previous behavior\n\nFor more info about message body, see:\n\n* http://365git.tumblr.com/post/3308646748/writing-git-commit-messages\n* http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html\n\n\n### Message footer\n\n#### Referencing issues\nClosed issues should be listed on a separate line in the footer prefixed with \"Closes\" keyword like this:\n```bash\nCloses #234\n```\nor in case of multiple issues:\n```bash\nCloses #123, #245, #992\n```\n#### Breaking changes\n\nAll breaking changes have to be mentioned in footer with the\ndescription of the change, justification and migration notes.\n```bash\nBREAKING CHANGE:\n\n`extension-registering` now is done throught a function call instead of assigning a property directly in the `showdown.extensions` object.\n\nTo migrate your extension, use the function showdown.registerExtension() instead.\n```\n\n### Further reading\nFor more information and examples, please read the [AngularJS Git Commit Msg Convention][8].\n\n---\n\n[1]: https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml\n[2]: https://github.com/showdownjs/code-style/blob/master/.editorconfig\n[3]: https://github.com/showdownjs/code-style/blob/master/.jshintrc\n[4]: https://github.com/showdownjs/code-style/blob/master/.jscs.json\n[5]: http://editorconfig.org/\n[6]: http://jshint.com/\n[7]: http://jscs.info/\n[8]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowdownjs%2Fcode-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshowdownjs%2Fcode-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowdownjs%2Fcode-style/lists"}