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/
|
||||
dist/
|
||||
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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.13.0",
|
||||
"@types/vscode": "^1.44.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.28.0",
|
||||
"@typescript-eslint/parser": "^2.28.0",
|
||||
"@types/node": "^14.0.5",
|
||||
"@types/vscode": "^1.45.1",
|
||||
"@typescript-eslint/eslint-plugin": "^3.0.0",
|
||||
"@typescript-eslint/parser": "^3.0.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-marine": "^6.0.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint": "^7.1.0",
|
||||
"eslint-config-marine": "^7.1.2",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"prettier": "^2.0.4",
|
||||
"terser-webpack-plugin": "^3.0.0",
|
||||
"ts-loader": "^7.0.1",
|
||||
"typescript": "^3.8.3",
|
||||
"webpack": "^4.42.1",
|
||||
"prettier": "^2.0.5",
|
||||
"terser-webpack-plugin": "^3.0.1",
|
||||
"ts-loader": "^7.0.4",
|
||||
"typescript": "^3.9.3",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.44.0"
|
||||
"vscode": "^1.45.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"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 { API } from '../git';
|
||||
|
||||
let activityTimer: NodeJS.Timer;
|
||||
let activityTimer: NodeJS.Timer | undefined;
|
||||
|
||||
export default class RPCClient implements Disposable {
|
||||
public statusBarIcon: StatusBarItem;
|
||||
|
@ -77,9 +77,9 @@ export default class RPCClient implements Disposable {
|
|||
if (activityTimer) clearInterval(activityTimer);
|
||||
await this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
||||
|
||||
activityTimer = setInterval(async () => {
|
||||
activityTimer = setInterval(() => {
|
||||
this.config = workspace.getConfiguration('discord');
|
||||
await this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
||||
void this.setActivity(this.config.get<boolean>('workspaceElapsedTime'));
|
||||
}, 10000);
|
||||
|
||||
this._rpc.subscribe('ACTIVITY_SPECTATE', async ({ secret }: { secret: string }) => {
|
||||
|
@ -166,6 +166,6 @@ export default class RPCClient implements Disposable {
|
|||
this._rpc = null;
|
||||
this.statusBarIcon.tooltip = '';
|
||||
|
||||
clearInterval(activityTimer);
|
||||
if (activityTimer) clearInterval(activityTimer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import Logger from './structures/Logger';
|
|||
import { GitExtension } from './git';
|
||||
const { register } = require('discord-rpc'); // eslint-disable-line
|
||||
|
||||
let loginTimeout: NodeJS.Timer;
|
||||
let loginTimeout: NodeJS.Timer | undefined;
|
||||
|
||||
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||
statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||
|
@ -32,28 +32,28 @@ export async function activate(context: ExtensionContext) {
|
|||
|
||||
const enabler = commands.registerCommand('discord.enable', async () => {
|
||||
await rpc.dispose();
|
||||
config.update('enabled', true);
|
||||
void config.update('enabled', true);
|
||||
rpc.config = workspace.getConfiguration('discord');
|
||||
rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||
rpc.statusBarIcon.show();
|
||||
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 () => {
|
||||
config.update('enabled', false);
|
||||
void config.update('enabled', false);
|
||||
rpc.config = workspace.getConfiguration('discord');
|
||||
await rpc.dispose();
|
||||
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 () => {
|
||||
if (loginTimeout) clearTimeout(loginTimeout);
|
||||
await rpc.dispose();
|
||||
loginTimeout = setTimeout(async () => {
|
||||
await rpc.login();
|
||||
if (!config.get('silent')) window.showInformationMessage('Reconnecting to Discord RPC...');
|
||||
loginTimeout = setTimeout(() => {
|
||||
void rpc.login();
|
||||
if (!config.get('silent')) void window.showInformationMessage('Reconnecting to Discord RPC...');
|
||||
rpc.statusBarIcon.text = '$(pulse) Reconnecting to Discord...';
|
||||
rpc.statusBarIcon.command = 'discord.reconnect';
|
||||
}, 1000);
|
||||
|
@ -106,11 +106,11 @@ export async function activate(context: ExtensionContext) {
|
|||
try {
|
||||
await rpc.login();
|
||||
} 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();
|
||||
if (!config.get('silent')) {
|
||||
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
|
||||
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.toString()}`);
|
||||
if (error.message.includes('ENOENT')) void window.showErrorMessage('No Discord Client detected!');
|
||||
else void window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error as string}`);
|
||||
}
|
||||
rpc.statusBarIcon.text = '$(pulse) Reconnect to Discord';
|
||||
rpc.statusBarIcon.command = 'discord.reconnect';
|
||||
|
|
|
@ -77,6 +77,7 @@ export default class Activity implements Disposable {
|
|||
this._lastKnownFile = window.activeTextEditor.document.fileName;
|
||||
const filename = basename(window.activeTextEditor.document.fileName);
|
||||
largeImageKey =
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
knownExtentions[
|
||||
Object.keys(knownExtentions).find((key) => {
|
||||
if (filename.endsWith(key)) return true;
|
||||
|
@ -85,7 +86,7 @@ export default class Activity implements Disposable {
|
|||
const regex = new RegExp(match[1], match[2]);
|
||||
return regex.test(filename);
|
||||
})!
|
||||
] ||
|
||||
] ??
|
||||
(knownLanguages.includes(window.activeTextEditor.document.languageId)
|
||||
? window.activeTextEditor.document.languageId
|
||||
: null);
|
||||
|
@ -297,7 +298,7 @@ export default class Activity implements Disposable {
|
|||
.replace(
|
||||
'{workspaceAndFolder}',
|
||||
checkState && workspaceName && workspaceFolder
|
||||
? `${workspaceName} - ${workspaceFolder}`
|
||||
? `${workspaceName} - ${workspaceFolder.name}`
|
||||
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||
)
|
||||
.replace('{lang}', largeImageKey ? largeImageKey.image || largeImageKey : 'txt')
|
||||
|
|
|
@ -2,14 +2,14 @@ import { OutputChannel, window } from 'vscode';
|
|||
|
||||
// eslint-disable-next-line
|
||||
export default class Logger {
|
||||
private static _output: OutputChannel;
|
||||
private static _output?: OutputChannel;
|
||||
|
||||
private static _setup() {
|
||||
this._output = this._output || window.createOutputChannel('Discord Presence');
|
||||
this._output = this._output ?? window.createOutputChannel('Discord Presence');
|
||||
}
|
||||
|
||||
public static log(message: string) {
|
||||
if (!this._output) this._setup();
|
||||
this._output.appendLine(message);
|
||||
this._output?.appendLine(message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue