Skip to content

Commit 8687551

Browse files
committed
chore: update format and lint config
1 parent 0bf7133 commit 8687551

22 files changed

+896
-725
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66
on:
77
push:
88
tags:
9-
- 'v*'
9+
- "v*"
1010

1111
jobs:
1212
release:

.vscode/settings.json

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,6 @@
11
{
2-
// Enable the ESlint flat config support
3-
"eslint.experimental.useFlatConfig": true,
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
44

5-
// Disable the default formatter, use eslint instead
6-
"prettier.enable": false,
7-
"editor.formatOnSave": false,
8-
9-
// Auto fix
10-
"editor.codeActionsOnSave": {
11-
"source.fixAll": "explicit",
12-
"source.organizeImports": "never"
13-
},
14-
15-
// Silent the stylistic rules in you IDE, but still auto fix them
16-
"eslint.rules.customizations": [
17-
{ "rule": "style/*", "severity": "off" },
18-
{ "rule": "*-indent", "severity": "off" },
19-
{ "rule": "*-spacing", "severity": "off" },
20-
{ "rule": "*-spaces", "severity": "off" },
21-
{ "rule": "*-order", "severity": "off" },
22-
{ "rule": "*-dangle", "severity": "off" },
23-
{ "rule": "*-newline", "severity": "off" },
24-
{ "rule": "*quotes", "severity": "off" },
25-
{ "rule": "*semi", "severity": "off" }
26-
],
27-
28-
// Enable eslint for all supported languages
29-
"eslint.validate": [
30-
"javascript",
31-
"javascriptreact",
32-
"typescript",
33-
"typescriptreact",
34-
"vue",
35-
"html",
36-
"markdown",
37-
"json",
38-
"jsonc",
39-
"yaml"
40-
]
5+
"eslint.experimental.useFlatConfig": true
416
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ ni -D unocss-preset-shadcn
1919

2020
```ts
2121
// unocss.config.ts
22-
import { defineConfig, presetUno } from 'unocss'
23-
import { presetShadcn } from 'unocss-preset-shadcn'
22+
import { defineConfig, presetUno } from "unocss"
23+
import { presetShadcn } from "unocss-preset-shadcn"
2424

2525
export default defineConfig({
2626
presets: [
2727
presetUno(),
2828
presetShadcn({
29-
color: 'red',
29+
color: "red",
3030
}),
3131
],
3232
})

build.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { defineBuildConfig } from 'unbuild'
1+
import { defineBuildConfig } from "unbuild"
22

33
export default defineBuildConfig({
4-
entries: [
5-
'src/index',
6-
],
4+
entries: ["src/index"],
75
declaration: true,
86
clean: true,
97
rollup: {

eslint.config.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,53 @@
1-
// @ts-check
2-
import antfu from '@antfu/eslint-config'
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"
36

4-
export default antfu(
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 [
525
{
6-
ignores: [
7-
// eslint ignore globs here
8-
'playground/package.json',
9-
],
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+
},
1042
},
43+
// disable formatting rules, make sure to put this last
1144
{
45+
files,
46+
languageOptions,
47+
linterOptions,
48+
plugins,
1249
rules: {
13-
// overrides
50+
...prettier.rules,
1451
},
1552
},
16-
)
53+
]

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@
3838
"scripts": {
3939
"build": "unbuild",
4040
"dev": "unbuild --stub",
41-
"lint": "eslint .",
41+
"lint": "eslint --max-warnings 0 .",
4242
"prepublishOnly": "nr build",
4343
"release": "bumpp && npm publish",
4444
"start": "esno src/index.ts",
4545
"test": "vitest",
4646
"typecheck": "tsc --noEmit",
47+
"format": "prettier --write .",
48+
"format:check": "prettier --check .",
4749
"prepare": "simple-git-hooks"
4850
},
4951
"peerDependencies": {
@@ -56,12 +58,18 @@
5658
"@antfu/eslint-config": "^2.1.2",
5759
"@antfu/ni": "^0.21.12",
5860
"@antfu/utils": "^0.7.6",
61+
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
5962
"@types/node": "^20.10.1",
63+
"@typescript-eslint/eslint-plugin": "^6.13.1",
64+
"@typescript-eslint/parser": "^6.13.1",
6065
"bumpp": "^9.2.0",
6166
"eslint": "^8.54.0",
67+
"eslint-config-prettier": "^9.0.0",
68+
"eslint-plugin-unicorn": "^49.0.0",
6269
"esno": "^4.0.0",
6370
"lint-staged": "^15.1.0",
6471
"pnpm": "^8.11.0",
72+
"prettier": "^3.1.0",
6573
"rimraf": "^5.0.5",
6674
"simple-git-hooks": "^2.9.0",
6775
"typescript": "^5.3.2",
@@ -70,9 +78,6 @@
7078
"vitest": "^1.0.0-beta.6"
7179
},
7280
"simple-git-hooks": {
73-
"pre-commit": "pnpm lint-staged"
74-
},
75-
"lint-staged": {
76-
"*": "eslint --fix"
81+
"pre-commit": "pnpm run format:check && pnpm run lint && pnpm run typecheck"
7782
}
7883
}

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
"preview": "vite preview"
2727
},
2828
"type": "module"
29-
}
29+
}

playground/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button } from '@/components/ui/button'
1+
import { Button } from "@/components/ui/button"
22

33
export default function ButtonDemo() {
44
return <Button>Button</Button>
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
import * as React from 'react'
2-
import { Slot } from '@radix-ui/react-slot'
3-
import { type VariantProps, cva } from 'class-variance-authority'
1+
import { cn } from "@/lib/utils"
2+
import { Slot } from "@radix-ui/react-slot"
3+
import { cva } from "class-variance-authority"
4+
import * as React from "react"
45

5-
import { cn } from '@/lib/utils'
6+
import type { VariantProps } from "class-variance-authority"
67

78
const buttonVariants = cva(
8-
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium 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',
9+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium 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",
910
{
1011
variants: {
1112
variant: {
12-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
13+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
1314
destructive:
14-
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
15+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
1516
outline:
16-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
17+
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
1718
secondary:
18-
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
19-
ghost: 'hover:bg-accent hover:text-accent-foreground',
20-
link: 'text-primary underline-offset-4 hover:underline',
19+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
20+
ghost: "hover:bg-accent hover:text-accent-foreground",
21+
link: "text-primary underline-offset-4 hover:underline",
2122
},
2223
size: {
23-
default: 'h-10 px-4 py-2',
24-
sm: 'h-9 rounded-md px-3',
25-
lg: 'h-11 rounded-md px-8',
26-
icon: 'h-10 w-10',
24+
default: "h-10 px-4 py-2",
25+
sm: "h-9 rounded-md px-3",
26+
lg: "h-11 rounded-md px-8",
27+
icon: "h-10 w-10",
2728
},
2829
},
2930
defaultVariants: {
30-
variant: 'default',
31-
size: 'default',
31+
variant: "default",
32+
size: "default",
3233
},
3334
},
3435
)
3536

3637
export interface ButtonProps
3738
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
38-
VariantProps<typeof buttonVariants> {
39+
VariantProps<typeof buttonVariants> {
3940
asChild?: boolean
4041
}
4142

4243
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
4344
({ className, variant, size, asChild = false, ...props }, ref) => {
44-
const Comp = asChild ? Slot : 'button'
45+
const Comp = asChild ? Slot : "button"
4546
return (
4647
<Comp
4748
className={cn(buttonVariants({ variant, size, className }))}
@@ -51,6 +52,6 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
5152
)
5253
},
5354
)
54-
Button.displayName = 'Button'
55+
Button.displayName = "Button"
5556

5657
export { Button, buttonVariants }

playground/src/lib/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { ClassValue } from 'clsx'
2-
import { clsx } from 'clsx'
3-
import { twMerge } from 'tailwind-merge'
1+
import { clsx } from "clsx"
2+
import { twMerge } from "tailwind-merge"
3+
4+
import type { ClassValue } from "clsx"
45

56
export function cn(...inputs: ClassValue[]) {
67
return twMerge(clsx(inputs))

playground/src/main.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom/client'
3-
import App from './App.tsx'
4-
import '@unocss/reset/tailwind.css'
5-
import 'virtual:uno.css'
1+
import React from "react"
2+
import ReactDOM from "react-dom/client"
63

7-
ReactDOM.createRoot(document.getElementById('root')!).render(
4+
import App from "./App.tsx"
5+
6+
import "@unocss/reset/tailwind.css"
7+
import "virtual:uno.css"
8+
9+
ReactDOM.createRoot(document.getElementById("root")!).render(
810
<React.StrictMode>
911
<App />
1012
</React.StrictMode>,

playground/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"module": "ESNext",
99
"moduleResolution": "bundler",
1010
"paths": {
11-
"@/*": [
12-
"./src/*"
13-
]
11+
"@/*": ["./src/*"]
1412
},
1513
"resolveJsonModule": true,
1614
"allowImportingTsExtensions": true,

playground/uno.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { defineConfig, presetUno } from 'unocss'
2-
import { presetShadcn } from 'unocss-preset-shadcn'
1+
import { defineConfig, presetUno } from "unocss"
2+
import { presetShadcn } from "unocss-preset-shadcn"
33

44
export default defineConfig({
55
presets: [
66
presetUno(),
77
presetShadcn({
8-
color: 'red',
8+
color: "red",
99
}),
1010
],
1111
})

playground/vite.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import path from 'node:path'
2-
import { defineConfig } from 'vite'
3-
import react from '@vitejs/plugin-react'
4-
import UnoCSS from 'unocss/vite'
1+
import path from "node:path"
2+
import react from "@vitejs/plugin-react"
3+
import UnoCSS from "unocss/vite"
4+
import { defineConfig } from "vite"
55

66
export default defineConfig({
77
plugins: [react(), UnoCSS()],
88
resolve: {
99
alias: {
10-
'@': path.resolve(__dirname, './src'),
10+
"@": path.resolve(__dirname, "./src"),
1111
},
1212
},
1313
})

0 commit comments

Comments
 (0)