Skip to content

Commit

Permalink
feat(command): support custom config command
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Sep 6, 2024
1 parent 95683e8 commit 0ac263e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/configs/command.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import createCommandPlugin from 'eslint-plugin-command/config'
import type { TypedConfigItem } from '../types'
import type { ConfigCommandOptions, TypedConfigItem } from '../types'

export const command = (): TypedConfigItem[] => [
export const command = (options: ConfigCommandOptions = {}): TypedConfigItem[] => [
{
...createCommandPlugin(),
...createCommandPlugin(options),
name: 'ntnyq/command',
},
]
12 changes: 10 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export function ntnyq(options: ConfigOptions = {}, customConfig: Arrayable<Typed
const configs: TypedConfigItem[] = []

if (options.gitignore ?? true) {
configs.push(...gitignore(resolveSubOptions(options, 'gitignore')))
configs.push(
...gitignore({
...resolveSubOptions(options, 'gitignore'),
}),
)
}

configs.push(
Expand Down Expand Up @@ -176,7 +180,11 @@ export function ntnyq(options: ConfigOptions = {}, customConfig: Arrayable<Typed
)
}
if (options.command ?? true) {
configs.push(...command())
configs.push(
...command({
...resolveSubOptions(options, 'command'),
}),
)
}

configs.push(...toArray(customConfig))
Expand Down
7 changes: 5 additions & 2 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import type { FlatGitignoreOptions } from 'eslint-config-flat-gitignore'
import type { ESLintPluginCommandOptions } from 'eslint-plugin-command/types'
import type { ParserOptions, TypedConfigItem } from './eslint'

/**
Expand All @@ -25,6 +26,8 @@ export type ConfigIgnoresOptions = string[]

export type ConfigGitIgnoreOptions = FlatGitignoreOptions

export type ConfigCommandOptions = ESLintPluginCommandOptions

export interface ConfigJsdocOptions extends OptionsOverrides {}

export interface ConfigUnoCSSOptions extends OptionsOverrides {}
Expand Down Expand Up @@ -96,8 +99,6 @@ export interface ConfigUnusedImportsOptions extends OptionsOverrides {}
* Config factory options
*/
export interface ConfigOptions {
command?: boolean

sortTsConfig?: boolean

sortI18nLocale?: boolean
Expand All @@ -106,6 +107,8 @@ export interface ConfigOptions {

ignores?: ConfigIgnoresOptions

command?: boolean | ConfigCommandOptions

gitignore?: boolean | ConfigGitIgnoreOptions

imports?: ConfigImportsOptions
Expand Down

0 comments on commit 0ac263e

Please sign in to comment.