Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 31, 2023
1 parent a56a240 commit fa3f873
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ import antfu from '@antfu/eslint-config'
export default antfu({
typescript: {
tsconfigPath: 'tsconfig.json',
// or if you have multiple tsconfigs
tsconfigPath: ['tsconfig.json', 'tsconfig.node.json'],
},
})
```
Expand Down
11 changes: 4 additions & 7 deletions src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import process from 'node:process'
import type { ConfigItem, OptionsComponentExts, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from '../types'
import { GLOB_SRC } from '../globs'
import { parserTs, pluginAntfu, pluginImport, pluginTs } from '../plugins'
import { renameRules } from '../utils'
import { renameRules, toArray } from '../utils'

export function typescript(
options?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions,
Expand All @@ -11,7 +11,6 @@ export function typescript(
componentExts = [],
overrides = {},
parserOptions = {},
tsconfigPath: tsc,
} = options ?? {}

const typeAwareRules: ConfigItem['rules'] = {
Expand All @@ -36,11 +35,9 @@ export function typescript(
'ts/unbound-method': 'error',
}

const tsconfigPath = typeof tsc === 'string' && tsc.trim()
? [tsc]
: Array.isArray(tsc) && tsc.length > 0
? tsc
: null
const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
: undefined

return [
{
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export function renameRules(rules: Record<string, any>, from: string, to: string
}),
)
}

export function toArray<T>(value: T | T[]): T[] {
return Array.isArray(value) ? value : [value]
}

0 comments on commit fa3f873

Please sign in to comment.