function foo() {
// Some beautiful code
}
function foo()
{
// OMG! did you see?
// Curly bracket in new line!!!1
}
PURE EVIL
GOOD
if (foo) {
do_a();
} else
{
do_b();
do_c()
}
if ( bar ) do_d();
EVILEST THING EVER
if (foo) {
do_a();
} else {
do_b();
do_c();
}
if (bar) {
do_d();
}
GLORIOUSLY CONSISTENT
if ( foo )
{
do_a();
}
else
{
do_b();
do_c();
}
if ( bar )
{
do_d();
}
mmkay...
def foo(bar):
# Some beautiful code
def foo( bar ):
# Literally UNREADABLE
# Whitespace around the arguments!!
GOOD
PURE EVIL
if (1 == true) {
// Will this block be executed?
}
if (1 === true) {
// Now we got this!
// This block will never be executed
}
PURE EVIL
GOOD
def guide( name ):
print "Moses, I am " + name
print "Please guide me!"
$ flake8 moses.py
moses.py:1:9: E201 whitespace after '('
moses.py:1:13: E202 whitespace before ')'
flake8
if (money == true) {
console.log('This should never run')
}
$ eslint money.js
/Users/omegak/money.js
1:5 error 'money' is not defined no-undef
1:9 error Expected '===' and instead saw '==' eqeqeq
✖ 2 problems (2 errors, 0 warnings)
eslint
sass-lint
Alejandro Avilés