Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 13, 2022
1 parent 2843b77 commit 62bda6e
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 54 deletions.
4 changes: 0 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
Expand Down
31 changes: 11 additions & 20 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,20 @@
"type": "npm",
"script": "dev",
"isBackground": true,
"problemMatcher": {
"fileLocation": "relative",
"pattern": {
"regexp": "_______",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
},
"background": {
"activeOnStart": true,
"beginsPattern": "Building",
"endsPattern": "^ CJS Build success"
}
},
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
"problemMatcher": [
{
"base": "$ts-webpack-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "Build start",
"endsPattern": "Build success"
}
}
],
"group": "build"
}
]
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"publisher": "antfu",
"name": "slidev",
"preview": true,
"packageManager": "pnpm@7.5.1",
"displayName": "Slidev",
"version": "0.3.3",
"packageManager": "pnpm@7.5.1",
"description": "Slidev support for VS Code",
"publisher": "antfu",
"license": "MIT",
"icon": "res/logo.png",
"repository": {
"type": "git",
"url": "/~https://github.com/slidevjs/slidev-vscode"
},
"engines": {
"vscode": "^1.52.0"
},
"categories": [
"Other"
],
"main": "./dist/index.js",
"icon": "res/logo.png",
"engines": {
"vscode": "^1.52.0"
},
"activationEvents": [
"onStartupFinished"
],
"main": "./dist/index.js",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -147,6 +147,7 @@
"build": "tsup src/index.ts --dts --external=vscode",
"dev": "nr build --watch",
"vscode:prepublish": "nr build",
"lint": "eslint .",
"publish": "vsce publish --no-dependencies",
"pack": "vsce package --no-dependencies",
"release": "bump && nr publish"
Expand Down
5 changes: 3 additions & 2 deletions src/ctx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExtensionContext, EventEmitter, TextDocument } from 'vscode'
import { SlidevMarkdown } from '@slidev/types'
import type { ExtensionContext, TextDocument } from 'vscode'
import { EventEmitter } from 'vscode'
import type { SlidevMarkdown } from '@slidev/types'

