Skip to content

Commit 247d2c4

Browse files
authored
style: update spacing to follow eslint (#412)
This commit enables the spacing checking rules in eslint, and also updates the code to follow said rules.
1 parent 1d3139f commit 247d2c4

34 files changed

+194
-201
lines changed

.eslintrc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"extends": "standard",
33
"rules": {
4-
"block-spacing": 0,
54
"brace-style": 0,
65
"comma-dangle": 0,
76
"indent": 0,
8-
"key-spacing": 0,
9-
"keyword-spacing": 0,
107
"no-duplicate-imports": 0,
118
"no-multiple-empty-lines": 0,
129
"no-path-concat": 0,
@@ -16,10 +13,6 @@
1613
"operator-linebreak": 0,
1714
"padded-blocks": 0,
1815
"quotes": 0,
19-
"semi-spacing": 0,
20-
"semi": 0,
21-
"space-before-blocks": 0,
22-
"space-before-function-paren": 0,
23-
"space-infix-ops": 0
16+
"semi": 0
2417
}
2518
}

src/cli/commitizen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export {
1313
* This is the main cli entry point.
1414
* environment may be used for debugging.
1515
*/
16-
function bootstrap(environment = {}) {
16+
function bootstrap (environment = {}) {
1717

1818
// Get cli args
1919
let rawGitArgs = process.argv.slice(2, process.argv.length);
@@ -29,7 +29,7 @@ function bootstrap(environment = {}) {
2929
console.log(`Attempting to initialize using the npm package ${adapterNpmName}`);
3030
try {
3131
init(sh, process.cwd(), adapterNpmName, parsedArgs);
32-
} catch(e) {
32+
} catch (e) {
3333
console.error(`Error: ${e}`);
3434
}
3535
} else {

src/cli/git-cz.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export {
1010
* This is the main cli entry point.
1111
* environment may be used for debugging.
1212
*/
13-
function bootstrap(environment = {}) {
13+
function bootstrap (environment = {}) {
1414

1515
// Get cli args
1616
let rawGitArgs = process.argv.slice(2, process.argv.length);
1717

1818
let adapterConfig = environment.config || configLoader.load();
1919

2020
// Choose a strategy based on the existance the adapter config
21-
if(typeof adapterConfig !== 'undefined') {
21+
if (typeof adapterConfig !== 'undefined') {
2222
// This tells commitizen we're in business
2323
useGitCzStrategy(rawGitArgs, environment, adapterConfig);
2424
} else {

src/cli/parsers/commitizen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
*
1212
* TODO: Aww shit this is ugly. Rewrite with mega leet tests plz, kthnx.
1313
*/
14-
function parse(rawGitArgs) {
14+
function parse (rawGitArgs) {
1515

1616
var args = minimist(rawGitArgs, {
1717
boolean: true

src/cli/parsers/git-cz.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
*
1212
* TODO: Aww shit this is ugly. Rewrite with mega leet tests plz, kthnx.
1313
*/
14-
function parse(rawGitArgs) {
14+
function parse (rawGitArgs) {
1515

1616
var args = minimist(rawGitArgs, {
1717
alias: {
@@ -49,7 +49,7 @@ function parse(rawGitArgs) {
4949
continue;
5050
} else if (isString(value)) {
5151
output += '-' + key + ' ' + value + ' ';
52-
} else if (isArray(value) && value.length>0) {
52+
} else if (isArray(value) && value.length > 0) {
5353
output += '-' + key + ' ' + value.join(' -' + key) + ' ';
5454
} else if (value === true || value === false) {
5555
output += '-' + key + ' ';
@@ -62,7 +62,7 @@ function parse(rawGitArgs) {
6262
}
6363
}
6464

65-
if(output.trim().length < 1) {
65+
if (output.trim().length < 1) {
6666
return '';
6767
} else {
6868
return output;

src/cli/strategies/git-cz.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ let { isClean } = staging;
1717

1818
export default gitCz;
1919

20-
function gitCz(rawGitArgs, environment, adapterConfig) {
20+
function gitCz (rawGitArgs, environment, adapterConfig) {
2121

2222
// See if any override conditions exist.
2323

2424
// In these very specific scenarios we may want to use a different
2525
// commit strategy than git-cz. For example, in the case of --amend
2626
let parsedCommitizenArgs = commitizenParser.parse(rawGitArgs);
2727

28-
if(parsedCommitizenArgs.a) {
28+
if (parsedCommitizenArgs.a) {
2929
// console.log('override -a in place');
3030
addPath(sh, process.cwd());
3131
}
3232

33-
if(parsedCommitizenArgs.amend) {
33+
if (parsedCommitizenArgs.amend) {
3434
// console.log('override --amend in place');
3535
gitStrategy.default(rawGitArgs, environment);
3636
return;
@@ -47,12 +47,12 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
4747
let resolvedAdapterRootPath = findRoot(resolvedAdapterConfigPath);
4848
let prompter = getPrompter(adapterConfig.path);
4949

50-
isClean(process.cwd(), function(error, stagingIsClean){
50+
isClean(process.cwd(), function (error, stagingIsClean) {
5151
if (error) {
5252
throw error;
5353
}
5454

55-
if(stagingIsClean) {
55+
if (stagingIsClean) {
5656
throw new Error('No files added to staging! Did you forget to run git add?');
5757
}
5858

@@ -66,7 +66,7 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
6666
emitData: true,
6767
quiet: false,
6868
retryLastCommit
69-
}, function(error) {
69+
}, function (error) {
7070
if (error) {
7171
throw error;
7272
}

src/cli/strategies/git.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export default git;
44

55
// We don't have a config, so either we use raw args to try to commit
66
// or if debug is enabled then we do a strict check for a config file.
7-
function git(rawGitArgs, environment) {
8-
if(environment.debug === true) {
7+
function git (rawGitArgs, environment) {
8+
if (environment.debug === true) {
99
console.error('COMMITIZEN DEBUG: No git-cz friendly config was detected. I looked for .czrc, .cz.json, or czConfig in package.json.');
1010
} else {
1111
var vanillaGitArgs = ["commit"].concat(rawGitArgs);

src/commitizen/adapter.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export {
3030
* Modifies the package.json, sets config.commitizen.path to the path of the adapter
3131
* Must be passed an absolute path to the cli's root
3232
*/
33-
function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
33+
function addPathToAdapterConfig (sh, cliPath, repoPath, adapterNpmName) {
3434

3535
let commitizenAdapterConfig = {
3636
config: {
@@ -46,7 +46,7 @@ function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
4646
let indent = detectIndent(packageJsonString).indent || ' ';
4747
let packageJsonContent = JSON.parse(packageJsonString);
4848
let newPackageJsonContent = '';
49-
if(_.get(packageJsonContent, 'config.commitizen.path') !== adapterNpmName) {
49+
if (_.get(packageJsonContent, 'config.commitizen.path') !== adapterNpmName) {
5050
newPackageJsonContent = _.merge(packageJsonContent, commitizenAdapterConfig);
5151
}
5252
fs.writeFileSync(packageJsonPath, JSON.stringify(newPackageJsonContent, null, indent) + '\n');
@@ -55,14 +55,14 @@ function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
5555
/**
5656
* Generates an npm install command given a map of strings and a package name
5757
*/
58-
function generateNpmInstallAdapterCommand(stringMappings, adapterNpmName) {
58+
function generateNpmInstallAdapterCommand (stringMappings, adapterNpmName) {
5959

6060
// Start with an initial npm install command
6161
let installAdapterCommand = `npm install ${adapterNpmName}`;
6262

6363
// Append the neccesary arguments to it based on user preferences
64-
for(let [key, value] of stringMappings.entries()) {
65-
if(value) {
64+
for (let [key, value] of stringMappings.entries()) {
65+
if (value) {
6666
installAdapterCommand = installAdapterCommand + ' ' + value;
6767
}
6868
}
@@ -73,15 +73,15 @@ function generateNpmInstallAdapterCommand(stringMappings, adapterNpmName) {
7373
/**
7474
* Gets the nearest npm_modules directory
7575
*/
76-
function getNearestNodeModulesDirectory(options) {
76+
function getNearestNodeModulesDirectory (options) {
7777

7878
// Get the nearest node_modules directories to the current working directory
7979
let nodeModulesDirectories = findNodeModules(options);
8080

8181
// Make sure we find a node_modules folder
8282

8383
/* istanbul ignore else */
84-
if(nodeModulesDirectories && nodeModulesDirectories.length > 0) {
84+
if (nodeModulesDirectories && nodeModulesDirectories.length > 0) {
8585
return nodeModulesDirectories[0];
8686
} else {
8787
console.error(`Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?`)
@@ -91,33 +91,33 @@ function getNearestNodeModulesDirectory(options) {
9191
/**
9292
* Gets the nearest project root directory
9393
*/
94-
function getNearestProjectRootDirectory(options) {
94+
function getNearestProjectRootDirectory (options) {
9595
return path.join(process.cwd(), getNearestNodeModulesDirectory(options), '/../');
9696
}
9797

9898
/**
9999
* Gets a map of arguments where the value is the corresponding npm strings
100100
*/
101-
function getNpmInstallStringMappings(save, saveDev, saveExact, force) {
101+
function getNpmInstallStringMappings (save, saveDev, saveExact, force) {
102102
return new Map()
103-
.set('save', (save && !saveDev) ? '--save':undefined)
104-
.set('saveDev', saveDev ? '--save-dev':undefined)
105-
.set('saveExact', saveExact ? '--save-exact':undefined)
106-
.set('force', force ? '--force':undefined);
103+
.set('save', (save && !saveDev) ? '--save' : undefined)
104+
.set('saveDev', saveDev ? '--save-dev' : undefined)
105+
.set('saveExact', saveExact ? '--save-exact' : undefined)
106+
.set('force', force ? '--force' : undefined);
107107
}
108108

109109
/**
110110
* Gets the prompter from an adapter given an adapter path
111111
*/
112-
function getPrompter(adapterPath) {
112+
function getPrompter (adapterPath) {
113113
// Resolve the adapter path
114114
let resolvedAdapterPath = resolveAdapterPath(adapterPath);
115115

116116
// Load the adapter
117117
let adapter = require(resolvedAdapterPath);
118118

119119
/* istanbul ignore next */
120-
if(adapter && adapter.prompter && isFunction(adapter.prompter)) {
120+
if (adapter && adapter.prompter && isFunction(adapter.prompter)) {
121121
return adapter.prompter;
122122
} else if (adapter && adapter.default && adapter.default.prompter && isFunction(adapter.default.prompter)) {
123123
return adapter.default.prompter;
@@ -130,7 +130,7 @@ function getPrompter(adapterPath) {
130130
* Given a resolvable module name or path, which can be a directory or file, will
131131
* return a located adapter path or will throw.
132132
*/
133-
function resolveAdapterPath(inboundAdapterPath) {
133+
function resolveAdapterPath (inboundAdapterPath) {
134134
// Check if inboundAdapterPath is a path or node module name
135135
let parsed = path.parse(inboundAdapterPath);
136136
let isPath = parsed.dir.length > 0 && parsed.dir.charAt(0) !== "@";
@@ -149,6 +149,6 @@ function resolveAdapterPath(inboundAdapterPath) {
149149
}
150150
}
151151

152-
function getGitRootPath() {
152+
function getGitRootPath () {
153153
return sh.exec('git rev-parse --show-toplevel').stdout.trim();
154154
}

src/commitizen/cache.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export {
1010
/**
1111
* Reads the entire cache
1212
*/
13-
function readCacheSync(cachePath) {
13+
function readCacheSync (cachePath) {
1414
return JSON.parse(fs.readFileSync(cachePath, 'utf8'));
1515
}
1616

1717
/**
1818
* Sets a cache value and writes the file to disk
1919
*/
20-
function setCacheValueSync(cachePath, key, value) {
20+
function setCacheValueSync (cachePath, key, value) {
2121
var originalCache;
2222
try {
2323
originalCache = readCacheSync(cachePath);
@@ -34,11 +34,11 @@ function setCacheValueSync(cachePath, key, value) {
3434
/**
3535
* Gets a single value from the cache given a key
3636
*/
37-
function getCacheValueSync(cachePath, repoPath) {
37+
function getCacheValueSync (cachePath, repoPath) {
3838
try {
3939
let cache = readCacheSync(cachePath);
4040
return cache[repoPath];
41-
} catch(e) {
41+
} catch (e) {
4242
return;
4343
}
4444
}

src/commitizen/commit.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ export default commit;
1111
/**
1212
* Takes all of the final inputs needed in order to make dispatch a git commit
1313
*/
14-
function dispatchGitCommit(sh, repoPath, template, options, overrideOptions, done) {
14+
function dispatchGitCommit (sh, repoPath, template, options, overrideOptions, done) {
1515
// Commit the user input -- side effect that we'll test
16-
gitCommit(sh, repoPath, template, { ...options, ...overrideOptions }, function(error) {
16+
gitCommit(sh, repoPath, template, { ...options, ...overrideOptions }, function (error) {
1717
done(error, template);
1818
});
1919
}
2020

2121
/**
2222
* Asynchronously commits files using commitizen
2323
*/
24-
function commit(sh, inquirer, repoPath, prompter, options, done) {
24+
function commit (sh, inquirer, repoPath, prompter, options, done) {
2525
var cacheDirectory = cacheDir('commitizen');
2626
var cachePath = path.join(cacheDirectory, 'commitizen.json');
2727

28-
ensureDir(cacheDirectory, function(error) {
28+
ensureDir(cacheDirectory, function (error) {
2929
if (error) {
3030
console.error("Couldn't create commitizen cache directory: ", error);
3131
// TODO: properly handle error?
3232
} else {
33-
if(options.retryLastCommit) {
33+
if (options.retryLastCommit) {
3434

3535
console.log('Retrying last commit attempt.');
3636

@@ -45,7 +45,7 @@ function commit(sh, inquirer, repoPath, prompter, options, done) {
4545

4646
} else {
4747
// Get user input -- side effect that is hard to test
48-
prompter(inquirer, function(error, template, overrideOptions) {
48+
prompter(inquirer, function (error, template, overrideOptions) {
4949
// Allow adapters to error out
5050
// (error: Error?, template: String, overrideOptions: Object)
5151
if (!(error instanceof Error)) {

src/commitizen/configLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export { load };
55
// Configuration sources in priority order.
66
var configs = ['package.json', '.czrc', '.cz.json'];
77

8-
function load(config, cwd) {
8+
function load (config, cwd) {
99
return loader(configs, config, cwd);
1010
}

0 commit comments

Comments
 (0)