Skip to content

Commit 15be0b2

Browse files
committed
chore: fix lint
1 parent 0037ee9 commit 15be0b2

File tree

10 files changed

+42
-39
lines changed

10 files changed

+42
-39
lines changed

eslint.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
const { sxzz } = require('@sxzz/eslint-config')
2-
module.exports = sxzz()
1+
import { sxzz } from '@sxzz/eslint-config'
2+
3+
export default sxzz({
4+
ignores: ['README*.md/*.js'],
5+
})

examples/vite/tsconfig.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
43
"target": "esnext",
4+
"jsx": "preserve",
5+
"lib": ["esnext", "dom"],
56
"useDefineForClassFields": true,
7+
"baseUrl": ".",
68
"module": "esnext",
79
"moduleResolution": "bundler",
8-
"strict": true,
9-
"jsx": "preserve",
10-
"sourceMap": true,
11-
"resolveJsonModule": true,
12-
"esModuleInterop": true,
13-
"lib": ["esnext", "dom"],
1410
"paths": {
1511
"~/*": ["src/*"]
16-
}
12+
},
13+
"resolveJsonModule": true,
14+
"strict": true,
15+
"sourceMap": true,
16+
"esModuleInterop": true
1717
},
1818
"include": ["src", "*"]
1919
}

examples/vite/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
2-
import { defineConfig } from 'vite'
32
import vue from '@vitejs/plugin-vue'
43
import ElementPlus from 'unplugin-element-plus/vite'
4+
import { defineConfig } from 'vite'
55
import Inspect from 'vite-plugin-inspect'
66

77
// https://vitejs.dev/config/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "0.8.0",
44
"packageManager": "[email protected]",
55
"type": "module",
6-
"license": "MIT",
76
"keywords": [
87
"element-plus",
98
"unplugin",
@@ -13,6 +12,7 @@
1312
"esbuild",
1413
"plugin"
1514
],
15+
"license": "MIT",
1616
"homepage": "https://github.com/element-plus/unplugin-element-plus/tree/main/#readme",
1717
"bugs": {
1818
"url": "https://github.com/element-plus/unplugin-element-plus/issues"

src/core/default-locale.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import escapeStringRegexp from 'escape-string-regexp'
2-
import { type Plugin } from 'esbuild'
3-
import { type Options } from '../index'
2+
import type { Options } from '../index'
3+
import type { Plugin } from 'esbuild'
44

55
export function getLocaleRE(options: Options): RegExp {
66
return new RegExp(
77
`${escapeStringRegexp(`${options.lib}/`)}(es|lib)${escapeStringRegexp(
8-
'/hooks/use-locale/index'
9-
)}`
8+
'/hooks/use-locale/index',
9+
)}`,
1010
)
1111
}
1212

1313
export function transformDefaultLocale(
1414
options: Options,
1515
source: string,
16-
id: string
16+
id: string,
1717
): string | undefined {
18-
if (!id.match(getLocaleRE(options))) return
18+
if (!getLocaleRE(options).test(id)) return
1919
return source.replace(
2020
'locale/lang/en',
21-
`locale/lang/${options.defaultLocale}`
21+
`locale/lang/${options.defaultLocale}`,
2222
)
2323
}
2424

2525
export function getViteDepPlugin(options: Options): Plugin {
2626
const localeImporterRE = new RegExp(
2727
`${escapeStringRegexp(
28-
`node_modules/${options.lib}/`
29-
)}(es|lib)${escapeStringRegexp('/hooks/use-locale/index')}`
28+
`node_modules/${options.lib}/`,
29+
)}(es|lib)${escapeStringRegexp('/hooks/use-locale/index')}`,
3030
)
3131
const localePath = '/locale/lang/en'
3232
const localePathFixed = `/locale/lang/${options.defaultLocale}`
@@ -46,7 +46,7 @@ export function getViteDepPlugin(options: Options): Plugin {
4646
kind,
4747
resolveDir,
4848
})
49-
}
49+
},
5050
)
5151
},
5252
}

