18
19const postgresLocalUrlRegex = /^postgres:\/\/(?:([^:]+):([^@]+)@)?(?:localhost|127\.0\.0\.1)(:\d+)?\/([^?]+)/
20
21yargs(hideBin(process.argv))22 .demandCommand(1)23 .command(24 'up',25 'Start docker containers',26 () => {},27 async () => {28 if (process.env.DATABASE_URL && postgresLocalUrlRegex.test(process.env.DATABASE_URL)) {29 console.log("Starting docker...")30 await compose.upAll({31 config: dockerComposeFile,32 callback: (chunk) => console.log(chunk.toString()),33 })34 } else {35 console.log("Skipping docker start, DATABASE_URL is not set to a local address")36 }37 }38 )39 .command(40 'down',41 'Stop docker containers',42 () => {},43 async () => {44 try {45 await compose.ps({ config: dockerComposeFile })4647 await compose.downAll({48 config: dockerComposeFile,49 callback: (chunk) => console.log(chunk.toString()),50 })51 } catch (err) {52 if (err instanceof Error) {53 console.error(err.message)54 }55 }56 }57 ).argv
An unused expression that does not affect the state of the program indicates a logic error.
For example, if a programmer wants to increment the value of a variable a
by one, and intends to do so through this code:
let a = 0
a = a + 1
console.log(a) // output 1
But because of a typo, writes the following:
let a = 0
a + 1
console.log(a)
Here, the expression a + 1
does nothing meaningful in the program's runtime.
The expression is thus considered "unused" and should be removed.
0
if(0) 0
{0}
f(0), {}
a, b()
c = a, b;
a() && function namedFunctionInExpressionContext () {f();}
(function anIncompleteIIFE () {});
injectGlobal`body{ color: red; }`
{} // In this context, this is a block statement, not an object literal
{myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
function namedFunctionDeclaration () {}
(function aGenuineIIFE () {}());
f()
a = 0
new C
delete a.b
void a