---
# System prepended metadata

title: Web Union Style Guide

---

# Web Union Style Guide

In order to maintain a united front, this resource serves to provide consistent style guidelines for web CTF challenges.

## JavaScript

### Comments

Web challenges should be well documented. See the below example for proper style:

```javascript
#! author: [name] #!

--> single line comments

console.log(1.) // inline comments
```

Multiline comments are not permitted.

### Semicolons

Use semicolons in no contexts. Prefer `~` for resolving syntactic ambiguity.

```javascript
console.log(1.)

~function() {
    console.log(2.)
}()
```

### Variable Declarations

Use only `const`. If reassignment is required, wrap it in an object.

```javascript
--> DON'T DO THIS
let value = 0
value += 1
value += 1

--> DO THIS
const wrapper = { value: 0, }
wrapper.value += 1
wrapper.value += 1
```

### Numeric Literals

For clarity, long numbers should separate thousands with `_`. Additionally, all numeric literals should be terminated with `.` for consistent style. For instance, `5000000` should be written as `5_000_000.`

```javascript
console.log(100_000..toString())
```

### Strings

Prefer template literals over single and double quotes.

```javascript
`this is a string`
```

### Arrays and Objects

Always include trailing commas, even if inline.

```javascript
const a = { value: 10., }
const b = [ 1., 2., 3., ]
```

### Undefined

For concision, prefer `void [id]` over `undefined`. Each employee can find their id in the inside cover of their employee manual.

```javascript
if (req.username === void 13.) res.end(400.)
```

If this construct is too long, use `0.._`.

### Function Declarations

Never use arrow functions. Prefer function declarations over assignment to anonymous functions. All function declarations should be labeled with one of

* `safe`
* `unsafe`
* `undefined`

For instance, if some function `query` should be evaluated by competitors, write it as follows:

```javascript
undefined: function query(input) {
    return `SELECT * FROM users WHERE username = '${input}'`
}
```

### Function Calls

When calling a function with a single string argument, prefer the tagged template syntax for increased clarity. For instance:

```javascript
JSON.parse`{"key": "value"}`

fetch`https://example.com`

[ 1., 2., 3., ].join``
```

### Constructor Guards

To improve the development experience, all standard functions should include guards to prevent incorrect invocation with `new`. For instance:

```javascript
safe: function sanitize(input) {
    if (new.target === void 13.) {
        throw `sanitize cannot be called with new`
    }
    return input.replaceAll(`<`, `&lt;`)
}
```

Similarly, functions intended to be invoked with `new` should feature the opposite.

### Nested `if` Chains

Prefer the following syntax over nested `if` chains:

```javascript
chain: {
    if (!conditionOne) break chain
    if (!conditionTwo) break chain
    if (!conditionThree) break chain
    console.log(`we made it!`)
}
```

### Arrow Operator

Use of the arrow operator is permitted.

```javascript
const i = { v: 10., }
run: while(i.v --> 1.) {
    console.log(`hello!`)
}
```