Skip to content

Commit

Permalink
feat: add unocss plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Aug 10, 2023
1 parent ca2d16e commit c95e85d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 12 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export * from './src/markdown.js'
export * from './src/presets.js'
export * from './src/prettier.js'
export * from './src/typescript.js'
export * from './src/unocss.js'
export * from './src/vue.js'
export * from './src/yml.js'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@eslint/js": "^8.46.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@unocss/eslint-plugin": "^0.55.0",
"eslint-config-prettier": "^9.0.0",
"eslint-define-config": "^1.23.0",
"eslint-plugin-antfu": "^0.40.2",
Expand Down
58 changes: 50 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { markdown } from './markdown.js'
import { prettier } from './prettier.js'
import { GLOB_EXCLUDE } from './shared.js'
import { typescript } from './typescript.js'
import { unocss } from './unocss.js'
import { vue } from './vue.js'
import { yml } from './yml.js'

Expand All @@ -30,30 +31,35 @@ export const basic = [
]

/** @type { FlatESLintConfigItem[] } */
export const all = [...vue, ...basic, ...prettier]
export const all = [...basic, ...vue, ...unocss, ...prettier]

/** @type {(config?: FlatESLintConfigItem | FlatESLintConfigItem[], enables?: Partial<{
* vue: boolean
* prettier: boolean
* markdown: boolean
* unocss: boolean
* }>) => FlatESLintConfigItem[]} */
export function sxzz(
config = [],
{
vue: enableVue = true,
prettier: enablePrettier = true,
markdown: enableMarkdown = true,
unocss: enableUnocss = false,
} = {}
) {
const configs = []
configs.push(...basic)
if (enableVue !== false) {
if (enableVue) {
configs.push(...vue)
}
if (enableMarkdown !== false) {
if (enableMarkdown) {
configs.push(...markdown)
}
if (enablePrettier !== false) {
if (enableUnocss) {
configs.push(...unocss)
}
if (enablePrettier) {
configs.push(...prettier)
}
if (Object.keys(config).length > 0) {
Expand Down
13 changes: 13 additions & 0 deletions src/unocss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unocssPlugin from '@unocss/eslint-plugin'

/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
export const unocss = [
{
plugins: {
'@unocss': unocssPlugin,
},
rules: {
...unocssPlugin.configs.recommended.rules,
},
},
]

0 comments on commit c95e85d

Please sign in to comment.