diff --git a/.eslintignore b/.eslintignore index 7e21e213d..306105960 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,6 @@ build/ -test/ example/ helpers/ +lib/platform-shims/esm.mjs +test/fixtures/**/** +example.mjs diff --git a/lib/platform-shims/browser.mjs b/lib/platform-shims/browser.mjs index 5740a0fec..5bba14653 100644 --- a/lib/platform-shims/browser.mjs +++ b/lib/platform-shims/browser.mjs @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ 'use strict'; import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'; // eslint-disable-line @@ -44,6 +45,7 @@ export default { // exit is noop browser: exit: () => {}, nextTick: cb => { + // eslint-disable-next-line no-undef window.setTimeout(cb, 1); }, stdColumns: 80, diff --git a/package.json b/package.json index 292c02905..ceeaca2d2 100644 --- a/package.json +++ b/package.json @@ -71,14 +71,13 @@ "rimraf": "^3.0.2", "rollup": "^2.23.0", "rollup-plugin-cleanup": "^3.1.1", - "standardx": "^7.0.0", "typescript": "^4.0.2", "which": "^2.0.0", "yargs-test-extends": "^1.0.1" }, "scripts": { "fix": "gts fix && npm run fix:js", - "fix:js": "standardx --fix **/*.mjs && standardx --fix **/*.cjs && standardx --fix ./*.mjs && standardx --fix ./*.cjs", + "fix:js": "eslint . --ext cjs --ext mjs --ext js --fix", "posttest": "npm run check", "test": "c8 mocha ./test/*.cjs --require ./test/before.cjs --timeout=12000 --check-leaks", "test:esm": "c8 mocha ./test/esm/*.mjs --check-leaks", @@ -90,7 +89,7 @@ "build:cjs": "rollup -c rollup.config.cjs", "postbuild:cjs": "rimraf ./build/index.cjs.d.ts", "check": "gts lint && npm run check:js", - "check:js": "standardx **/*.mjs && standardx **/*.cjs && standardx ./*.mjs && standardx ./*.cjs", + "check:js": "eslint . --ext cjs --ext mjs --ext js", "clean": "gts clean" }, "repository": { @@ -98,14 +97,6 @@ "url": "https://github.com/yargs/yargs.git" }, "homepage": "https://yargs.js.org/", - "standardx": { - "ignore": [ - "build", - "helpers", - "**/example/**", - "**/platform-shims/esm.mjs" - ] - }, "keywords": [ "argument", "args", diff --git a/test/command.cjs b/test/command.cjs index ab284f570..5a3c01269 100644 --- a/test/command.cjs +++ b/test/command.cjs @@ -1,5 +1,6 @@ -'use strict'; /* global describe, it, beforeEach */ +/* eslint-disable no-unused-vars */ +'use strict'; const yargs = require('../index.cjs'); const expect = require('chai').expect; const checkOutput = require('./helpers/utils.cjs').checkOutput; diff --git a/test/completion.cjs b/test/completion.cjs index cf52d299a..a37709d75 100644 --- a/test/completion.cjs +++ b/test/completion.cjs @@ -1,5 +1,6 @@ 'use strict'; /* global describe, it, before, beforeEach, after */ +/* eslint-disable no-unused-vars */ const checkUsage = require('./helpers/utils.cjs').checkOutput; const yargs = require('../index.cjs'); diff --git a/test/deno/platform-shim.test.ts b/test/deno/platform-shim.test.ts index aca9a3013..4ecb3c235 100644 --- a/test/deno/platform-shim.test.ts +++ b/test/deno/platform-shim.test.ts @@ -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'); +}); diff --git a/test/deno/yargs.test.ts b/test/deno/yargs.test.ts index 895b6f011..01264c747 100644 --- a/test/deno/yargs.test.ts +++ b/test/deno/yargs.test.ts @@ -2,43 +2,49 @@ import { assertEquals, - assertMatch -} from 'https://deno.land/std/testing/asserts.ts' -import yargs from '../../deno.ts' -import { Arguments } from '../../deno-types.ts' -import { commands } from '../esm/fixtures/commands/index.mjs' + assertMatch, +} from 'https://deno.land/std/testing/asserts.ts'; +import yargs from '../../deno.ts'; +import {Arguments} from '../../deno-types.ts'; +import {commands} from '../esm/fixtures/commands/index.mjs'; Deno.test('demandCommand(1) throw error if no command provided', () => { - let err: Error|null = null + let err: Error | null = null; yargs() .demandCommand(1) .parse(Deno.args, (_err: Error) => { - err = _err - }) - assertMatch(err!.message, /Not enough non-option/) -}) + err = _err; + }); + assertMatch(err!.message, /Not enough non-option/); +}); // TODO: we should think of a way to support this functionality Deno.test('guesses version # based on package.json', () => { - let output: string|null = null - yargs() - .parse('--version', (_err: Error, argv: Arguments, _output: string) => { - output = _output - }) - assertMatch('' + output, /[0-9]+\.[0-9]+\.[0-9]+/) -}) + let output: string | null = null; + yargs().parse( + '--version', + (_err: Error, argv: Arguments, _output: string) => { + output = _output; + } + ); + assertMatch('' + output, /[0-9]+\.[0-9]+\.[0-9]+/); +}); // Handling of strings that look like numbers, see: // https://github.com/yargs/yargs/issues/1758 -Deno.test('does not drop .0 if positional is configured as string', async () => { - const argv = await yargs(['cmd', '33.0']) - .command('cmd [str]', 'a command', (yargs: any) => { - return yargs.positional('str', { - type: 'string' +Deno.test( + 'does not drop .0 if positional is configured as string', + async () => { + const argv = (await yargs(['cmd', '33.0']) + .command('cmd [str]', 'a command', (yargs: any) => { + return yargs.positional('str', { + type: 'string', + }); }) - }).parse() as Arguments - assertEquals(argv.str, '33.0') -}) + .parse()) as Arguments; + assertEquals(argv.str, '33.0'); + } +); Deno.test('hierarchy of commands', async () => { const context = { @@ -46,4 +52,4 @@ Deno.test('hierarchy of commands', async () => { }; yargs().command(commands).parse('a c 10 5', context); assertEquals(context.output.value, 15); -}) +}); diff --git a/test/esm/fixtures/commands/a.mjs b/test/esm/fixtures/commands/a.mjs index 90fc41265..4f2a86fa4 100644 --- a/test/esm/fixtures/commands/a.mjs +++ b/test/esm/fixtures/commands/a.mjs @@ -5,4 +5,5 @@ export const describe = 'numeric commands'; export const builder = yargs => { yargs.command(commands); }; +// eslint-disable-next-line no-unused-vars export const handler = function (argv) {}; diff --git a/test/esm/fixtures/commands/subcommands/c.mjs b/test/esm/fixtures/commands/subcommands/c.mjs index 8085aeb95..3c6cc49da 100644 --- a/test/esm/fixtures/commands/subcommands/c.mjs +++ b/test/esm/fixtures/commands/subcommands/c.mjs @@ -1,5 +1,6 @@ export const command = 'c '; export const describe = 'add x to y'; +// eslint-disable-next-line no-unused-vars export const builder = yargs => {}; export const handler = function (argv) { argv.output.value = argv.x + argv.y; diff --git a/test/esm/fixtures/commands/subcommands/d.mjs b/test/esm/fixtures/commands/subcommands/d.mjs index 62c937dfe..4f4d456c4 100644 --- a/test/esm/fixtures/commands/subcommands/d.mjs +++ b/test/esm/fixtures/commands/subcommands/d.mjs @@ -1,5 +1,6 @@ export const command = 'd '; export const describe = 'multiply x by y'; +// eslint-disable-next-line no-unused-vars export const builder = yargs => {}; export const handler = function (argv) { argv.output.value = argv.x * argv.y; diff --git a/test/fixtures/bin.js b/test/fixtures/bin.js index 76889cb82..dfa0d62e0 100755 --- a/test/fixtures/bin.js +++ b/test/fixtures/bin.js @@ -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._)); diff --git a/test/fixtures/cmddir/deep/deeper/deeper_still/limbo.js b/test/fixtures/cmddir/deep/deeper/deeper_still/limbo.js index 9b8d0cc73..28ffad452 100644 --- a/test/fixtures/cmddir/deep/deeper/deeper_still/limbo.js +++ b/test/fixtures/cmddir/deep/deeper/deeper_still/limbo.js @@ -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; } diff --git a/test/fixtures/cmddir/deep/deeper/inception.js b/test/fixtures/cmddir/deep/deeper/inception.js index 4ee5e7423..6e4667b3e 100644 --- a/test/fixtures/cmddir/deep/deeper/inception.js +++ b/test/fixtures/cmddir/deep/deeper/inception.js @@ -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; } diff --git a/test/fixtures/cmddir/deep/within-a-dream.js b/test/fixtures/cmddir/deep/within-a-dream.js index b6d2f1942..7281d3c0a 100644 --- a/test/fixtures/cmddir/deep/within-a-dream.js +++ b/test/fixtures/cmddir/deep/within-a-dream.js @@ -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; } diff --git a/test/fixtures/cmddir/dream.js b/test/fixtures/cmddir/dream.js index d66cef6a4..1b058cc0b 100644 --- a/test/fixtures/cmddir/dream.js +++ b/test/fixtures/cmddir/dream.js @@ -1,31 +1,36 @@ -exports.command = 'dream [command] [opts]' -exports.desc = 'Go to sleep and dream' +/* eslint-disable no-undef */ +exports.command = 'dream [command] [opts]'; +exports.desc = 'Go to sleep and dream'; exports.builder = function (yargs) { return yargs .commandDir('deep', { - extensions: ['js', 'json'] + extensions: ['js', 'json'], }) .option('shared', { desc: 'Is the dream shared with others?', type: 'boolean', - global: true + global: true, }) .option('extract', { desc: 'Attempt extraction?', type: 'boolean', - global: true - }) -} + global: true, + }); +}; exports.handler = function (argv) { if (argv.extract) { - if (!argv.shared) throw new Error('Dream is not shared, there is no one to extract from!') - if (!chancesLevel1()) throw new Error('Extraction failed!') - if (!argv._msg) argv._msg = 'Extraction succesful' + if (!argv.shared) + throw new Error('Dream is not shared, there is no one to extract from!'); + if (!chancesLevel1()) throw new Error('Extraction failed!'); + if (!argv._msg) argv._msg = 'Extraction succesful'; } - if (argv._msg) console.log(argv._msg) - else console.log(argv.shared ? 'Training session over' : 'Well, that was a refreshing nap') -} + if (argv._msg) console.log(argv._msg); + else + console.log( + argv.shared ? 'Training session over' : 'Well, that was a refreshing nap' + ); +}; -function chancesLevel1 () { - return Math.floor(Math.random() * 10) < 9 +function chancesLevel1() { + return Math.floor(Math.random() * 10) < 9; } diff --git a/test/fixtures/cmddir_cyclic/cyclic.js b/test/fixtures/cmddir_cyclic/cyclic.js index b506260c2..479fc499d 100644 --- a/test/fixtures/cmddir_cyclic/cyclic.js +++ b/test/fixtures/cmddir_cyclic/cyclic.js @@ -1,6 +1,7 @@ -exports.command = 'cyclic' -exports.description = 'Attempts to (re)apply its own dir' +/* eslint-disable no-undef */ +exports.command = 'cyclic'; +exports.description = 'Attempts to (re)apply its own dir'; exports.builder = function (yargs) { - return yargs.commandDir('../cmddir_cyclic') -} -exports.handler = function (argv) {} + return yargs.commandDir('../cmddir_cyclic'); +}; +exports.handler = function () {}; diff --git a/test/fixtures/cmddir_noname/nameless.js b/test/fixtures/cmddir_noname/nameless.js index 6da3ae9a2..b2ae2ca6d 100644 --- a/test/fixtures/cmddir_noname/nameless.js +++ b/test/fixtures/cmddir_noname/nameless.js @@ -1,14 +1,15 @@ -exports.description = 'Command name derived from module filename' +/* eslint-disable no-undef */ +exports.description = 'Command name derived from module filename'; exports.builder = { banana: { - default: 'cool' + default: 'cool', }, batman: { - default: 'sad' - } -} + default: 'sad', + }, +}; exports.handler = function (argv) { - global.commandHandlerCalledWith = argv -} + global.commandHandlerCalledWith = argv; +}; diff --git a/test/fixtures/command-module.js b/test/fixtures/command-module.js index b43c84cf3..d79a9dc9d 100644 --- a/test/fixtures/command-module.js +++ b/test/fixtures/command-module.js @@ -1,17 +1,18 @@ -exports.command = 'blerg ' +/* eslint-disable no-undef */ +exports.command = 'blerg '; -exports.describe = 'handle blerg things' +exports.describe = 'handle blerg things'; exports.builder = function (yargs) { return yargs .option('banana', { - default: 'cool' + default: 'cool', }) .option('batman', { - default: 'sad' - }) -} + default: 'sad', + }); +}; exports.handler = function (argv) { - global.commandHandlerCalledWith = argv -} + global.commandHandlerCalledWith = argv; +}; diff --git a/test/fixtures/command.js b/test/fixtures/command.js index 92cf5255b..3aa83b7d4 100644 --- a/test/fixtures/command.js +++ b/test/fixtures/command.js @@ -1,12 +1,13 @@ +/* eslint-disable no-undef */ exports.builder = { banana: { - default: 'cool' + default: 'cool', }, batman: { - default: 'sad' - } -} + default: 'sad', + }, +}; exports.handler = function (argv) { - global.commandHandlerCalledWith = argv -} + global.commandHandlerCalledWith = argv; +}; diff --git a/test/fixtures/issue-497.js b/test/fixtures/issue-497.js index fbec4e4de..cdf053f00 100755 --- a/test/fixtures/issue-497.js +++ b/test/fixtures/issue-497.js @@ -1,19 +1,22 @@ #!/usr/bin/env node +/* eslint-disable node/shebang */ +/* eslint-disable no-undef */ // pretend we are a TTY -process.stdout.isTTY = true -process.stderr.isTTY = true +process.stdout.isTTY = true; +process.stderr.isTTY = true; -var yargs = require('../../') -var y = yargs.command('download ', 'make a get HTTP request') - .help() +const yargs = require('../../'); +const y = yargs + .command('download ', 'make a get HTTP request') + .help(); -for (var i = 0; i < 1000; i++) { +for (let i = 0; i < 1000; i++) { yargs.option('o' + i, { - describe: 'option ' + i - }) + describe: 'option ' + i, + }); } -y.parse() +y.parse(); -console.log('never get here') +console.log('never get here'); diff --git a/test/fixtures/no-require-main.js b/test/fixtures/no-require-main.js index 63b325735..ae5f902a0 100755 --- a/test/fixtures/no-require-main.js +++ b/test/fixtures/no-require-main.js @@ -1,13 +1,16 @@ #!/usr/bin/env node - -'use strict' +/* eslint-disable node/shebang */ +/* eslint-disable no-undef */ +'use strict'; // for some unknown reason, a test environment has decided to omit require.main -delete require.main +delete require.main; -var parser = require('../../')(process.argv.slice(2), undefined, require) +const parser = require('../../')(process.argv.slice(2), undefined, require); -console.log(parser.parserConfiguration({ - 'dot-notation': false, - 'boolean-negation': false -}).argv) +console.log( + parser.parserConfiguration({ + 'dot-notation': false, + 'boolean-negation': false, + }).argv +); diff --git a/test/fixtures/normal-bin.js b/test/fixtures/normal-bin.js index 426e50e3c..5b71b1a5d 100755 --- a/test/fixtures/normal-bin.js +++ b/test/fixtures/normal-bin.js @@ -1,10 +1,8 @@ #!/usr/bin/env node -var argv = require('../../') - .help('help') - .version() - .parserConfiguration({ - 'dot-notation': false, - 'boolean-negation': false - }) - .argv -console.log(argv) +/* eslint-disable no-undef */ +/* eslint-disable node/shebang */ +const argv = require('../../').help('help').version().parserConfiguration({ + 'dot-notation': false, + 'boolean-negation': false, +}).argv; +console.log(argv); diff --git a/test/fixtures/opt-assignment-and-positional-command-arg.js b/test/fixtures/opt-assignment-and-positional-command-arg.js index 7ded499df..9f78dc1b7 100755 --- a/test/fixtures/opt-assignment-and-positional-command-arg.js +++ b/test/fixtures/opt-assignment-and-positional-command-arg.js @@ -1,14 +1,18 @@ #!/usr/bin/env node +/* eslint-disable node/shebang */ +/* eslint-disable no-undef */ require('../../') .option('foo', { - nargs: 1 + nargs: 1, }) .command( 'bar ', 'example', - function (yargs) { return yargs }, - function (argv) { - console.log(JSON.stringify({ _: argv._, foo: argv.foo, baz: argv.baz })) + yargs => { + return yargs; + }, + argv => { + console.log(JSON.stringify({_: argv._, foo: argv.foo, baz: argv.baz})); } ) - .parse() + .parse(); diff --git a/test/fixtures/symlink-bin.js b/test/fixtures/symlink-bin.js index da53b4bba..2c97060bc 100755 --- a/test/fixtures/symlink-bin.js +++ b/test/fixtures/symlink-bin.js @@ -1,10 +1,11 @@ #!/usr/bin/env node -var argv = require('./yargs-symlink') +/* eslint-disable node/shebang */ +/* eslint-disable no-undef */ +const argv = require('./yargs-symlink') .help('help') .version() .parserConfiguration({ 'dot-notation': false, - 'boolean-negation': false - }) - .argv -console.log(argv) + 'boolean-negation': false, + }).argv; +console.log(argv); diff --git a/test/middleware.cjs b/test/middleware.cjs index 4efe10300..ed1074c81 100644 --- a/test/middleware.cjs +++ b/test/middleware.cjs @@ -1,5 +1,6 @@ 'use strict'; /* global describe, it, beforeEach, afterEach */ +/* eslint-disable no-unused-vars */ const {expect} = require('chai'); const {globalMiddlewareFactory} = require('../build/index.cjs'); @@ -524,9 +525,9 @@ describe('middleware', () => { argv.bar = 'hello'; return resolve(); }, 100); - }) + }); }, true) - .check((argv) => { + .check(argv => { if (argv.foo > 100) return true; else return false; }) @@ -538,11 +539,7 @@ describe('middleware', () => { it('applies middleware before performing validation, with explicit $0', async () => { const argvEventual = yargs('--foo 100') - .usage( - '$0', - 'usage', - () => {}, - ) + .usage('$0', 'usage', () => {}) .option('bar', { demand: true, }) @@ -553,9 +550,9 @@ describe('middleware', () => { argv.bar = 'hello'; return resolve(); }, 100); - }) + }); }, true) - .check((argv) => { + .check(argv => { if (argv.foo > 100) return true; else return false; }) @@ -599,12 +596,11 @@ describe('middleware', () => { }) .middleware(argv => { argv.foo = argv.foo * 2; - argv.bar = 'hello' + argv.bar = 'hello'; }, true) - .check((argv) => { + .check(argv => { if (argv.foo > 100) return true; else return false; - return true; }) .parse(); argv.foo.should.equal(200); @@ -615,11 +611,16 @@ describe('middleware', () => { // Refs: https://github.com/yargs/yargs/issues/1351 it('should run even if no command is matched', () => { const argv = yargs('snuh --foo 99') - .middleware(argv => { - argv.foo = argv.foo * 2; - }) - .command('bar', 'bar command', () => {}, () => {}) - .parse(); + .middleware(argv => { + argv.foo = argv.foo * 2; + }) + .command( + 'bar', + 'bar command', + () => {}, + () => {} + ) + .parse(); argv.foo.should.equal(198); }); }); diff --git a/test/usage.cjs b/test/usage.cjs index a2ae6a688..355455bbb 100644 --- a/test/usage.cjs +++ b/test/usage.cjs @@ -1,5 +1,6 @@ 'use strict'; /* global describe, it, beforeEach */ +/* eslint-disable no-unused-vars */ const checkUsage = require('./helpers/utils.cjs').checkOutput; const chalk = require('chalk'); diff --git a/test/validation.cjs b/test/validation.cjs index eaf9ab4e5..3db8d2835 100644 --- a/test/validation.cjs +++ b/test/validation.cjs @@ -1,5 +1,6 @@ 'use strict'; /* global describe, it, beforeEach */ +/* eslint-disable no-unused-vars */ const checkUsage = require('./helpers/utils.cjs').checkOutput; const expect = require('chai').expect; diff --git a/test/yargs.cjs b/test/yargs.cjs index bec35d5c3..e279ec425 100644 --- a/test/yargs.cjs +++ b/test/yargs.cjs @@ -1,5 +1,6 @@ 'use strict'; /* global context, describe, it, beforeEach, afterEach */ +/* eslint-disable no-unused-vars */ const expect = require('chai').expect; const fs = require('fs'); @@ -3067,15 +3068,11 @@ describe('yargs dsl tests', () => { }); // Refs: #1853 it('should use cached help message for nested synchronous commands', async () => { - const y = yargs('object').command( - 'object', - 'object command', - (yargs) => { - yargs.command('get', 'get command'); - } - ); + const y = yargs('object').command('object', 'object command', yargs => { + yargs.command('get', 'get command'); + }); const argv = y.argv; - const help = (await y.getHelp()); + const help = await y.getHelp(); help.should.match(/node object get/); argv._.should.eql(['object']); });