Skip to content

Commit 314ae40

Browse files
committed
chore: update lint config
1 parent d15a1c6 commit 314ae40

34 files changed

+2837
-2031
lines changed

.vscode/settings.json

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
{
2-
"editor.defaultFormatter": "esbenp.prettier-vscode",
3-
"editor.formatOnSave": true,
4-
5-
"eslint.experimental.useFlatConfig": true
2+
"prettier.enable": false,
3+
"editor.formatOnSave": false,
4+
"eslint.experimental.useFlatConfig": true,
5+
"eslint.validate": [
6+
"javascript",
7+
"javascriptreact",
8+
"typescript",
9+
"typescriptreact",
10+
"mdx",
11+
"html",
12+
"markdown",
13+
"json",
14+
"jsonc",
15+
"yaml",
16+
"github-actions-workflow",
17+
"css"
18+
],
19+
"editor.codeActionsOnSave": {
20+
"source.fixAll.eslint": "explicit"
21+
},
22+
"eslint.codeActionsOnSave.rules": [
23+
"!unused-imports/no-unused-imports",
24+
"*"
25+
],
26+
"eslint.rules.customizations": [
27+
{ "rule": "@stylistic/*", "severity": "off" },
28+
{ "rule": "simple-import-sort/*", "severity": "off" },
29+
{ "rule": "import/first", "severity": "off" },
30+
{ "rule": "import/newline-after-import", "severity": "off" },
31+
{ "rule": "import/no-duplicates", "severity": "off" },
32+
{ "rule": "antfu/import-dedupe", "severity": "off" },
33+
{ "rule": "format/prettier", "severity": "off" }
34+
],
35+
"typescript.tsdk": "node_modules/typescript/lib"
636
}

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ ni -D unocss-preset-animations unocss-preset-shadcn
2323

2424
```ts
2525
// unocss.config.ts
26-
import { defineConfig, presetUno } from "unocss"
27-
import presetAnimations from "unocss-preset-animations"
28-
import { presetShadcn } from "unocss-preset-shadcn"
26+
import { defineConfig, presetUno } from "unocss";
27+
import presetAnimations from "unocss-preset-animations";
28+
import { presetShadcn } from "unocss-preset-shadcn";
2929

3030
export default defineConfig({
3131
presets: [
@@ -48,7 +48,7 @@ export default defineConfig({
4848
],
4949
},
5050
},
51-
})
51+
});
5252
```
5353

