Guidelines - Stations-Project/START-HERE GitHub Wiki

Repositories

Creating

  • If a Template Repository for your language/framework exists, use it.
  • Otherwise, use the general "Template" repository.

Next steps

  1. Make a plan
  2. Create an issue for every task to work on
  3. Post your progress in the issue (does not replace commits!)

Contributing

Contributions are welcome, but before you contribute:

  1. Check the repository issues (maybe someone else is already on it)
  2. Create a new issue and wait for feedback

Commits

Provide short, descriptive commit messages, such as:

edit readme file
fix typo in index.ts
can now parse file contents

Style

Always follow the naming conventions of your programming language or framework. Here are some additional rules:

Basics

  • Function names should contain a verb
    • create_item() instead of new_item() or item()
  • Variable names should be sufficiently descriptive
    • new_token instead of tkn
    • 'pswd' is ok
  • Booleans should start with verbs
    • is_correct instead of correct
    • was_successful instead of succeeded
    • has_failed instead of failed

Comments

  • Use comments for structure and explanation where necessary
  • Comment on complex lines

Comment types

  • Code Section: inline, uppercase, leading whitespace: // CODE SECTION
    • Large section in your code, usually grouping multiple functions
    • e.g. "IMPORTS", "MAIN" or "HELPERS"
  • Code block: multiline if available, lowercase, padding whitespaces /* code block */
    • Block of your code that does one specific thing
    • e.g. "get user information"
  • Line Description: inline, lowercase, no whitespace //line description
    • Describes a complex line

Node

  • Always use TypeScript
  • Always define a main function (readability)

Style Example (logically bad good code):

//--snip--

// HELPERS
function getUserInfo(username: string) {
    /* get user information */
    const displayName = getDisplayName(username);
    const permaKey = getPermaKey(username)

    /* return */
    //create object from data
    const responseObject = Object.create({ username, displayName, permaKey })
    return responseObject;
}

Full Example

// IMPORTS
import StationSDK from "path/to/module";

// MAIN
async function main(allArguments: string[]) {
    const [ username, subcommand, ...args ] = allArguments;

    switch (subcommand) {
        case 'my-command': return myCommand(username, args[0]);
        default: throw 'no-subcommand';
    }
}

// SUBCOMMANDS
function myCommand(executingUsername: string, myArgument: string) {
    //--snip--
}

// INIT
/* call main function */
//remove first two arguments
process.argv.splice(0, 2);
main(process.argv);