Skip to content

Commit

Permalink
Improve code by eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ALONELUR committed Dec 15, 2021
1 parent a3af5a5 commit d7a48e2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
46 changes: 26 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "none"
}
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": 0
}
}
19 changes: 5 additions & 14 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { App, Editor, MarkdownView, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';

// Remember to rename these classes and interfaces!
const enum vimStatusForIm {
insert,
noInsert
}
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian';

interface VimImPluginSettings {
defaultIM: string;
Expand All @@ -26,9 +20,8 @@ const DEFAULT_SETTINGS: VimImPluginSettings = {

export default class VimImPlugin extends Plugin {
settings: VimImPluginSettings;
private currentVimStatus: vimStatusForIm = vimStatusForIm.noInsert;
private currentInsertIM: string = '';
private isWinPlatform: boolean = false;
private currentInsertIM = '';
private isWinPlatform = false;

async onload() {
await this.loadSettings();
Expand All @@ -42,7 +35,7 @@ export default class VimImPlugin extends Plugin {
// This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new SampleSettingTab(this.app, this));

var os = require('os');
const { os } = require('os');
this.isWinPlatform = os.type() == 'Windows_NT';

this.currentInsertIM = this.isWinPlatform ? this.settings.windowsDefaultIM : this.settings.defaultIM;
Expand All @@ -54,7 +47,7 @@ export default class VimImPlugin extends Plugin {

onVimModeChanged(modeObj: any) {
const { exec } = require('child_process');
var switchToInsert: string;
let switchToInsert: string;
if (this.currentInsertIM) {
switchToInsert = this.isWinPlatform ?
this.settings.windowsSwitchCmd.replace(/{im}/, this.currentInsertIM) :
Expand All @@ -70,7 +63,6 @@ export default class VimImPlugin extends Plugin {

switch (modeObj.mode) {
case "insert":
this.currentVimStatus = vimStatusForIm.insert;
console.log("change to insert");
if (typeof switchToInsert != 'undefined' && switchToInsert) {
exec(switchToInsert, (error: any, stdout: any, stderr: any) => {
Expand Down Expand Up @@ -107,7 +99,6 @@ export default class VimImPlugin extends Plugin {
});
}

this.currentVimStatus = vimStatusForIm.noInsert;
break;
}
// this.vimStatusBar.setText(this.currentVimStatus);
Expand Down

0 comments on commit d7a48e2

Please sign in to comment.