Skip to content

Commit

Permalink
fix: eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 21, 2021
1 parent df42832 commit e5b807d
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions lib/code-context-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class CodeContextBuilder {
//
// returns a {CodeContext} object
buildCodeContext(editor, argType = 'Selection Based') {
if (!editor) return null;
if (!editor) {return null;}

const codeContext = this.initCodeContext(editor);

Expand All @@ -35,7 +35,7 @@ export default class CodeContextBuilder {
editor.save();
} else if (codeContext.selection.isEmpty() && codeContext.filepath) {
codeContext.argType = 'File Based';
if (editor && editor.isModified()) editor.save();
if (editor && editor.isModified()) {editor.save();}
}

// Selection and Line Number Based runs both benefit from knowing the current line
Expand Down Expand Up @@ -78,11 +78,11 @@ export default class CodeContextBuilder {
}

getShebang(editor) {
if (process.platform === 'win32') return null;
if (process.platform === 'win32') {return null;}
const text = editor.getText();
const lines = text.split('\n');
const firstLine = lines[0];
if (!firstLine.match(/^#!/)) return null;
if (!firstLine.match(/^#!/)) {return null;}

return firstLine.replace(/^#!\s*/, '');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/code-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class CodeContext {
// Returns the code selection {String}
getCode(prependNewlines = true) {
const code = this.textSource ? this.textSource.getText() : null;
if (!prependNewlines || !this.lineNumber) return code;
if (!prependNewlines || !this.lineNumber) {return code;}

const newlineCount = Number(this.lineNumber);
const newlines = Array(newlineCount).join('\n');
Expand All @@ -52,7 +52,7 @@ export default class CodeContext {
// Returns the {String} name of the command or {undefined} if not applicable.
shebangCommand() {
const sections = this.shebangSections();
if (!sections) return null;
if (!sections) {return null;}

return sections[0];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/command-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class CommandContext {
}

getRepresentation() {
if (!this.command || !this.args.length) return '';
if (!this.command || !this.args.length) {return '';}

// command arguments
const commandArgs = this.options.cmdArgs ? this.quoteArguments(this.options.cmdArgs).join(' ') : '';
Expand Down
2 changes: 1 addition & 1 deletion lib/grammar-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
// Public: Format args for cmd or bash, depending on the current OS
formatArgs(command) {
if (os.platform() === 'win32') {
return [`/c ${command.replace(/['"]/g, '')}`];
return [`/c ${command.replace(/["']/g, '')}`];
}
return ['-c', command];
},
Expand Down
4 changes: 2 additions & 2 deletions lib/grammar-utils/lisp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export default {
// Returns an {Array} of executable statements.
splitStatements(code) {
const iterator = (statements, currentCharacter) => {
if (!this.parenDepth) this.parenDepth = 0;
if (!this.parenDepth) {this.parenDepth = 0;}
if (currentCharacter === '(') {
this.parenDepth += 1;
this.inStatement = true;
} else if (currentCharacter === ')') {
this.parenDepth -= 1;
}

if (!this.statement) this.statement = '';
if (!this.statement) {this.statement = '';}
this.statement += currentCharacter;

if (this.parenDepth === 0 && this.inStatement) {
Expand Down
2 changes: 1 addition & 1 deletion lib/grammar-utils/nim.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
|| path.extname(name) === '.nimcgf'
|| path.extname(name) === '.cfg') {
const tfile = name.slice(0, -1);
if (fs.existsSync(tfile)) return path.basename(tfile);
if (fs.existsSync(tfile)) {return path.basename(tfile);}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/grammar-utils/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
//
// Returns the {String} filepath of the new file
createTempFileWithCode(code) {
if (!/^[\s]*<\?php/.test(code)) { code = `<?php ${code}`; }
if (!/^\s*<\?php/.test(code)) { code = `<?php ${code}`; }
return module.parent.exports.createTempFileWithCode(code);
},
};
6 changes: 3 additions & 3 deletions lib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Runtime {
// * "File Based"
// input (Optional) - {String} that'll be provided to the `stdin` of the new process
execute(argType = 'Selection Based', input = null, options = null) {
if (atom.config.get('script.stopOnRerun')) this.stop();
if (atom.config.get('script.stopOnRerun')) {this.stop();}
this.emitter.emit('start');

const codeContext = this.codeContextBuilder.buildCodeContext(
Expand All @@ -58,12 +58,12 @@ export default class Runtime {

// In the future we could handle a runner without the language being part
// of the grammar map, using the options runner
if (!codeContext || !codeContext.lang) return;
if (!codeContext || !codeContext.lang) {return;}

const executionOptions = !options ? this.scriptOptions : options;
const commandContext = CommandContext.build(this, executionOptions, codeContext);

if (!commandContext) return;
if (!commandContext) {return;}

if (commandContext.workingDirectory) {
executionOptions.workingDirectory = commandContext.workingDirectory;
Expand Down
2 changes: 1 addition & 1 deletion lib/script-input-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class ScriptInputView extends View {
}

destroy() {
if (this.subscriptions) this.subscriptions.dispose();
if (this.subscriptions) {this.subscriptions.dispose();}
this.panel.destroy();
}
}
8 changes: 4 additions & 4 deletions lib/script-options-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class ScriptOptionsView extends View {

// handling focus traversal and run on enter
this.find('atom-text-editor').on('keydown', (e) => {
if (e.keyCode !== 9 && e.keyCode !== 13) return true;
if (e.keyCode !== 9 && e.keyCode !== 13) {return true;}

switch (e.keyCode) {
case 9: {
Expand All @@ -82,7 +82,7 @@ export default class ScriptOptionsView extends View {

static splitArgs(argText) {
const text = argText.trim();
const argSubstringRegex = /([^'"\s]+)|((["'])(.*?)\3)/g;
const argSubstringRegex = /([^\s"']+)|((["'])(.*?)\3)/g;
const args = [];
let lastMatchEndPosition = -1;
let match = argSubstringRegex.exec(text);
Expand Down Expand Up @@ -137,7 +137,7 @@ export default class ScriptOptionsView extends View {
const inputView = new ScriptInputView({ caption: 'Enter profile name:' });
inputView.onCancel(() => this.show());
inputView.onConfirm((profileName) => {
if (!profileName) return;
if (!profileName) {return;}
_.forEach(this.find('atom-text-editor'), (editor) => {
editor.getModel().setText('');
});
Expand All @@ -157,7 +157,7 @@ export default class ScriptOptionsView extends View {
}

destroy() {
if (this.subscriptions) this.subscriptions.dispose();
if (this.subscriptions) {this.subscriptions.dispose();}
}

show() {
Expand Down
2 changes: 1 addition & 1 deletion lib/script-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class ScriptOptions {
//
// Returns an {Object} representation of the user specified environment.
getEnv() {
if (!this.env) return {};
if (!this.env) {return {};}

const mapping = {};

Expand Down
2 changes: 1 addition & 1 deletion lib/script-profile-run-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class ScriptProfileRunView extends SelectListView {
close() {}

destroy() {
if (this.subscriptions) this.subscriptions.dispose();
if (this.subscriptions) {this.subscriptions.dispose();}
}

run() {
Expand Down
2 changes: 1 addition & 1 deletion lib/view-runtime-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export default class ViewRuntimeObserver {
}

destroy() {
if (this.subscriptions) this.subscriptions.dispose();
if (this.subscriptions) {this.subscriptions.dispose();}
}
}
2 changes: 1 addition & 1 deletion spec/grammars-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('grammarMap', () => {
}));

describe('C++', () => it('returns the appropriate File Based runner on Mac OS X', () => {
if (process.platform === 'win32') return;
if (process.platform === 'win32') {return;}
OperatingSystem.platform = () => 'darwin';
this.reloadGrammar();

Expand Down

0 comments on commit e5b807d

Please sign in to comment.