diff --git a/.eslintrc.js b/.eslintrc.js index 29bd7b9..f0dba7d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,7 @@ module.exports = { }, parserOptions: { sourceType: "module", - ecmaVersion: "2017", + ecmaVersion: "2018", allowImportExportEverywhere: false, ecmaFeatures: { globalReturn: false, @@ -26,4 +26,4 @@ module.exports = { ], eqeqeq: ['error', 'always'], // adding some custom ESLint rules }, - }; \ No newline at end of file + }; diff --git a/bin/index.js b/bin/index.js index 20ae0a8..ee669dd 100755 --- a/bin/index.js +++ b/bin/index.js @@ -17,42 +17,40 @@ const submitTask = require('../src/commands/submit'); program.version(version).usage(' [options]'); program -.command('init') -.description('Initialize challenges') -.action(initTasks); + .command('init') + .description('Initialize challenges') + .action(initTasks); program -.command('submit') -.description('Submits current task') -.action(submitTask); + .command('submit') + .description('Submits current task') + .action(submitTask); program -.command('fetchtask ') -.description('Fetches any task as per the key supplied') -.action(fetchTask); + .command('fetchtask ') + .description('Fetches any task as per the key supplied') + .action(fetchTask); program -.command('showkeys') -.description('Shows keys of all the completed tasks') -.action(showKeys); + .command('showkeys') + .description('Shows keys of all the completed tasks') + .action(showKeys); program -.command('showcommands') -.description('Shows all commands available') -.action(showCommands); + .command('showcommands') + .description('Shows all commands available') + .action(showCommands); // Validates any random command fired in -program - .arguments('') - .action((cmd) => { - program.outputHelp(); - console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)); - console.log(); +program.arguments('').action(cmd => { + program.outputHelp(); + console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)); + console.log(); }); program.parse(process.argv); // Outputs help if no argument is provided -if(!program.args.length){ - program.help(); +if (!program.args.length) { + program.help(); } diff --git a/package.json b/package.json index 1f6b0ca..35636a4 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "test": "mocha test/index.js", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", - "lint": "eslint ./src", - "lint:fix": "eslint --fix ./src" + "lint": "eslint src bin", + "lint:fix": "eslint --fix src bin" }, "husky": { "hooks": { diff --git a/src/commands/init.js b/src/commands/init.js index 70267eb..c88458c 100644 --- a/src/commands/init.js +++ b/src/commands/init.js @@ -15,7 +15,7 @@ const { initializeGHWorkFlow, } = require('../utils/github'); -const validateInput = require('../utils/validate'); +const validate = require('../utils/validate'); // Key for the very first task let key = '5e06b81de9ac43218a974785ffce8146'; @@ -103,7 +103,7 @@ const initTasks = async () => { name: 'userName', type: 'input', message: "What's your name:-", - validate: validateInput, + validate, }, ]); diff --git a/src/commands/submit.js b/src/commands/submit.js index 9b507d1..5e94b34 100644 --- a/src/commands/submit.js +++ b/src/commands/submit.js @@ -73,7 +73,11 @@ const checkSolution = async (submittedFileContent, solutionFileContent) => { taskCount += 1; keys.push(generatedKey); - userConfig = Object.assign({}, userConfig, { taskCount, keys }); + userConfig = { + ...userConfig, + taskCount, + keys, + }; fs.writeFileSync('./config.json', JSON.stringify(userConfig)); await makeLocalCommit(taskCount); diff --git a/src/utils/github.js b/src/utils/github.js index a7c62a4..c4c4daa 100644 --- a/src/utils/github.js +++ b/src/utils/github.js @@ -9,7 +9,7 @@ const shell = require('shelljs'); const execAsync = promisify(shell.exec); -const validateInput = require('../utils/validate'); +const validate = require('../utils/validate'); // Global reference to the GitHub username. let GHUserName; @@ -25,7 +25,7 @@ const initializeGHWorkFlow = async () => { name: 'userName', message: 'GitHub username:-', type: 'input', - validate: validateInput, + validate, }); // Holding global reference to the GitHub username.