src/core/style.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { type ImportSpecifier, init, parse } from 'es-module-lexer'
1+
import { init, parse, type ImportSpecifier } from 'es-module-lexer'
22
import MagicString from 'magic-string'
3-
import { type Options } from '../index'
3+
import type { Options } from '../index'
44

55
type FormatType = 'cjs' | 'esm'
66

@@ -13,7 +13,7 @@ const formatMap = {
1313
esm: 'es',
1414
}
1515

16-
const multilineCommentsRE = /\/\*\s(.|[\n\r])*?\*\//gm
16+
const multilineCommentsRE = /\/\*\s(.|[\n\r])*?\*\//g
1717
const singlelineCommentsRE = /\/\/\s.*/g
1818

1919
function stripeComments(code: string) {
@@ -31,12 +31,12 @@ export function transformImportStyle(
3131
lib: string
3232
format: FormatType
3333
ignoreComponents: string[]
34-
}
34+
},
3535
): string | undefined {
3636
const { prefix, lib, format, ignoreComponents } = options
3737
const statement = stripeComments(source.slice(specifier.ss, specifier.se))
3838
const leftBracket = statement.indexOf('{')
39-
if (leftBracket > -1) {
39+
if (leftBracket !== -1) {
4040
// remove { } to get raw imported items. Maybe this will fail since there could be
4141
// special cases
4242
const identifiers = statement.slice(leftBracket + 1, statement.indexOf('}'))
@@ -50,14 +50,14 @@ export function transformImportStyle(
5050
if (useSource) {
5151
styleImports.push(
5252
`import '${lib}/${formatMap[format]}/components/${hyphenate(
53-
component
54-
)}/style/index'`
53+
component,
54+
)}/style/index'`,
5555
)
5656
} else {
5757
styleImports.push(
5858
`import '${lib}/${formatMap[format]}/components/${hyphenate(
59-
component
60-
)}/style/css'`
59+
component,
60+
)}/style/css'`,
6161
)
6262
}
6363
}
@@ -68,7 +68,7 @@ export function transformImportStyle(
6868

6969
export async function transformStyle(
7070
source: string,
71-
options: Options
71+
options: Options,
7272
): Promise<
7373
| {
7474
code: string

src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type FilterPattern } from '@rollup/pluginutils'
1+
import type { FilterPattern } from '@rollup/pluginutils'
22

33
export type Options = {
44
/**

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createFilter } from '@rollup/pluginutils'
22
import { createUnplugin, type UnpluginInstance } from 'unplugin'
3-
import { transformStyle } from './core/style'
43
import {
54
getLocaleRE,
65
getViteDepPlugin,
76
transformDefaultLocale,
87
} from './core/default-locale'
9-
import { type Options } from './core/types'
8+
import { transformStyle } from './core/style'
9+
import type { Options } from './core/types'
1010

1111
export type { Options }
1212

@@ -68,6 +68,6 @@ const unplugin: UnpluginInstance<Partial<Options>, false> = createUnplugin(
6868
},
6969
},
7070
}
71-
}
71+
},
7272
)
7373
export default unplugin

src/nuxt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Options } from './core/types'
1+
import type { Options } from './core/types'
22
import unplugin from '.'
33

44
// eslint-disable-next-line import/no-default-export

tests/transform.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { resolve } from 'node:path'
22
import glob from 'fast-glob'
3-
import { describe, expect, it } from 'vitest'
43
import { rollup } from 'rollup'
4+
import { describe, expect, it } from 'vitest'
55
import plugin from '../src/rollup'
66

77
async function getCode(file: string, plugin: any) {
@@ -41,7 +41,7 @@ describe('transform', () => {
4141
plugin({
4242
useSource,
4343
ignoreComponents: ['AutoResizer'],
44-
})
44+
}),
4545
)
4646
expect(code).toMatchSnapshot()
4747
})

0 commit comments

Comments
 (0)