Skip to content

Commit

Permalink
style: lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Apr 27, 2024
1 parent e53fcf4 commit 6b87a37
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 59 deletions.
9 changes: 8 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"extends": ["@recommended/biome-config"]
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
"extends": ["@recommended/biome-config"],
"javascript": {
"formatter": {
"trailingComma": "es5",
"arrowParentheses": "always"
}
}
}
2 changes: 1 addition & 1 deletion example/values.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Circular
let obj: Record<any, any> = {a: 1, obj: null}
const obj: Record<any, any> = {a: 1, obj: null}
obj.obj = obj
obj

Expand Down
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"engines": {
"vscode": "^1.61.0"
},
"categories": [
"Programming Languages"
],
"categories": ["Programming Languages"],
"activationEvents": [
"onLanguage:javascript",
"onLanguage:javascriptreact",
Expand Down Expand Up @@ -145,12 +143,8 @@
},
"jest": {
"preset": "es-jest",
"transformIgnorePatterns": [
"/node_modules/(?!(node-fetch-cache)/)"
],
"collectCoverageFrom": [
"src/**/*"
]
"transformIgnorePatterns": ["/node_modules/(?!(node-fetch-cache)/)"],
"collectCoverageFrom": ["src/**/*"]
},
"dependencies": {
"esbuild": "^0.20.2"
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-extension.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import minimist from 'minimist'
import {execSync} from 'child_process'
import {builtinModules} from 'module'
import * as esbuild from 'esbuild'
/* eslint-disable no-console */
import minimist from 'minimist'
import watchLogPlugin from './watchLogPlugin.mjs'

const args = minimist(process.argv.slice(2), {
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-preview.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-console */
import minimist from 'minimist'
import {execSync} from 'child_process'
import NodeModulesPolyfills from '@esbuild-plugins/node-modules-polyfill'
import {fetchBuilder, FileSystemCache} from 'node-fetch-cache'
import * as esbuild from 'esbuild'
import {execSync} from 'child_process'
/* eslint-disable no-console */
import minimist from 'minimist'
import {FileSystemCache, fetchBuilder} from 'node-fetch-cache'
import httpPlugin from './httpPlugin.mjs'
import watchLogPlugin from './watchLogPlugin.mjs'

Expand Down
4 changes: 2 additions & 2 deletions scripts/copy.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fg from 'fast-glob'
import path from 'path'
import {promises as fs} from 'fs'
import path from 'path'
import fg from 'fast-glob'

const config = [
// {
Expand Down
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import path from 'path'
import * as prettyFormat from 'pretty-format'
import * as vscode from 'vscode'
import type {Runtime, AnyFunction, BuildPlatform} from './types'
import type {Worker} from 'worker_threads'
import bundle from './extension/bundle'
import {install} from './extension/install'
import getWebviewContent from './extension/getWebviewContent'
import transform from './sandbox/transform'
import {install} from './extension/install'
import * as nodeVM from './sandbox/nodeVM'
import transform from './sandbox/transform'
import type {ExpContext} from './sandbox/types'
import timeMark from './utils/timeMark'
import type {AnyFunction, BuildPlatform, Runtime} from './types'
import {of} from './utils/promise'
import type {Worker} from 'worker_threads'
import timeMark from './utils/timeMark'

const NAME = 'Live Code'
const output = vscode.window.createOutputChannel(NAME)
Expand Down Expand Up @@ -331,13 +331,13 @@ async function processDocumentPanel(

function debounce<T extends AnyFunction<void>>(fn: T, wait: number) {
let timer: number | undefined
return function () {
return (() => {
if (timer) {
clearTimeout(timer)
}
// eslint-disable-next-line prefer-rest-params
timer = setTimeout(fn.apply.bind(fn, void 0, arguments), wait)
} as T
}) as T
}

function setPanelTitleAndIcon(
Expand Down
2 changes: 1 addition & 1 deletion src/extension/__tests__/bundle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import bundle, {BundleOpts} from '../bundle'
import bundle, {type BundleOpts} from '../bundle'

describe('browser', () => {
const opts: BundleOpts = {
Expand Down
12 changes: 6 additions & 6 deletions src/extension/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import type * as Esbuild from 'esbuild'
import {fetchBuilder, MemoryCache} from 'node-fetch-cache'
import {nodeExternalsPlugin} from 'esbuild-node-externals'
import {MemoryCache, fetchBuilder} from 'node-fetch-cache'
// @ts-expect-error ESM
import httpPlugin from '../../scripts/httpPlugin.mjs'

Expand Down Expand Up @@ -107,11 +107,11 @@ export default async function bundle(
nodeExternalsPlugin(),
]
: isWeb
? [
//
externalGlobalPlugin({react: 'React', 'react-dom': 'ReactDOM'}),
]
: [],
? [
//
externalGlobalPlugin({react: 'React', 'react-dom': 'ReactDOM'}),
]
: [],
})
const outputs = result.outputFiles
const js = outputs.find((x) => x.path.endsWith('.js'))?.text
Expand Down
2 changes: 1 addition & 1 deletion src/extension/getWebviewContent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AppConfig} from '../types'
import type {AppConfig} from '../types'

export default function getWebviewContent(appConfig: AppConfig) {
return `<!DOCTYPE html>
Expand Down
22 changes: 11 additions & 11 deletions src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/** @jsx jsx */
import {jsx} from '@emotion/react'
import isPromise from 'is-promise'
import * as prettyFormat from 'pretty-format'
import React, {useState, useMemo, useEffect, useCallback} from 'react'
import {render} from 'react-dom'
import * as prettyFormat from 'pretty-format'
import isPromise from 'is-promise'
// import {VSCodeProgressRing} from '@vscode/webview-ui-toolkit/react'
import type {EvaluationResult, ExpContext} from './sandbox/types'
import {runInNewContext, CallbackParams} from './sandbox/browserVM'
import injectImportMap from './sandbox/injectImportMap'
import injectCSS from './sandbox/injectCSS'
import {IsDarkModeProvider, useIsDarkMode} from './preview/darkMode'
import ErrorBoundary from './preview/ErrorBoundary'
import Inspector from './preview/Inspector'
import {StyledConsole, Hook, Unhook, Message} from './preview/console'
import {AppConfig, AnyFunction, Runtime} from './types'
import timeMark from './utils/timeMark'
import {Hook, type Message, StyledConsole, Unhook} from './preview/console'
import {IsDarkModeProvider, useIsDarkMode} from './preview/darkMode'
import {type CallbackParams, runInNewContext} from './sandbox/browserVM'
import injectCSS from './sandbox/injectCSS'
import injectImportMap from './sandbox/injectImportMap'
// import {VSCodeProgressRing} from '@vscode/webview-ui-toolkit/react'
import type {EvaluationResult, ExpContext} from './sandbox/types'
import type {AnyFunction, AppConfig, Runtime} from './types'
import {of} from './utils/promise'
import timeMark from './utils/timeMark'

// https://code.visualstudio.com/api/extension-guides/webview#persistence
const vscode = acquireVsCodeApi()
Expand Down
3 changes: 2 additions & 1 deletion src/preview/Inspector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useState, useEffect} from 'react'
import type React from 'react'
import {useEffect, useState} from 'react'
import * as ri from 'react-inspector'
import {useIsDarkMode} from './darkMode'

Expand Down
3 changes: 2 additions & 1 deletion src/preview/console.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @jsx jsx */
import {jsx} from '@emotion/react'
import React, {useMemo} from 'react'
import {Console, Decode} from 'console-feed'
import type React from 'react'
import {useMemo} from 'react'
import {baseInspectorStyles} from './Inspector'
import {useIsDarkMode} from './darkMode'

Expand Down
3 changes: 2 additions & 1 deletion src/preview/darkMode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useState, useEffect, createContext, useContext} from 'react'
import type React from 'react'
import {createContext, useContext, useEffect, useState} from 'react'

// https://github.com/microsoft/vscode/issues/7589#issuecomment-226129243
const getIsDarkMode = () => document.body.classList.contains('vscode-dark')
Expand Down
4 changes: 2 additions & 2 deletions src/preview/webview-ui-toolkit.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import type React from 'react'

// https://github.com/microsoft/vscode-webview-ui-toolkit
type VSCodeElement<
T = HTMLElement,
P = React.HTMLAttributes
P = React.HTMLAttributes,
> = React.DetailedHTMLProps<P<T>, T>

declare global {
Expand Down
12 changes: 7 additions & 5 deletions src/sandbox/__tests__/nodeVM.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Message} from 'console-feed/lib/definitions/Console'
import type {Message} from 'console-feed/lib/definitions/Console'
import {create} from '../../utils/promise'
import * as nodeVM from '../nodeVM'
import transform from '../transform'
Expand All @@ -8,8 +8,9 @@ const opts = {
}

test('empty', async () => {
expect(await nodeVM.runInNewContext(transform(``), opts))
.toMatchInlineSnapshot(`
expect(
await nodeVM.runInNewContext(transform(``), opts)
).toMatchInlineSnapshot(`
{
"logs": [],
"result": [],
Expand All @@ -18,8 +19,9 @@ test('empty', async () => {
})

test('expression', async () => {
expect(await nodeVM.runInNewContext(transform(`0`), opts))
.toMatchInlineSnapshot(`
expect(
await nodeVM.runInNewContext(transform(`0`), opts)
).toMatchInlineSnapshot(`
{
"logs": [],
"result": [
Expand Down
2 changes: 1 addition & 1 deletion src/sandbox/nodeVM.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import type {ExpContext} from './types'
import {Worker} from 'worker_threads'
import type {ExpContext} from './types'

const workerPath = path.resolve(__dirname, 'nodeWorker.js')

Expand Down
6 changes: 3 additions & 3 deletions src/sandbox/transform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as recast from 'recast'
import {types} from 'recast'
import getBabelOptions, {Overrides} from 'recast/parsers/_babel_options'
import {parse as babelParse} from '@babel/parser'
import * as recast from 'recast'
import type {types} from 'recast'
import getBabelOptions, {type Overrides} from 'recast/parsers/_babel_options'

function parse(source: string, options?: Overrides) {
const babelOptions = getBabelOptions(options)
Expand Down

0 comments on commit 6b87a37

Please sign in to comment.