export class Context {
private _onDataUpdate = new EventEmitter<SlidevMarkdown | undefined>()
Expand Down
17 changes: 8 additions & 9 deletions src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { commands, languages, window, workspace } from 'vscode'
// @ts-expect-error
import * as parser from '@slidev/parser/fs'
import Markdown from 'markdown-it'
import { ctx } from './ctx'
import { SlideItem } from './view/SlideItem'
import type { SlideItem } from './view/SlideItem'
import { SlidesProvider } from './view/SlidesProvider'
import { FoldingProvider } from './view/FoldingProvider'
import { PreviewProvider } from './view/PreviewProvider'
Expand Down Expand Up @@ -40,7 +39,7 @@ export function configEditor() {
}

workspace.createFileSystemWatcher('**/*.md', true, false)
.onDidChange(async(uri) => {
.onDidChange(async (uri) => {
if (uri.fsPath === ctx.doc?.uri.fsPath)
ctx.data = await parser.load(uri.fsPath)
})
Expand All @@ -62,12 +61,12 @@ export function configEditor() {
showCollapseAll: true,
})

commands.registerCommand('slidev.goto', async(idx: number) => {
commands.registerCommand('slidev.goto', async (idx: number) => {
revealSlide(idx)
previewProvider.updateSlide(idx)
})

commands.registerCommand('slidev.next', async() => {
commands.registerCommand('slidev.next', async () => {
const editor = window.activeTextEditor
if (!editor || editor.document !== ctx.doc)
return
Expand All @@ -76,7 +75,7 @@ export function configEditor() {
revealSlide(index + 1)
})

commands.registerCommand('slidev.prev', async() => {
commands.registerCommand('slidev.prev', async () => {
const editor = window.activeTextEditor
if (!editor || editor.document !== ctx.doc)
return
Expand All @@ -89,14 +88,14 @@ export function configEditor() {
return arr
}

commands.registerCommand('slidev.move-up', async(item: SlideItem) => {
commands.registerCommand('slidev.move-up', async (item: SlideItem) => {
if (!ctx.data?.slides || item.info.index <= 0)
return
move(ctx.data.slides, item.info.index, item.info.index - 1)
parser.save(ctx.data)
})

commands.registerCommand('slidev.move-down', async(item: SlideItem) => {
commands.registerCommand('slidev.move-down', async (item: SlideItem) => {
if (!ctx.data?.slides || item.info.index >= ctx.data.slides.length)
return
move(ctx.data.slides, item.info.index, item.info.index + 1)
Expand All @@ -105,7 +104,7 @@ export function configEditor() {

commands.registerCommand('slidev.preview-refresh', previewProvider.refresh.bind(previewProvider))

commands.registerCommand('slidev.markdown-to-html', async() => {
commands.registerCommand('slidev.markdown-to-html', async () => {
const editor = window.activeTextEditor
const doc = editor?.document
if (!editor || !doc)
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { existsSync, promises as fs } from 'fs'
import { join } from 'path'
import { commands, ExtensionContext, workspace } from 'vscode'
import type { ExtensionContext } from 'vscode'
import { commands, workspace } from 'vscode'
import { config } from './config'
import { ctx } from './ctx'
import { configEditor } from './editor'
Expand Down
8 changes: 4 additions & 4 deletions src/slides.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SlideInfo, SlideInfoWithPath } from '@slidev/types'
import { Position, Range, Selection, TextEditorRevealType, window, workspace, Uri } from 'vscode'
import type { SlideInfo, SlideInfoWithPath } from '@slidev/types'
import { Position, Range, Selection, TextEditorRevealType, Uri, window, workspace } from 'vscode'
import { ctx } from './ctx'

export function getCurrentSlideIndex(editor = window.activeTextEditor) {
Expand All @@ -12,9 +12,9 @@ export function getCurrentSlideIndex(editor = window.activeTextEditor) {
export async function revealSlide(idx: number, editor = window.activeTextEditor) {
if (idx < 0)
return
// @ts-expect-error
// @ts-expect-error cast
let slide: SlideInfoWithPath & SlideInfo = ctx.data?.slides[idx]
// @ts-expect-error
// @ts-expect-error cast
slide = slide?.source || slide
if (!slide)
return
Expand Down
3 changes: 2 additions & 1 deletion src/view/FoldingProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventEmitter, FoldingRange, FoldingRangeKind, FoldingRangeProvider, TextDocument } from 'vscode'
import type { FoldingRangeProvider, TextDocument } from 'vscode'
import { EventEmitter, FoldingRange, FoldingRangeKind } from 'vscode'
import { ctx } from '../ctx'

export class FoldingProvider implements FoldingRangeProvider {
Expand Down
5 changes: 3 additions & 2 deletions src/view/PreviewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WebviewView, WebviewViewProvider, window } from 'vscode'
import type { WebviewView, WebviewViewProvider } from 'vscode'
import { window } from 'vscode'
import got from 'got'
import { ctx } from '../ctx'
import { config, setConfig } from '../config'
Expand Down Expand Up @@ -50,7 +51,7 @@ export class PreviewProvider implements WebviewViewProvider {
localResourceRoots: [ctx.ext.extensionUri],
}

this.view.webview.onDidReceiveMessage(async({ command }) => {
this.view.webview.onDidReceiveMessage(async ({ command }) => {
if (command === 'config-port') {
const port = await window.showInputBox({
placeHolder: 'Server port',
Expand Down
4 changes: 2 additions & 2 deletions src/view/SlideItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, ThemeIcon, TreeItem } from 'vscode'
import { SlideInfo } from '@slidev/types'
import type { Command, ThemeIcon, TreeItem } from 'vscode'
import type { SlideInfo } from '@slidev/types'
import { ctx } from '../ctx'

export class SlideItem implements TreeItem {
Expand Down
3 changes: 2 additions & 1 deletion src/view/SlidesProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventEmitter, ProviderResult, TreeDataProvider } from 'vscode'
import type { ProviderResult, TreeDataProvider } from 'vscode'
import { EventEmitter } from 'vscode'
import { ctx } from '../ctx'
import { SlideItem } from './SlideItem'

Expand Down

0 comments on commit 62bda6e

Please sign in to comment.