Skip to content

Commit d33dd8e

Browse files
committed
chore: apply linter
1 parent 9fa82a9 commit d33dd8e

File tree

8 files changed

+214
-278
lines changed

8 files changed

+214
-278
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import antfu from '@antfu/eslint-config'
22

33
export default await antfu({
4-
ignores: ['test/fixtures']
4+
ignores: ['test/fixtures'],
55
})

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"name": "unplugin-swc",
3+
"type": "module",
34
"version": "0.0.0",
45
"packageManager": "[email protected]",
56
"description": "SWC plugin for Vite and Rollup",
67
"publishConfig": {
78
"access": "public"
89
},
9-
"license": "MIT",
1010
"author": "EGOIST <[email protected]> (https://github.com/egoist)",
1111
"contributors": [
1212
"hannoeru <[email protected]> (https://github.com/hannoeru)"
1313
],
14+
"license": "MIT",
15+
"homepage": "https://github.com/unplugin/unplugin-swc/tree/main/#readme",
1416
"repository": {
1517
"type": "git",
1618
"url": "https://github.com/unplugin/unplugin-swc.git"
1719
},
1820
"bugs": {
1921
"url": "https://github.com/unplugin/unplugin-swc/issues"
2022
},
21-
"homepage": "https://github.com/unplugin/unplugin-swc/tree/main/#readme",
22-
"types": "./dist/index.d.ts",
2323
"exports": {
2424
".": {
2525
"import": {
@@ -32,12 +32,13 @@
3232
}
3333
}
3434
},
35+
"types": "./dist/index.d.ts",
3536
"files": [
3637
"dist"
3738
],
3839
"scripts": {
3940
"build": "tsup",
40-
"test": "npm run build && vitest",
41+
"test": "vitest",
4142
"lint": "eslint .",
4243
"lint:fix": "eslint . --fix",
4344
"prepublishOnly": "npm run build",
@@ -57,6 +58,7 @@
5758
"@types/node": "^20.14.9",
5859
"defu": "^6.1.4",
5960
"esbuild": "0.20.2",
61+
"eslint": "^9.6.0",
6062
"path-exists": "^5.0.0",
6163
"prettier": "3.2.5",
6264
"rollup": "^4.18.0",

pnpm-lock.yaml

Lines changed: 175 additions & 245 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import path from 'path'
1+
import path from 'node:path'
22
import { createFilter } from '@rollup/pluginutils'
33
import { transform } from '@swc/core'
44
import { defu } from 'defu'
55
// @ts-expect-error missing types
66
import { loadTsConfig } from 'load-tsconfig'
77
import { createUnplugin } from 'unplugin'
8-
import { resolveId } from './resolve'
98
import type { FilterPattern } from '@rollup/pluginutils'
109
import type { JscConfig, Options as SwcOptions, TransformConfig } from '@swc/core'
10+
import { resolveId } from './resolve'
1111

1212
export type Options = SwcOptions & {
1313
include?: FilterPattern
@@ -34,7 +34,8 @@ export default createUnplugin<Options | undefined, false>(
3434
resolveId,
3535

3636
async transform(code, id) {
37-
if (!filter(id)) return null
37+
if (!filter(id))
38+
return null
3839

3940
const compilerOptions
4041
= tsconfigFile === false
@@ -56,7 +57,8 @@ export default createUnplugin<Options | undefined, false>(
5657
if (compilerOptions.jsx) {
5758
if (jsc.parser.syntax === 'typescript') {
5859
jsc.parser.tsx = true
59-
} else {
60+
}
61+
else {
6062
jsc.parser.jsx = true
6163
}
6264
Object.assign<TransformConfig, TransformConfig>(jsc.transform, {

src/resolve.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import fs from 'fs'
2-
import path from 'path'
1+
import fs from 'node:fs'
2+
import path from 'node:path'
33
import { pathExists } from 'path-exists'
44

55
const RESOLVE_EXTENSIONS = ['.tsx', '.ts', '.mts', '.jsx', '.js', '.mjs', '.cjs']
66

7-
const resolveFile = async(resolved: string, index = false) => {
7+
async function resolveFile(resolved: string, index = false) {
88
for (const ext of RESOLVE_EXTENSIONS) {
99
const file = index
1010
? path.join(resolved, `index${ext}`)
1111
: `${resolved}${ext}`
12-
if (await pathExists(file)) return file
12+
if (await pathExists(file))
13+
return file
1314
}
1415
}
1516

16-
export const resolveId = async(importee: string, importer?: string) => {
17+
export async function resolveId(importee: string, importer?: string) {
1718
if (importer && importee[0] === '.') {
1819
const absolutePath = path.resolve(
20+
// eslint-disable-next-line node/prefer-global/process
1921
importer ? path.dirname(importer) : process.cwd(),
2022
importee,
2123
)

test/index.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import path from 'path'
1+
import path from 'node:path'
22
import { rollup } from 'rollup'
3-
import { expect, test } from 'vitest'
4-
import swc from '../dist'
3+
import { expect, it } from 'vitest'
4+
import swc from '../src'
55

66
const fixture = (...args: string[]) => path.join(__dirname, 'fixtures', ...args)
77

8-
test('rollup', async() => {
8+
it('rollup', async () => {
99
const bundle = await rollup({
1010
input: fixture('rollup/index.ts'),
1111
plugins: [
@@ -32,7 +32,7 @@ test('rollup', async() => {
3232
`)
3333
})
3434

35-
test('read tsconfig', async() => {
35+
it('read tsconfig', async () => {
3636
const bundle = await rollup({
3737
input: fixture('read-tsconfig/index.tsx'),
3838
plugins: [swc.rollup()],
@@ -53,7 +53,7 @@ test('read tsconfig', async() => {
5353
})).rejects.toThrow('Syntax Error')
5454
})
5555

56-
test('custom swcrc', async() => {
56+
it('custom swcrc', async () => {
5757
const bundle = await rollup({
5858
input: fixture('custom-swcrc/index.tsx'),
5959
plugins: [
@@ -72,7 +72,7 @@ test('custom swcrc', async() => {
7272
expect(code).toMatch('customPragma')
7373
})
7474

75-
test('minify', async() => {
75+
it('minify', async () => {
7676
const bundle = await rollup({
7777
input: fixture('minify/index.ts'),
7878
plugins: [

test/tsconfig.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"compilerOptions": {
33
"target": "es2020",
44
"module": "esnext",
5-
"strict": true,
6-
"esModuleInterop": true,
75
"moduleResolution": "node",
8-
"skipLibCheck": true,
9-
"noUnusedLocals": true,
10-
"noImplicitAny": true,
6+
"resolveJsonModule": true,
117
"allowJs": true,
12-
"resolveJsonModule": true
8+
"strict": true,
9+
"noImplicitAny": true,
10+
"noUnusedLocals": true,
11+
"esModuleInterop": true,
12+
"skipLibCheck": true
1313
},
1414
"exclude": ["fixtures"]
1515
}

tsconfig.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"compilerOptions": {
33
"target": "es2020",
44
"module": "esnext",
5-
"strict": true,
6-
"esModuleInterop": true,
75
"moduleResolution": "Bundler",
8-
"skipLibCheck": true,
9-
"noUnusedLocals": true,
10-
"noImplicitAny": true,
6+
"resolveJsonModule": true,
117
"allowJs": true,
12-
"resolveJsonModule": true
8+
"strict": true,
9+
"noImplicitAny": true,
10+
"noUnusedLocals": true,
11+
"esModuleInterop": true,
12+
"skipLibCheck": true
1313
},
1414
"include": ["src", "*.ts"]
1515
}

0 commit comments

Comments
 (0)