diff --git a/package.json b/package.json index 9746a1a..a21a688 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,8 @@ "coc.nvim": "^0.0.80" }, "devDependencies": { + "@commitlint/cli": "^13.1.0", + "@commitlint/config-conventional": "^13.1.0", "@luma-dev/eslint-config-base": "^0.5.0", "@luma-dev/eslint-config-jest": "^0.2.3", "@luma-dev/prettier-config": "^0.1.0", @@ -167,6 +169,7 @@ "@types/jest": "^27.0.1", "@types/node": "10.12.0", "better-typescript-lib": "^1.1.0", + "commitlint": "^13.1.0", "deep-equal": "^2.0.5", "esbuild": "^0.12.28", "esbuild-node-externals": "^1.3.0", @@ -174,9 +177,6 @@ "husky": "^7.0.2", "jest": "^27.2.0", "npm-run-all": "^4.1.5", - "@commitlint/cli": "^13.1.0", - "@commitlint/config-conventional": "^13.1.0", - "commitlint": "^13.1.0", "onchange": "^7.1.0", "prettier": "^2.4.0", "semantic-release": "^17.4.7", diff --git a/src/entrypoints/coc.ts b/src/entrypoints/coc.ts index 48df7ab..c536981 100644 --- a/src/entrypoints/coc.ts +++ b/src/entrypoints/coc.ts @@ -1,7 +1,6 @@ /* eslint-disable import/prefer-default-export */ import type { ExtensionContext } from 'coc.nvim'; import { workspace, commands } from 'coc.nvim'; -import assert from 'assert'; import { autoInitializeWorkspace, manualInitializeWorkspace } from '../commands'; import { EXTENSION_NS, getSettings } from '../settings'; @@ -21,7 +20,7 @@ const initialize = async (_context: ExtensionContext): Promise => { export const activate = async (context: ExtensionContext): Promise => { // Setup vim runtime settings as vim plugin. const rtp = await workspace.nvim.getOption('runtimepath'); - assert(typeof rtp === 'string'); + if (typeof rtp !== 'string') throw new Error('[coc-tsdetect] Failed to get runtimepath.'); const paths = rtp.split(','); if (!paths.includes(context.extensionPath)) { await workspace.nvim.command(`execute 'noautocmd set runtimepath^='.fnameescape('${context.extensionPath}')`); diff --git a/src/settings.ts b/src/settings.ts index 480eec5..3d32db7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,5 +1,4 @@ import { workspace } from 'coc.nvim'; -import assert from 'assert'; export const EXTENSION_NS = 'tsdetect'; @@ -23,8 +22,9 @@ export const getSettings = (): Settings => { const result: any = Object.create(null); settingsKeys.forEach((key) => { const value = settings.inspect(key); - assert(value); - result[key] = value.workspaceValue ?? value.globalValue ?? value.defaultValue; + if (value) { + result[key] = value.workspaceValue ?? value.globalValue ?? value.defaultValue; + } }); // eslint-disable-next-line @typescript-eslint/no-unsafe-return return result;