5454
> [!IMPORTANT]
@@ -69,13 +69,13 @@ export default defineConfig({
6969
## Code to copy
7070

7171
```ts
72-
import { clsx } from "clsx"
73-
import { twMerge } from "tailwind-merge"
72+
import { clsx } from "clsx";
73+
import { twMerge } from "tailwind-merge";
7474

75-
import type { ClassValue } from "clsx"
75+
import type { ClassValue } from "clsx";
7676

7777
export function cn(...inputs: ClassValue[]) {
78-
return twMerge(clsx(inputs))
78+
return twMerge(clsx(inputs));
7979
}
8080
```
8181

@@ -147,17 +147,17 @@ Preview the [demo](https://unocss-preset-shadcn.vercel.app).
147147
If you want to use a dynamic theme, you can pass an array of theme objects to `presetShadcn`:
148148

149149
```ts
150-
import { defineConfig, presetUno, UserConfig } from "unocss"
151-
import presetAnimations from "unocss-preset-animations"
152-
import { builtinColors, presetShadcn } from "unocss-preset-shadcn"
150+
import { defineConfig, presetUno, UserConfig } from "unocss";
151+
import presetAnimations from "unocss-preset-animations";
152+
import { builtinColors, presetShadcn } from "unocss-preset-shadcn";
153153

154154
export default defineConfig({
155155
presets: [
156156
presetUno(),
157157
presetAnimations(),
158158
presetShadcn(builtinColors.map((c) => ({ color: c }))),
159159
],
160-
})
160+
});
161161
```
162162

163163
Add a theme sync script to your [index.html](./playground/index.html).

build.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { defineBuildConfig } from "unbuild"
1+
import { defineBuildConfig } from 'unbuild'
22

33
export default defineBuildConfig({
4-
entries: ["src/index"],
4+
entries: ['src/index'],
55
declaration: true,
66
clean: true,
77
rollup: {

eslint.config.js

+9-46
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,16 @@
1-
import process from "node:process"
2-
import ts from "@typescript-eslint/eslint-plugin"
3-
import tsParser from "@typescript-eslint/parser"
4-
import prettier from "eslint-config-prettier"
5-
import unicorn from "eslint-plugin-unicorn"
1+
import hyoban from 'eslint-config-hyoban'
62

7-
const files = ["src/**/*.{ts,tsx}"]
8-
const languageOptions = {
9-
parser: tsParser,
10-
parserOptions: {
11-
project: true,
12-
tsconfigRootDir: process.cwd(),
13-
},
14-
}
15-
const linterOptions = {
16-
reportUnusedDisableDirectives: true,
17-
}
18-
const plugins = {
19-
"@typescript-eslint": ts,
20-
prettier,
21-
unicorn,
22-
}
23-
24-
export default [
3+
export default hyoban(
254
{
26-
files,
27-
languageOptions,
28-
linterOptions,
29-
plugins,
30-
rules: {
31-
...ts.configs["strict-type-checked"]?.rules,
32-
"@typescript-eslint/no-non-null-assertion": "off",
33-
"@typescript-eslint/no-unused-vars": "off",
34-
"@typescript-eslint/no-import-type-side-effects": "error",
35-
36-
...unicorn.configs.recommended.rules,
37-
"unicorn/prevent-abbreviations": "off",
38-
"unicorn/catch-error-name": "off",
39-
"unicorn/prefer-top-level-await": "off",
40-
"unicorn/no-null": "off",
41-
},
5+
ignores: [
6+
'**/vite.config.ts',
7+
'**/uno.config.ts',
8+
],
429
},
43-
// disable formatting rules, make sure to put this last
4410
{
45-
files,
46-
languageOptions,
47-
linterOptions,
48-
plugins,
11+
files: ['**/package.json'],
4912
rules: {
50-
...prettier.rules,
13+
'package-json/valid-package-def': 'off',
5114
},
5215
},
53-
]
16+
)

examples/shadcn-svelte/package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
22
"name": "shadcn-svelte",
3+
"type": "module",
34
"version": "0.0.1",
45
"private": true,
56
"scripts": {
6-
"dev": "vite dev",
77
"build": "vite build",
8-
"preview": "vite preview",
98
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
9+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
10+
"dev": "vite dev",
11+
"preview": "vite preview"
12+
},
13+
"dependencies": {
14+
"@unocss/reset": "^0.58.5",
15+
"bits-ui": "^0.19.5",
16+
"clsx": "^2.1.0",
17+
"lucide-svelte": "^0.352.0",
18+
"tailwind-merge": "^2.2.1",
19+
"tailwind-variants": "^0.2.0"
1120
},
1221
"devDependencies": {
1322
"@sveltejs/adapter-auto": "^3.1.1",
14-
"@sveltejs/kit": "^2.5.2",
23+
"@sveltejs/kit": "^2.5.3",
1524
"@sveltejs/vite-plugin-svelte": "^3.0.2",
1625
"@unocss/extractor-svelte": "^0.58.5",
1726
"svelte": "^4.2.12",
1827
"svelte-check": "^3.6.6",
1928
"tslib": "^2.6.2",
20-
"typescript": "^5.3.3",
29+
"typescript": "^5.4.2",
2130
"unocss": "^0.58.5",
2231
"unocss-preset-animations": "^1.0.1",
2332
"unocss-preset-shadcn": "workspace:^",
24-
"vite": "^5.1.4"
25-
},
26-
"type": "module",
27-
"dependencies": {
28-
"@unocss/reset": "^0.58.5",
29-
"bits-ui": "^0.18.4",
30-
"clsx": "^2.1.0",
31-
"lucide-svelte": "^0.343.0",
32-
"tailwind-merge": "^2.2.1",
33-
"tailwind-variants": "^0.2.0"
33+
"vite": "^5.1.5"
3434
}
3535
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
1-
import { tv } from "tailwind-variants"
2-
3-
import Root from "./button.svelte"
4-
5-
import type { Button as ButtonPrimitive } from "bits-ui"
6-
import type { VariantProps } from "tailwind-variants"
1+
import type { Button as ButtonPrimitive } from 'bits-ui'
2+
import type { VariantProps } from 'tailwind-variants'
3+
import { tv } from 'tailwind-variants'
74

85
const buttonVariants = tv({
9-
base: "inline-flex items-center justify-center rounded-md text-sm font-medium whitespace-nowrap ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
6+
base: 'inline-flex items-center justify-center rounded-md text-sm font-medium whitespace-nowrap ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
107
variants: {
118
variant: {
12-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
9+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
1310
destructive:
14-
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
11+
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
1512
outline:
16-
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
17-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18-
ghost: "hover:bg-accent hover:text-accent-foreground",
19-
link: "text-primary underline-offset-4 hover:underline",
13+
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
14+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
15+
ghost: 'hover:bg-accent hover:text-accent-foreground',
16+
link: 'text-primary underline-offset-4 hover:underline',
2017
},
2118
size: {
22-
default: "h-10 px-4 py-2",
23-
sm: "h-9 rounded-md px-3",
24-
lg: "h-11 rounded-md px-8",
25-
icon: "h-10 w-10",
19+
default: 'h-10 px-4 py-2',
20+
sm: 'h-9 rounded-md px-3',
21+
lg: 'h-11 rounded-md px-8',
22+
icon: 'h-10 w-10',
2623
},
2724
},
2825
defaultVariants: {
29-
variant: "default",
30-
size: "default",
26+
variant: 'default',
27+
size: 'default',
3128
},
3229
})
3330

34-
type Variant = VariantProps<typeof buttonVariants>["variant"]
35-
type Size = VariantProps<typeof buttonVariants>["size"]
31+
type Variant = VariantProps<typeof buttonVariants>['variant']
32+
type Size = VariantProps<typeof buttonVariants>['size']
3633

3734
type Props = ButtonPrimitive.Props & {
3835
variant?: Variant
@@ -42,12 +39,12 @@ type Props = ButtonPrimitive.Props & {
4239
type Events = ButtonPrimitive.Events
4340

4441
export {
45-
Root,
46-
type Props,
47-
type Events,
4842
//
49-
Root as Button,
50-
type Props as ButtonProps,
5143
type Events as ButtonEvents,
44+
type Props as ButtonProps,
5245
buttonVariants,
46+
type Events,
47+
type Props,
5348
}
49+
50+
export { default as Button, default as Root } from './button.svelte'
+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
// place files you want to import through the `$lib` alias in this folder.
2+
// eslint-disable-next-line unicorn/no-empty-file

examples/shadcn-svelte/src/lib/utils.ts

+28-30
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { clsx } from "clsx"
2-
import { cubicOut } from "svelte/easing"
3-
import { twMerge } from "tailwind-merge"
4-
5-
import type { ClassValue } from "clsx"
6-
import type { TransitionConfig } from "svelte/transition"
1+
import type { ClassValue } from 'clsx'
2+
import { clsx } from 'clsx'
3+
import { cubicOut } from 'svelte/easing'
4+
import type { TransitionConfig } from 'svelte/transition'
5+
import { twMerge } from 'tailwind-merge'
76

87
export function cn(...inputs: ClassValue[]) {
98
return twMerge(clsx(inputs))
@@ -16,35 +15,34 @@ type FlyAndScaleParams = {
1615
duration?: number
1716
}
1817

19-
export const flyAndScale = (
20-
node: Element,
21-
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 },
22-
): TransitionConfig => {
23-
const style = getComputedStyle(node)
24-
const transform = style.transform === "none" ? "" : style.transform
18+
function scaleConversion(valueA: number, scaleA: [number, number], scaleB: [number, number]) {
19+
const [minA, maxA] = scaleA
20+
const [minB, maxB] = scaleB
2521

26-
const scaleConversion = (
27-
valueA: number,
28-
scaleA: [number, number],
29-
scaleB: [number, number],
30-
) => {
31-
const [minA, maxA] = scaleA
32-
const [minB, maxB] = scaleB
22+
const percentage = (valueA - minA) / (maxA - minA)
23+
const valueB = percentage * (maxB - minB) + minB
3324

34-
const percentage = (valueA - minA) / (maxA - minA)
35-
const valueB = percentage * (maxB - minB) + minB
25+
return valueB
26+
}
3627

37-
return valueB
38-
}
28+
function styleToString(style: Record<string, number | string | undefined>): string {
29+
// eslint-disable-next-line unicorn/no-array-reduce
30+
return Object.keys(style).reduce((str, key) => {
31+
if (style[key] === undefined)
32+
return str
33+
return `${str}${key}:${style[key]};`
34+
}, '')
35+
}
3936

40-
const styleToString = (
41-
style: Record<string, number | string | undefined>,
42-
): string => {
43-
return Object.keys(style).reduce((str, key) => {
44-
if (style[key] === undefined) return str
45-
return str + `${key}:${style[key]};`
46-
}, "")
37+
export function flyAndScale(node: Element, params?: FlyAndScaleParams): TransitionConfig {
38+
params = params ?? {
39+
y: -8,
40+
x: 0,
41+
start: 0.95,
42+
duration: 150,
4743
}
44+
const style = getComputedStyle(node)
45+
const transform = style.transform === 'none' ? '' : style.transform
4846

4947
return {
5048
duration: params.duration ?? 200,

examples/shadcn-svelte/svelte.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import adapter from "@sveltejs/adapter-auto"
2-
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"
1+
import adapter from '@sveltejs/adapter-auto'
2+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
33

44
/** @type {import('@sveltejs/kit').Config} */
55
const config = {
@@ -13,7 +13,7 @@ const config = {
1313
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
1414
adapter: adapter(),
1515
alias: {
16-
$lib: "./src/lib",
16+
$lib: './src/lib',
1717
},
1818
},
1919
}

0 commit comments

Comments
 (0)