Skip to content

Commit 21c5f9b

Browse files
committed
fix TypeScript lint issues, use standard tsconfig.json
1 parent 02e2ab1 commit 21c5f9b

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/extension.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import * as sourcegraph from 'sourcegraph'
21
import { distanceInWordsToNow } from 'date-fns'
2+
import * as sourcegraph from 'sourcegraph'
33
import { resolveSettings, Settings } from './settings'
44
import { fetchDiscussionThreads } from './shared/api'
5+
import { resolveURI } from './uri'
56

67
const decorationType = sourcegraph.app.createDecorationType && sourcegraph.app.createDecorationType()
78

@@ -16,7 +17,7 @@ export function activate(): void {
1617
return
1718
}
1819

19-
const u = new (global as any).URL(editor.document.uri)
20+
const u = new URL(editor.document.uri)
2021
const uri = {
2122
repositoryName: u.pathname.slice(2),
2223
revision: u.search.slice(1),
@@ -30,8 +31,8 @@ export function activate(): void {
3031
relativeRev: uri.revision,
3132
})
3233

33-
let decorations: sourcegraph.TextDocumentDecoration[] = []
34-
threads.nodes.forEach(thread => {
34+
const decorations: sourcegraph.TextDocumentDecoration[] = []
35+
for (const thread of threads.nodes) {
3536
const settings = resolveSettings(sourcegraph.configuration.get<Settings>().value)
3637
if (!settings['discussions.decorations.inline']) {
3738
return
@@ -40,7 +41,7 @@ export function activate(): void {
4041
if (thread.target.__typename !== 'DiscussionThreadTargetRepo') {
4142
return
4243
}
43-
var target = thread.target as SourcegraphGQL.IDiscussionThreadTargetRepo
44+
const target: SourcegraphGQL.IDiscussionThreadTargetRepo = thread.target
4445
if (target.relativePath !== uri.filePath) {
4546
// TODO(slimsag): shouldn't the discussions API return threads created in different files and moved here, too? lol :facepalm:
4647
return // comment has since moved to a different file.
@@ -57,8 +58,8 @@ export function activate(): void {
5758
)} ago`
5859

5960
// TODO(slimsag): color scheme detection was impossible when this was written, see https://github.com/sourcegraph/sourcegraph/issues/732
60-
const color = (global as any).location.host === 'github.com' ? 'black' : '#0366d6' // #3b4d6e
61-
const backgroundColor = (global as any).location.host === 'github.com' ? 'white' : 'rgba(28, 126, 214, 0.3)' // #151c28
61+
const color = window.location.host === 'github.com' ? 'black' : '#0366d6' // #3b4d6e
62+
const backgroundColor = window.location.host === 'github.com' ? 'white' : 'rgba(28, 126, 214, 0.3)' // #151c28
6263

6364
decorations.push({
6465
range: new sourcegraph.Range(
@@ -74,16 +75,16 @@ export function activate(): void {
7475
after: {
7576
contentText: ' 💬 ' + describeThread(shortTitle),
7677
linkURL: thread.inlineURL
77-
? (global as any).location.host
78+
? window.location.host
7879
? thread.inlineURL.slice(thread.inlineURL.lastIndexOf('#'))
7980
: thread.inlineURL
8081
: undefined,
8182
hoverMessage: ' ' + describeThread(thread.title),
82-
color: color,
83+
color,
8384
},
84-
backgroundColor: backgroundColor,
85+
backgroundColor,
8586
})
86-
})
87+
}
8788

8889
try {
8990
editor.setDecorations(decorationType, decorations)

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./node_modules/@sourcegraph/tsconfig/tsconfig.json",
3+
"compilerOptions": {
4+
"target": "es2016",
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"sourceMap": true,
8+
"declaration": true,
9+
"outDir": "dist",
10+
"rootDir": "src",
11+
"esModuleInterop": true,
12+
"allowSyntheticDefaultImports": true
13+
}
14+
}

0 commit comments

Comments
 (0)