Skip to content

Development Guide

Lee Yi edited this page Jan 18, 2023 · 12 revisions

This section contains information on creating a Source Module. Please read through this section thoroughly to get a better understanding of the Source Modules system and how to create your own Source Module.

Table of Contents

Scripts

This subsection of the page contains information about all the scripts used currently in the Source Modules project. To run a script, at the root directory of your copy of the Source Modules code repository on your local development machine, run the following command in your favourite shell's command-line interface.

yarn run <script>
Script Description
build Transpile modules' files from src folder to build folder as well as generates API documentation.
build:docs Generates the Source Modules' API documentation.
build:modules Transpile modules' files from src folder to build folder.
create Run the module generator command-line app to create a new Source Module bundle or tab.
lint Check code for errors.
lint:fix Check and automatically fix code errors.
test Run all unit tests once.
test:watch Run all unit tests, watch files for changes and rerun tests related to changed files.

Coding Standards

As with the other Source Academy code repositories, we practice KISS and DRY within the code repository. In addition to that, we practice additional constraints to keep the code base consistent. These constraints will be automatically identified and highlighted to the developer when the lint script is executed.

For VSCode users, we recommend that you install and use the ESLint VSCode extension here as it will help to highlight code that do not conform to the ESLint rules in real time, eliminating the need to execute yarn run lint regularly.

In the Source Modules project, we have opted to use Airbnb's JavaScript code linting rules that were converted to support TypeScript. This is because the linting rules by Airbnb is one of the most commonnly used around, and it bills itself as "a mostly reasonable approach to JavaScript". And their linting rules are popular because they are simple, sensible, and beautifully consistent. An exhaustive list of the enforced rules and their explanations can be found here.

Clone this wiki locally