fix: lint
This commit is contained in:
parent
6c197e4309
commit
b2d3b0c410
8 changed files with 5914 additions and 4195 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -19,4 +19,3 @@ test/
|
||||||
.vscode-test/
|
.vscode-test/
|
||||||
dist/
|
dist/
|
||||||
typings/
|
typings/
|
||||||
package-lock.json
|
|
||||||
|
|
5880
package-lock.json
generated
Normal file
5880
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
31
package.json
31
package.json
|
@ -194,31 +194,26 @@
|
||||||
"register-scheme": "devsnek/node-register-scheme"
|
"register-scheme": "devsnek/node-register-scheme"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^13.13.0",
|
"@types/node": "^14.0.5",
|
||||||
"@types/vscode": "^1.44.0",
|
"@types/vscode": "^1.45.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.28.0",
|
"@typescript-eslint/eslint-plugin": "^3.0.0",
|
||||||
"@typescript-eslint/parser": "^2.28.0",
|
"@typescript-eslint/parser": "^3.0.0",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"eslint": "^7.0.0",
|
"eslint": "^7.1.0",
|
||||||
"eslint-config-marine": "^6.0.0",
|
"eslint-config-marine": "^7.1.2",
|
||||||
"eslint-config-prettier": "^6.10.1",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"prettier": "^2.0.4",
|
"prettier": "^2.0.5",
|
||||||
"terser-webpack-plugin": "^3.0.0",
|
"terser-webpack-plugin": "^3.0.1",
|
||||||
"ts-loader": "^7.0.1",
|
"ts-loader": "^7.0.4",
|
||||||
"typescript": "^3.8.3",
|
"typescript": "^3.9.3",
|
||||||
"webpack": "^4.42.1",
|
"webpack": "^4.43.0",
|
||||||
"webpack-cli": "^3.3.11"
|
"webpack-cli": "^3.3.11"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.44.0"
|
"vscode": "^1.45.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": "marine/prettier/node"
|
"extends": "marine/prettier/node"
|
||||||
},
|
|
||||||
"renovate": {
|
|
||||||
"extends": [
|
|
||||||
"teal"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4156
pnpm-lock.yaml
4156
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@ import Activity from '../structures/Activity';
|
||||||
import Logger from '../structures/Logger';
|
import Logger from '../structures/Logger';
|
||||||
import { API } from '../git';
|
import { API } from '../git';
|
||||||
|
|
||||||
let activityTimer: NodeJS.Timer;
|
let activityTimer: NodeJS.Timer | undefined;
|
||||||
|
|
||||||
export default class RPCClient implements Disposable {
|
export default class RPCClient implements Disposable {
|
||||||
public statusBarIcon: StatusBarItem;
|
public statusBarIcon: StatusBarItem;
|
||||||
|
@ -77,9 +77,9 @@ export default class RPCClient implements Disposable {
|
||||||
if (activityTimer) clearInterval(activityTimer);
|
if (activityTimer) clearInterval(activityTimer);
|
||||||
await this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
await this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
||||||
|
|
||||||
activityTimer = setInterval(async () => {
|
activityTimer = setInterval(() => {
|
||||||
this.config = workspace.getConfiguration('discord');
|
this.config = workspace.getConfiguration('discord');
|
||||||
await this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
void this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
this._rpc.subscribe('ACTIVITY_SPECTATE', async ({ secret }: { secret: string }) => {
|
this._rpc.subscribe('ACTIVITY_SPECTATE', async ({ secret }: { secret: string }) => {
|
||||||
|
@ -166,6 +166,6 @@ export default class RPCClient implements Disposable {
|
||||||
this._rpc = null;
|
this._rpc = null;
|
||||||
this.statusBarIcon.tooltip = '';
|
this.statusBarIcon.tooltip = '';
|
||||||
|
|
||||||
clearInterval(activityTimer);
|
if (activityTimer) clearInterval(activityTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Logger from './structures/Logger';
|
||||||
import { GitExtension } from './git';
|
import { GitExtension } from './git';
|
||||||
const { register } = require('discord-rpc'); // eslint-disable-line
|
const { register } = require('discord-rpc'); // eslint-disable-line
|
||||||
|
|
||||||
let loginTimeout: NodeJS.Timer;
|
let loginTimeout: NodeJS.Timer | undefined;
|
||||||
|
|
||||||
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||||
statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||||
|
@ -32,28 +32,28 @@ export async function activate(context: ExtensionContext) {
|
||||||
|
|
||||||
const enabler = commands.registerCommand('discord.enable', async () => {
|
const enabler = commands.registerCommand('discord.enable', async () => {
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
config.update('enabled', true);
|
void config.update('enabled', true);
|
||||||
rpc.config = workspace.getConfiguration('discord');
|
rpc.config = workspace.getConfiguration('discord');
|
||||||
rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||||
rpc.statusBarIcon.show();
|
rpc.statusBarIcon.show();
|
||||||
await rpc.login();
|
await rpc.login();
|
||||||
window.showInformationMessage('Enabled Discord Rich Presence for this workspace.');
|
void window.showInformationMessage('Enabled Discord Rich Presence for this workspace.');
|
||||||
});
|
});
|
||||||
|
|
||||||
const disabler = commands.registerCommand('discord.disable', async () => {
|
const disabler = commands.registerCommand('discord.disable', async () => {
|
||||||
config.update('enabled', false);
|
void config.update('enabled', false);
|
||||||
rpc.config = workspace.getConfiguration('discord');
|
rpc.config = workspace.getConfiguration('discord');
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
rpc.statusBarIcon.hide();
|
rpc.statusBarIcon.hide();
|
||||||
window.showInformationMessage('Disabled Discord Rich Presence for this workspace.');
|
void window.showInformationMessage('Disabled Discord Rich Presence for this workspace.');
|
||||||
});
|
});
|
||||||
|
|
||||||
const reconnecter = commands.registerCommand('discord.reconnect', async () => {
|
const reconnecter = commands.registerCommand('discord.reconnect', async () => {
|
||||||
if (loginTimeout) clearTimeout(loginTimeout);
|
if (loginTimeout) clearTimeout(loginTimeout);
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
loginTimeout = setTimeout(async () => {
|
loginTimeout = setTimeout(() => {
|
||||||
await rpc.login();
|
void rpc.login();
|
||||||
if (!config.get('silent')) window.showInformationMessage('Reconnecting to Discord RPC...');
|
if (!config.get('silent')) void window.showInformationMessage('Reconnecting to Discord RPC...');
|
||||||
rpc.statusBarIcon.text = '$(pulse) Reconnecting to Discord...';
|
rpc.statusBarIcon.text = '$(pulse) Reconnecting to Discord...';
|
||||||
rpc.statusBarIcon.command = 'discord.reconnect';
|
rpc.statusBarIcon.command = 'discord.reconnect';
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -106,11 +106,11 @@ export async function activate(context: ExtensionContext) {
|
||||||
try {
|
try {
|
||||||
await rpc.login();
|
await rpc.login();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.log(`Encountered following error after trying to login:\n${error}`);
|
Logger.log(`Encountered following error after trying to login:\n${error as string}`);
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
if (!config.get('silent')) {
|
if (!config.get('silent')) {
|
||||||
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
|
if (error.message.includes('ENOENT')) void window.showErrorMessage('No Discord Client detected!');
|
||||||
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.toString()}`);
|
else void window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error as string}`);
|
||||||
}
|
}
|
||||||
rpc.statusBarIcon.text = '$(pulse) Reconnect to Discord';
|
rpc.statusBarIcon.text = '$(pulse) Reconnect to Discord';
|
||||||
rpc.statusBarIcon.command = 'discord.reconnect';
|
rpc.statusBarIcon.command = 'discord.reconnect';
|
||||||
|
|
|
@ -77,6 +77,7 @@ export default class Activity implements Disposable {
|
||||||
this._lastKnownFile = window.activeTextEditor.document.fileName;
|
this._lastKnownFile = window.activeTextEditor.document.fileName;
|
||||||
const filename = basename(window.activeTextEditor.document.fileName);
|
const filename = basename(window.activeTextEditor.document.fileName);
|
||||||
largeImageKey =
|
largeImageKey =
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
knownExtentions[
|
knownExtentions[
|
||||||
Object.keys(knownExtentions).find((key) => {
|
Object.keys(knownExtentions).find((key) => {
|
||||||
if (filename.endsWith(key)) return true;
|
if (filename.endsWith(key)) return true;
|
||||||
|
@ -85,7 +86,7 @@ export default class Activity implements Disposable {
|
||||||
const regex = new RegExp(match[1], match[2]);
|
const regex = new RegExp(match[1], match[2]);
|
||||||
return regex.test(filename);
|
return regex.test(filename);
|
||||||
})!
|
})!
|
||||||
] ||
|
] ??
|
||||||
(knownLanguages.includes(window.activeTextEditor.document.languageId)
|
(knownLanguages.includes(window.activeTextEditor.document.languageId)
|
||||||
? window.activeTextEditor.document.languageId
|
? window.activeTextEditor.document.languageId
|
||||||
: null);
|
: null);
|
||||||
|
@ -297,7 +298,7 @@ export default class Activity implements Disposable {
|
||||||
.replace(
|
.replace(
|
||||||
'{workspaceAndFolder}',
|
'{workspaceAndFolder}',
|
||||||
checkState && workspaceName && workspaceFolder
|
checkState && workspaceName && workspaceFolder
|
||||||
? `${workspaceName} - ${workspaceFolder}`
|
? `${workspaceName} - ${workspaceFolder.name}`
|
||||||
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||||
)
|
)
|
||||||
.replace('{lang}', largeImageKey ? largeImageKey.image || largeImageKey : 'txt')
|
.replace('{lang}', largeImageKey ? largeImageKey.image || largeImageKey : 'txt')
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { OutputChannel, window } from 'vscode';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
export default class Logger {
|
export default class Logger {
|
||||||
private static _output: OutputChannel;
|
private static _output?: OutputChannel;
|
||||||
|
|
||||||
private static _setup() {
|
private static _setup() {
|
||||||
this._output = this._output || window.createOutputChannel('Discord Presence');
|
this._output = this._output ?? window.createOutputChannel('Discord Presence');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static log(message: string) {
|
public static log(message: string) {
|
||||||
if (!this._output) this._setup();
|
if (!this._output) this._setup();
|
||||||
this._output.appendLine(message);
|
this._output?.appendLine(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue