Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify/fix linting (#1867)
- Loading branch information
Showing
28 changed files
with
260 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
build/ | ||
test/ | ||
example/ | ||
helpers/ | ||
lib/platform-shims/esm.mjs | ||
test/fixtures/**/** | ||
example.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
/* global Deno */ | ||
|
||
import { | ||
assertEquals | ||
} from 'https://deno.land/std/testing/asserts.ts' | ||
import shim from '../../lib/platform-shims/deno.ts' | ||
import {assertEquals} from 'https://deno.land/std/testing/asserts.ts'; | ||
import shim from '../../lib/platform-shims/deno.ts'; | ||
|
||
// y18n. | ||
Deno.test('__ behaves like sprintf', () => { | ||
const str = shim.y18n.__('hello %s, goodnight %s', 'world', 'moon') | ||
assertEquals(str, 'hello world, goodnight moon') | ||
}) | ||
const str = shim.y18n.__('hello %s, goodnight %s', 'world', 'moon'); | ||
assertEquals(str, 'hello world, goodnight moon'); | ||
}); | ||
|
||
Deno.test('__n uses first string if singular', () => { | ||
const str = shim.y18n.__n('Missing required argument: %s', 'Missing required arguments: %s', 1, 'foo, bar') | ||
assertEquals(str, 'Missing required argument: foo, bar') | ||
}) | ||
const str = shim.y18n.__n( | ||
'Missing required argument: %s', | ||
'Missing required arguments: %s', | ||
1, | ||
'foo, bar' | ||
); | ||
assertEquals(str, 'Missing required argument: foo, bar'); | ||
}); | ||
|
||
Deno.test('__n uses second string if plural', () => { | ||
const str = shim.y18n.__n('Missing required argument: %s', 'Missing required arguments: %s', 2, 'foo, bar') | ||
assertEquals(str, 'Missing required arguments: foo, bar') | ||
}) | ||
const str = shim.y18n.__n( | ||
'Missing required argument: %s', | ||
'Missing required arguments: %s', | ||
2, | ||
'foo, bar' | ||
); | ||
assertEquals(str, 'Missing required arguments: foo, bar'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env node | ||
var argv = require('../../') | ||
.help('help') | ||
.completion() | ||
.argv | ||
console.log(JSON.stringify(argv._)) | ||
/* eslint-disable node/shebang */ | ||
// eslint-disable-next-line no-undef | ||
const argv = require('../../').help('help').completion().argv; | ||
console.log(JSON.stringify(argv._)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
exports.command = 'limbo [opts]' | ||
exports.desc = 'Get lost in pure subconscious' | ||
/* eslint-disable no-undef */ | ||
exports.command = 'limbo [opts]'; | ||
exports.desc = 'Get lost in pure subconscious'; | ||
exports.builder = { | ||
'with-self-exit': { | ||
desc: 'Pretty much your only way out', | ||
type: 'boolean' | ||
type: 'boolean', | ||
}, | ||
'with-totem': { | ||
desc: 'Take your totem with you', | ||
type: 'boolean' | ||
} | ||
} | ||
type: 'boolean', | ||
}, | ||
}; | ||
exports.handler = function (argv) { | ||
var factor = 3 | ||
if (!argv.withSelfExit) throw new Error('You entered limbo without a way out!') | ||
if (!argv.withTotem) factor -= 2 | ||
let factor = 3; | ||
if (!argv.withSelfExit) | ||
throw new Error('You entered limbo without a way out!'); | ||
if (!argv.withTotem) factor -= 2; | ||
if (argv.extract) { | ||
if (!chancesLevel4(factor)) throw new Error('You didn\'t have much chance anyway, you\'re stuck in limbo!') | ||
if (!argv._msg) argv._msg = 'You have accomplished the impossible. Inception successful.' | ||
return | ||
if (!chancesLevel4(factor)) | ||
throw new Error( | ||
"You didn't have much chance anyway, you're stuck in limbo!" | ||
); | ||
if (!argv._msg) | ||
argv._msg = 'You have accomplished the impossible. Inception successful.'; | ||
return; | ||
} | ||
if (!chancesLevel4(factor)) throw new Error('You rolled the dice and lost, you\'re stuck in limbo!') | ||
if (!argv._msg) argv._msg = 'Can you ever be sure of what\'s real anymore?' | ||
} | ||
if (!chancesLevel4(factor)) | ||
throw new Error("You rolled the dice and lost, you're stuck in limbo!"); | ||
if (!argv._msg) argv._msg = "Can you ever be sure of what's real anymore?"; | ||
}; | ||
|
||
function chancesLevel4 (factor) { | ||
return Math.floor(Math.random() * 10) < factor | ||
function chancesLevel4(factor) { | ||
return Math.floor(Math.random() * 10) < factor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,39 @@ | ||
exports.command = 'inception [command] [opts]' | ||
exports.desc = 'Enter another dream, where inception is possible' | ||
/* eslint-disable no-undef */ | ||
exports.command = 'inception [command] [opts]'; | ||
exports.desc = 'Enter another dream, where inception is possible'; | ||
exports.builder = function (yargs) { | ||
return yargs | ||
.commandDir('deeper_still') | ||
.option('with-sedation', { | ||
desc: 'Apply a sedative?', | ||
type: 'boolean', | ||
global: true | ||
global: true, | ||
}) | ||
.option('with-timed-kick', { | ||
desc: 'Plan an elaborate timed kick at each layer?', | ||
type: 'boolean', | ||
global: true | ||
}) | ||
} | ||
global: true, | ||
}); | ||
}; | ||
exports.handler = function (argv) { | ||
var factor = 5 | ||
let factor = 5; | ||
if (argv.extract) { | ||
if (!argv.withSedation) factor -= 1 | ||
if (!argv.withTimedKick) factor -= 1 | ||
if (!chancesLevel3(factor)) throw new Error('Something went wrong at level 3! Check your options for increased chance of success.') | ||
if (!argv._msg) argv._msg = 'You have narrowly escaped disaster. Inception successful.' | ||
return | ||
if (!argv.withSedation) factor -= 1; | ||
if (!argv.withTimedKick) factor -= 1; | ||
if (!chancesLevel3(factor)) | ||
throw new Error( | ||
'Something went wrong at level 3! Check your options for increased chance of success.' | ||
); | ||
if (!argv._msg) | ||
argv._msg = 'You have narrowly escaped disaster. Inception successful.'; | ||
return; | ||
} | ||
if (!chancesLevel3(factor)) throw new Error('You can no longer tell a dream from reality!') | ||
if (!argv._msg) argv._msg = 'Be very careful, you\'re starting to lose grip on reality.' | ||
} | ||
if (!chancesLevel3(factor)) | ||
throw new Error('You can no longer tell a dream from reality!'); | ||
if (!argv._msg) | ||
argv._msg = "Be very careful, you're starting to lose grip on reality."; | ||
}; | ||
|
||
function chancesLevel3 (factor) { | ||
return Math.floor(Math.random() * 10) < factor | ||
function chancesLevel3(factor) { | ||
return Math.floor(Math.random() * 10) < factor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
/* eslint-disable no-undef */ | ||
module.exports = { | ||
command: 'within-a-dream [command] [opts]', | ||
desc: 'Dream within a dream', | ||
builder: function (yargs) { | ||
return yargs | ||
.commandDir('deeper') | ||
.option('with-kick', { | ||
desc: 'Plan a kick for controlled wake up?', | ||
type: 'boolean', | ||
global: true | ||
}) | ||
return yargs.commandDir('deeper').option('with-kick', { | ||
desc: 'Plan a kick for controlled wake up?', | ||
type: 'boolean', | ||
global: true, | ||
}); | ||
}, | ||
handler: function (argv) { | ||
var factor = 7 | ||
if (argv.context) argv.context.counter++ // keep track of how many times we've invoked this handler. | ||
let factor = 7; | ||
if (argv.context) argv.context.counter++; // keep track of how many times we've invoked this handler. | ||
if (argv.extract) { | ||
if (!argv.withKick) factor -= 2 | ||
if (!chancesLevel2(factor)) throw new Error('Something went wrong at level 2! Check your options for increased chance of success.') | ||
if (!argv._msg) argv._msg = 'You got lucky this time. Extraction successful.' | ||
return | ||
if (!argv.withKick) factor -= 2; | ||
if (!chancesLevel2(factor)) | ||
throw new Error( | ||
'Something went wrong at level 2! Check your options for increased chance of success.' | ||
); | ||
if (!argv._msg) | ||
argv._msg = 'You got lucky this time. Extraction successful.'; | ||
return; | ||
} | ||
if (!argv._msg) argv._msg = 'Let\'s not make a habit of this.' | ||
} | ||
} | ||
if (!argv._msg) argv._msg = "Let's not make a habit of this."; | ||
}, | ||
}; | ||
|
||
function chancesLevel2 (factor) { | ||
return Math.floor(Math.random() * 10) < factor | ||
function chancesLevel2(factor) { | ||
return Math.floor(Math.random() * 10) < factor; | ||
} |
Oops, something went wrong.