Skip to content

Commit

Permalink
feat(eslint): add optional unicorn rules
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJume committed Jun 27, 2024
1 parent 41c4e80 commit 46954db
Show file tree
Hide file tree
Showing 4 changed files with 337 additions and 181 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type antfu from '@antfu/eslint-config'

declare function eslintConfig(config: {
nuxt: boolean
unicorn?: boolean
tsconfigPath?: string[]
/** @deprecated */ configs?: TypedFlatConfigItem[]
}): ReturnType<typeof antfu>
Expand Down
9 changes: 8 additions & 1 deletion packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import antfu from '@antfu/eslint-config'
import { FlatCompat } from '@eslint/eslintrc'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginCompat from 'eslint-plugin-compat'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'

import github from './github.js'
import nuxtRules from './nuxt.js'
Expand All @@ -12,7 +13,12 @@ const compat = new FlatCompat()

/** @type {import('./index.d.ts').eslintConfig} */
export function eslintConfig(
{ nuxt, tsconfigPath, configs } = { nuxt: false, tsconfigPath: undefined, configs: undefined },
{ nuxt, tsconfigPath, unicorn, configs } = {
nuxt: false,
tsconfigPath: undefined,
unicorn: false,
configs: undefined,
},
) {
return antfu({
stylistic: false,
Expand Down Expand Up @@ -50,6 +56,7 @@ export function eslintConfig(
})
.prepend(github)
.append(nuxt ? nuxtRules : [])
.append(unicorn && eslintPluginUnicorn.configs['flat/recommended'])
.append({
name: 'falcondev/rules',
rules: {
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"@shopify/eslint-plugin": "^45.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-compat": "^5.0.0",
"eslint-plugin-github": "^5.0.1"
"eslint-plugin-github": "^5.0.1",
"eslint-plugin-unicorn": "^54.0.0"
},
"devDependencies": {
"@types/eslint": "^8.56.10",
Expand Down
Loading

0 comments on commit 46954db

Please sign in to comment.