Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(
sourcegraph.workspace.registerDiagnosticProvider('packageJsonDependency', {
provideDiagnostics: (_scope, context) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
provideDiagnostics((context as any) as PackageJsonDependencyCampaignContext).pipe(
filter((diagnostics): diagnostics is sourcegraph.Diagnostic[] => diagnostics !== LOADING)
),
})
)
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(COMMAND_ID, diagnostic => {
if (!diagnostic || (diagnostic.tags && !diagnostic.tags.includes('fix'))) {
return Promise.resolve(new sourcegraph.WorkspaceEdit())
}
return editForDependencyAction(diagnostic).toPromise()
})
)
return subscriptions
}
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(
sourcegraph.workspace.registerDiagnosticProvider('packageJsonDependency', {
provideDiagnostics: (_scope, context) =>
provideDiagnostics(context).pipe(
filter((diagnostics): diagnostics is sourcegraph.Diagnostic[] => diagnostics !== LOADING)
),
})
)
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(REMOVE_COMMAND, async diagnostic => {
const doc = await sourcegraph.workspace.openTextDocument(diagnostic.resource)
return computeRemoveDependencyEdit(diagnostic, doc)
})
)
return subscriptions
}
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(startDiagnostics())
subscriptions.add(registerCheckProvider(diagnostics))
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(FILE_ISSUE_COMMAND, () => new sourcegraph.WorkspaceEdit())
)
subscriptions.add(sourcegraph.commands.registerActionEditCommand(IGNORE_COMMAND, ignoreCommandCallback))
return subscriptions
}
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(
sourcegraph.workspace.registerDiagnosticProvider('rubyGemDependency', {
provideDiagnostics: (_scope, context) =>
provideDiagnostics((context as any) as RubyGemDependencyCampaignContext).pipe(
filter((diagnostics): diagnostics is sourcegraph.Diagnostic[] => diagnostics !== LOADING)
),
})
)
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(REMOVE_COMMAND, async diagnostic =>
diagnostic
? computeRemoveDependencyEdit(
diagnostic,
await sourcegraph.workspace.openTextDocument(diagnostic.resource)
)
: new sourcegraph.WorkspaceEdit()
)
)
return subscriptions
}
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(startDiagnostics())
subscriptions.add(registerCheckProvider(diagnostics))
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(FILE_ISSUE_COMMAND, () => new sourcegraph.WorkspaceEdit())
)
subscriptions.add(sourcegraph.commands.registerActionEditCommand(IGNORE_COMMAND, ignoreCommandCallback))
return subscriptions
}
{
command: {
command: 'TODO!(sqs)',
},
},
],
},
},
],
},
])
),
})
)
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(
FIX_GO_VERSION_COMMAND_ID,
async (diagnostic: sourcegraph.Diagnostic) => {
const { edit } = await computeFixAllActionsFromDiagnostics([diagnostic])
return edit
}
)
)
return subscriptions
}
async ({ query, vars }: { query: string; vars: { [name: string]: any } }): Promise => {
return sourcegraph.commands.executeCommand('queryGraphQL', query, vars)
},
arg => JSON.stringify({ query: arg.query, vars: arg.vars })
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(sourcegraph.commands.registerCommand(FIND_REPLACE_REWRITE_COMMAND, rewrite))
return subscriptions
}
async function queryGraphQL(query: string, variables: any = {}): Promise {
const { data, errors } = await sourcegraph.commands.executeCommand('queryGraphQL', query, variables)
if (errors) {
throw Object.assign(new Error(errors.map((err: any) => err.message).join('\n')), { errors })
}
return data
}
export function register(): Unsubscribable {
const subscriptions = new Subscription()
subscriptions.add(startDiagnostics())
subscriptions.add(registerCheckProvider(diagnostics))
subscriptions.add(sourcegraph.languages.registerCodeActionProvider(['*'], createCodeActionProvider()))
subscriptions.add(sourcegraph.commands.registerActionEditCommand(FIX_EDIT_COMMAND, fixEditCommandCallback))
subscriptions.add(
sourcegraph.commands.registerActionEditCommand(DISABLE_RULE_ON_LINE_COMMAND, disableRuleOnLineCommandCallback)
)
return subscriptions
}