Skip to content

Commit

Permalink
Merge pull request #18 from m-sureshraj/linting-improvements
Browse files Browse the repository at this point in the history
fix: Linting improvements
  • Loading branch information
m-sureshraj authored Sep 14, 2019
2 parents 5377a29 + c116a9a commit 1efc128
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# /node_modules/* in the project root are ignored by default

!.*.js
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module.exports = {
parserOptions: {
ecmaVersion: 2018
ecmaVersion: 2018,
},
env: {
node: true,
es6: true
es6: true,
},
extends: 'eslint:recommended',
plugins: ['prettier'],
// 0: off, 1: warn, 2: error
rules: {
'prettier/prettier': 'error',
'no-console': 'off'
}
'no-console': 'off',
},
};
14 changes: 7 additions & 7 deletions lib/build-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ const { yellow, blue, red, green, magenta } = require('kleur');
module.exports = {
FAILED: {
icon: red(figures.cross),
label: red('Failed')
label: red('Failed'),
},
SUCCESS: {
icon: green(figures.tick),
label: green('Success')
label: green('Success'),
},
ABORTED: {
icon: yellow(figures.warning),
label: yellow('Aborted')
label: yellow('Aborted'),
},
IN_PROGRESS: {
icon: blue(figures.play),
label: blue('In Progress')
label: blue('In Progress'),
},
NOT_EXECUTED: {
icon: magenta(figures.checkboxOn),
label: magenta('Not executed')
label: magenta('Not executed'),
},
UNSTABLE: {
icon: yellow(figures.checkboxOff),
label: yellow('Unstable')
}
label: yellow('Unstable'),
},
};
10 changes: 5 additions & 5 deletions lib/cli-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ exports.printBuildHistory = function(builds = []) {
colAligns: ['middle'],
style: {
head: ['cyan'],
compact: true
}
compact: true,
},
});
let status = null;

Expand All @@ -48,7 +48,7 @@ exports.printBuildHistory = function(builds = []) {
build.name,
status.label,
printBuildStartedTime(build),
printBuildDuration(build)
printBuildDuration(build),
]);
});

Expand All @@ -58,8 +58,8 @@ exports.printBuildHistory = function(builds = []) {
exports.printConfig = function(config) {
const table = new Table({
style: {
head: ['cyan']
}
head: ['cyan'],
},
});

table.push(
Expand Down
6 changes: 3 additions & 3 deletions lib/git-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { removeNewLine } = require('./util');

exports.getCurrentBranchName = function() {
const { stdout, stderr } = spawnSync('git', ['symbolic-ref', 'HEAD'], {
encoding: 'utf8'
encoding: 'utf8',
});

if (stderr) throw new Error(stderr);
Expand All @@ -13,7 +13,7 @@ exports.getCurrentBranchName = function() {

exports.isGitRepository = function() {
const { stdout } = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], {
encoding: 'utf8'
encoding: 'utf8',
});

// error scenario `stderr` will be handled by the application
Expand All @@ -22,7 +22,7 @@ exports.isGitRepository = function() {

exports.getGitRootDirPath = function() {
const { stdout, stderr } = spawnSync('git', ['rev-parse', '--show-toplevel'], {
encoding: 'utf8'
encoding: 'utf8',
});

if (stderr) throw new Error(stderr);
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function mapBuild(build) {
durationMillis: build.durationMillis,
startTimeMillis: build.startTimeMillis,
endTimeMillis: build.endTimeMillis,
__meta__: build.__meta__
__meta__: build.__meta__,
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ function logNetworkErrors(err) {

module.exports = {
debug,
logNetworkErrors
logNetworkErrors,
};
12 changes: 6 additions & 6 deletions lib/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getBaseJobQuestionConfig() {
},
name: 'job',
message: 'Select current repo base job', // fixme - better message
choices: () => baseJobs
choices: () => baseJobs,
};
}

Expand All @@ -44,14 +44,14 @@ exports.requestJenkinsCredentials = function() {
name: 'username',
message: 'Jenkins username',
validate: val => val.trim() !== '',
format: val => val.trim()
format: val => val.trim(),
},
{
type: 'text',
name: 'token',
message: 'Jenkins api-token',
validate: val => val.trim() !== '',
format: val => val.trim()
format: val => val.trim(),
},
{
type: 'text',
Expand All @@ -66,9 +66,9 @@ exports.requestJenkinsCredentials = function() {
}

return val;
}
},
},
getBaseJobQuestionConfig()
getBaseJobQuestionConfig(),
];

// todo: show banner message about jenkins credentials
Expand All @@ -81,7 +81,7 @@ exports.askConfirmation = function() {
type: 'confirm',
name: 'confirmation',
message: 'Are you sure you want to save this configuration?',
initial: true
initial: true,
};

return prompts(question);
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const months = [
'Sep',
'Oct',
'Nov',
'Dec'
'Dec',
];

exports.removeNewLine = function(str) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"lint-staged": {
"**/*.js": [
"*.js": [
"npm run lint-fix",
"git add"
]
Expand Down
4 changes: 2 additions & 2 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
printWidth: 90,
trailingComma: 'none',
trailingComma: 'es5',
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
bracketSpacing: true,
arrowParens: 'avoid',
endOfLine: 'lf'
endOfLine: 'lf',
};
2 changes: 1 addition & 1 deletion src/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = async function config(options = {}) {
...(username && { username }),
...(token && { token }),
...(url && { url }),
...(job && { job })
...(job && { job }),
};

// if options passed update configuration
Expand Down
2 changes: 1 addition & 1 deletion src/commands/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Conf = require('conf');
const {
isGitRepository,
getGitRootDirPath,
getCurrentBranchName
getCurrentBranchName,
} = require('../../lib/git-cmd');
const { getBranchJobLink } = require('../../lib/jenkins');
const { debug } = require('../../lib/log');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const terminalLink = require('terminal-link');
const {
getCurrentBranchName,
isGitRepository,
getGitRootDirPath
getGitRootDirPath,
} = require('../../lib/git-cmd');
const { getBranchBuildHistory, getBranchJobLink } = require('../../lib/jenkins');
const { printBuildHistory } = require('../../lib/cli-table');
Expand Down

0 comments on commit 1efc128

Please sign in to comment.