Skip to content

Adding multiple ESLint rules for spacing

I write code without spaces so this has the following series of ESLint rules [skip eslint] to ensure things are properly formatted in a uniform style:

space-infix-ops

Before:

let cheesecake==true;

After:

let cheesecake == true;

semi-spacing

Before:

for (let rabbit = 0;rabbit < 3;rabbit++)

After:

for (let rabbit = 0; rabbit < 3; rabbit++)

space-before-blocks

Before:

function macarons(){ ... }

After:

function macarons() { ... }

keyword-spacing

Before:

catch(rabbit) { // No space before (rabbit), space after was from 'space-before-blocks'
    logError(rabbit);
} finally{ // No space before
    riverbank.quit();
}

After:

catch (rabbit) { // Space before and after (rabbit)
    logError(rabbit);
} finally { // Space after
    riverbank.quit();
}

comma-spacing

Before:

function cute_things(rabbits,cheesecake,gnome) { ... }

After:

function cute_things(rabbits, cheesecake, gnome) { ... }

brace-style

Before (Stroustrup):

catch (height) {
    logError(height);
}
finally {
    wonderland.quit();
}

After (one true brace style):

catch (height) {
    logError(height);
} finally {
    wonderland.quit();
}
Edited by Avi

Merge request reports