Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Standard eslint #13

Merged
merged 3 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"browser": true,
"jasmine": true,
"atomtest": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8,
"ecmaFeatures": {
"impliedStrict": true
}
"jasmine": true
},
"extends": [
"standard"
],
"globals": {
"atom": false
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",
"atom": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"extends": "eslint:recommended",
"rules": {
"quotes": "warn",
"semi": "error",
"indent": ["error", 2, { "SwitchCase": 1 }]
}
}
56 changes: 28 additions & 28 deletions lib/dialog.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
const { TextEditorView, View } = require("atom-space-pen-views");
const { TextEditorView, View } = require('atom-space-pen-views')

class Dialog extends View {
static content({prompt} = {}) {
this.div({class: "terminus-dialog"}, () => {
this.label(prompt, {class: "icon", outlet: "promptText"});
this.subview("miniEditor", new TextEditorView({mini: true}));
this.label("Escape (Esc) to exit", {style: "width: 50%;"});
this.label("Enter (\u21B5) to confirm", {style: "width: 50%; text-align: right;"});
});
static content ({ prompt } = {}) {
this.div({ class: 'terminus-dialog' }, () => {
this.label(prompt, { class: 'icon', outlet: 'promptText' })
this.subview('miniEditor', new TextEditorView({ mini: true }))
this.label('Escape (Esc) to exit', { style: 'width: 50%;' })
this.label('Enter (\u21B5) to confirm', { style: 'width: 50%; text-align: right;' })
})
}

initialize({iconClass, placeholderText, stayOpen} = {}) {
if (iconClass) { this.promptText.addClass(iconClass); }
initialize ({ iconClass, placeholderText, stayOpen } = {}) {
if (iconClass) { this.promptText.addClass(iconClass) }
atom.commands.add(this.element, {
"core:confirm": () => this.onConfirm(this.miniEditor.getText()),
"core:cancel": () => this.cancel()
});
'core:confirm': () => this.onConfirm(this.miniEditor.getText()),
'core:cancel': () => this.cancel()
})

if (!stayOpen) {
this.miniEditor.on("blur", () => this.close());
this.miniEditor.on('blur', () => this.close())
}

if (placeholderText) {
this.miniEditor.getModel().setText(placeholderText);
this.miniEditor.getModel().selectAll();
this.miniEditor.getModel().setText(placeholderText)
this.miniEditor.getModel().selectAll()
}
}

attach() {
this.panel = atom.workspace.addModalPanel({item: this.element});
this.miniEditor.focus();
this.miniEditor.getModel().scrollToCursorPosition();
attach () {
this.panel = atom.workspace.addModalPanel({ item: this.element })
this.miniEditor.focus()
this.miniEditor.getModel().scrollToCursorPosition()
}

close() {
const panelToDestroy = this.panel;
this.panel = null;
close () {
const panelToDestroy = this.panel
this.panel = null
if (panelToDestroy) {
panelToDestroy.destroy();
panelToDestroy.destroy()
}
atom.workspace.getActivePane().activate();
atom.workspace.getActivePane().activate()
}

cancel() {
this.close();
cancel () {
this.close()
}
}

module.exports = Dialog;
module.exports = Dialog
32 changes: 16 additions & 16 deletions lib/input-dialog.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
const Dialog = require("./dialog");
const os = require("os");
const Dialog = require('./dialog')
const os = require('os')

class InputDialog extends Dialog {
constructor(terminalView) {
constructor (terminalView) {
super({
prompt: "Insert Text",
iconClass: "icon-keyboard",
prompt: 'Insert Text',
iconClass: 'icon-keyboard',
stayOpen: true
});
})

this.terminalView = terminalView;
this.terminalView = terminalView
}

onConfirm(input) {
let eol;
if (atom.config.get("terminus.toggles.runInsertedText")) {
eol = os.EOL;
onConfirm (input) {
let eol
if (atom.config.get('terminus.toggles.runInsertedText')) {
eol = os.EOL
} else {
eol = "";
eol = ''
}

const data = `${input}${eol}`;
this.terminalView.input(data);
this.cancel();
const data = `${input}${eol}`
this.terminalView.input(data)
this.cancel()
}
}

module.exports = InputDialog;
module.exports = InputDialog
86 changes: 43 additions & 43 deletions lib/process.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
const pty = require("node-pty-prebuilt-multiarch");
const _ = require("underscore");
const child = require("child_process");
const pty = require('node-pty-prebuilt-multiarch')
const _ = require('underscore')
const child = require('child_process')

function getSystemLanguage() {
let language = "en_US.UTF-8";
if (process.platform === "darwin") {
function getSystemLanguage () {
let language = 'en_US.UTF-8'
if (process.platform === 'darwin') {
try {
const command = "plutil -convert json -o - ~/Library/Preferences/.GlobalPreferences.plist";
language = `${JSON.parse(child.execSync(command).toString()).AppleLocale}.UTF-8`;
const command = 'plutil -convert json -o - ~/Library/Preferences/.GlobalPreferences.plist'
language = `${JSON.parse(child.execSync(command).toString()).AppleLocale}.UTF-8`
} catch (error) {
// do nothing
}
}
return language;
return language
}
const systemLanguage = getSystemLanguage();
const systemLanguage = getSystemLanguage()

function getFilteredEnvironment() {
const env = _.omit(process.env, "ATOM_HOME", "ELECTRON_RUN_AS_NODE", "GOOGLE_API_KEY", "NODE_ENV", "NODE_PATH", "userAgent", "taskPath");
if (!env.LANG) { env.LANG = systemLanguage; }
env.TERM_PROGRAM = "terminus";
return env;
function getFilteredEnvironment () {
const env = _.omit(process.env, 'ATOM_HOME', 'ELECTRON_RUN_AS_NODE', 'GOOGLE_API_KEY', 'NODE_ENV', 'NODE_PATH', 'userAgent', 'taskPath')
if (!env.LANG) { env.LANG = systemLanguage }
env.TERM_PROGRAM = 'terminus'
return env
}
const filteredEnvironment = getFilteredEnvironment();
const filteredEnvironment = getFilteredEnvironment()

module.exports = function(pwd, shell, args, env) {
let ptyProcess;
const callback = this.async();
module.exports = function (pwd, shell, args, env) {
let ptyProcess
const callback = this.async()

if (shell) {
ptyProcess = pty.fork(shell, args, {
cwd: pwd,
env: _.extend(filteredEnvironment, env),
name: "xterm-256color"
});
name: 'xterm-256color'
})
} else {
ptyProcess = pty.open();
ptyProcess = pty.open()
}

const emitTitle = _.throttle(() => global.emit("terminus:title", ptyProcess.process), 500, true);
const emitTitle = _.throttle(() => global.emit('terminus:title', ptyProcess.process), 500, true)

ptyProcess.on("data", function(data) {
global.emit("terminus:data", data);
emitTitle();
});
ptyProcess.on('data', function (data) {
global.emit('terminus:data', data)
emitTitle()
})

ptyProcess.on("exit", function() {
global.emit("terminus:exit");
callback();
});
ptyProcess.on('exit', function () {
global.emit('terminus:exit')
callback()
})

return process.on("message", function({event, cols, rows, text}={}) {
return process.on('message', function ({ event, cols, rows, text } = {}) {
switch (event) {
case "resize": {
ptyProcess.resize(cols, rows);
break;
case 'resize': {
ptyProcess.resize(cols, rows)
break
}
case "input": {
ptyProcess.write(text);
break;
case 'input': {
ptyProcess.write(text)
break
}
case "pty": {
global.emit("terminus:pty", ptyProcess.pty);
break;
case 'pty': {
global.emit('terminus:pty', ptyProcess.pty)
break
}
}
});
};
})
}
20 changes: 10 additions & 10 deletions lib/rename-dialog.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const Dialog = require("./dialog");
const Dialog = require('./dialog')

class RenameDialog extends Dialog {
constructor(statusIcon) {
constructor (statusIcon) {
super({
prompt: "Rename",
iconClass: "icon-pencil",
prompt: 'Rename',
iconClass: 'icon-pencil',
placeholderText: statusIcon.getName()
});
})

this.statusIcon = statusIcon;
this.statusIcon = statusIcon
}

onConfirm(newTitle) {
this.statusIcon.updateName(newTitle.trim());
this.cancel();
onConfirm (newTitle) {
this.statusIcon.updateName(newTitle.trim())
this.cancel()
}
}

module.exports = RenameDialog;
module.exports = RenameDialog
Loading