Skip to content

Commit 835de5d

Browse files
committed
refactor: improve lint (madlabsinc#16)
1 parent 31a4653 commit 835de5d

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
},
1010
parserOptions: {
1111
sourceType: "module",
12-
ecmaVersion: "2017",
12+
ecmaVersion: "2018",
1313
allowImportExportEverywhere: false,
1414
ecmaFeatures: {
1515
globalReturn: false,
@@ -26,4 +26,4 @@ module.exports = {
2626
],
2727
eqeqeq: ['error', 'always'], // adding some custom ESLint rules
2828
},
29-
};
29+
};

bin/index.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,40 @@ const submitTask = require('../src/commands/submit');
1717
program.version(version).usage('<command> [options]');
1818

1919
program
20-
.command('init')
21-
.description('Initialize challenges')
22-
.action(initTasks);
20+
.command('init')
21+
.description('Initialize challenges')
22+
.action(initTasks);
2323

2424
program
25-
.command('submit')
26-
.description('Submits current task')
27-
.action(submitTask);
25+
.command('submit')
26+
.description('Submits current task')
27+
.action(submitTask);
2828

2929
program
30-
.command('fetchtask <key>')
31-
.description('Fetches any task as per the key supplied')
32-
.action(fetchTask);
30+
.command('fetchtask <key>')
31+
.description('Fetches any task as per the key supplied')
32+
.action(fetchTask);
3333

3434
program
35-
.command('showkeys')
36-
.description('Shows keys of all the completed tasks')
37-
.action(showKeys);
35+
.command('showkeys')
36+
.description('Shows keys of all the completed tasks')
37+
.action(showKeys);
3838

3939
program
40-
.command('showcommands')
41-
.description('Shows all commands available')
42-
.action(showCommands);
40+
.command('showcommands')
41+
.description('Shows all commands available')
42+
.action(showCommands);
4343

4444
// Validates any random command fired in
45-
program
46-
.arguments('<command>')
47-
.action((cmd) => {
48-
program.outputHelp();
49-
console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`));
50-
console.log();
45+
program.arguments('<command>').action(cmd => {
46+
program.outputHelp();
47+
console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`));
48+
console.log();
5149
});
5250

5351
program.parse(process.argv);
5452

5553
// Outputs help if no argument is provided
56-
if(!program.args.length){
57-
program.help();
54+
if (!program.args.length) {
55+
program.help();
5856
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"test": "mocha test/index.js",
1515
"docs:dev": "vuepress dev docs",
1616
"docs:build": "vuepress build docs",
17-
"lint": "eslint ./src",
18-
"lint:fix": "eslint --fix ./src"
17+
"lint": "eslint src bin",
18+
"lint:fix": "eslint --fix src bin"
1919
},
2020
"husky": {
2121
"hooks": {

src/commands/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515
initializeGHWorkFlow,
1616
} = require('../utils/github');
1717

18-
const validateInput = require('../utils/validate');
18+
const validate = require('../utils/validate');
1919

2020
// Key for the very first task
2121
let key = '5e06b81de9ac43218a974785ffce8146';
@@ -103,7 +103,7 @@ const initTasks = async () => {
103103
name: 'userName',
104104
type: 'input',
105105
message: "What's your name:-",
106-
validate: validateInput,
106+
validate,
107107
},
108108
]);
109109

src/commands/submit.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ const checkSolution = async (submittedFileContent, solutionFileContent) => {
7373
taskCount += 1;
7474
keys.push(generatedKey);
7575

76-
userConfig = Object.assign({}, userConfig, { taskCount, keys });
76+
userConfig = {
77+
...userConfig,
78+
taskCount,
79+
keys,
80+
};
7781
fs.writeFileSync('./config.json', JSON.stringify(userConfig));
7882

7983
await makeLocalCommit(taskCount);

src/utils/github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const shell = require('shelljs');
99

1010
const execAsync = promisify(shell.exec);
1111

12-
const validateInput = require('../utils/validate');
12+
const validate = require('../utils/validate');
1313

1414
// Global reference to the GitHub username.
1515
let GHUserName;
@@ -25,7 +25,7 @@ const initializeGHWorkFlow = async () => {
2525
name: 'userName',
2626
message: 'GitHub username:-',
2727
type: 'input',
28-
validate: validateInput,
28+
validate,
2929
});
3030

3131
// Holding global reference to the GitHub username.

0 commit comments

Comments
 (0)