Skip to content

Commit

Permalink
feat(gitignore): add config gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Sep 6, 2024
1 parent 0bc9a23 commit 95683e8
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@types/eslint": "^9.6.1",
"@unocss/eslint-plugin": "^0.62.3",
"@vitest/eslint-plugin": "^1.1.0",
"eslint-config-flat-gitignore": "^0.3.0",
"eslint-flat-config-utils": "^0.3.1",
"eslint-plugin-command": "^0.2.3",
"eslint-plugin-import-x": "^4.2.1",
Expand Down
26 changes: 26 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions scripts/generateType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { flatConfigsToRulesDTS } from 'eslint-typegen/core'
import {
command,
comments,
gitignore,
ignores,
imports,
javascript,
Expand Down Expand Up @@ -30,6 +31,7 @@ const configs = [
...comments(),
...ignores(),
...imports(),
...gitignore(),
...javascript(),
...jsdoc(),
...jsonc(),
Expand Down
9 changes: 9 additions & 0 deletions src/configs/gitignore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import createGitIgnore from 'eslint-config-flat-gitignore'
import type { ConfigGitIgnoreOptions, TypedConfigItem } from '../types'

export const gitignore = (options: ConfigGitIgnoreOptions = {}): TypedConfigItem[] => [
{
...createGitIgnore(options),
name: 'ntnyq/gitignore',
},
]
2 changes: 2 additions & 0 deletions src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export * from './perfectionist'

export * from './regexp'
export * from './unocss'

export * from './gitignore'
export * from './command'

export * from './vitest'
Expand Down
11 changes: 9 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
command,
comments,
gitignore,
ignores,
imports,
javascript,
Expand Down Expand Up @@ -41,7 +42,13 @@ import type { Arrayable, ConfigOptions, TypedConfigItem } from './types'
* Config factory
*/
export function ntnyq(options: ConfigOptions = {}, customConfig: Arrayable<TypedConfigItem> = []) {
const configs: TypedConfigItem[] = [
const configs: TypedConfigItem[] = []

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

configs.push(
/**
* Basic
*/
Expand All @@ -57,7 +64,7 @@ export function ntnyq(options: ConfigOptions = {}, customConfig: Arrayable<Typed
...resolveSubOptions(options, 'javascript'),
overrides: getOverrides(options, 'javascript'),
}),
]
)

if (options.unicorn ?? true) {
configs.push(
Expand Down
5 changes: 5 additions & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file Config options
*/

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

/**
Expand All @@ -22,6 +23,8 @@ export interface OptionsOverrides<

export type ConfigIgnoresOptions = string[]

export type ConfigGitIgnoreOptions = FlatGitignoreOptions

export interface ConfigJsdocOptions extends OptionsOverrides {}

export interface ConfigUnoCSSOptions extends OptionsOverrides {}
Expand Down Expand Up @@ -103,6 +106,8 @@ export interface ConfigOptions {

ignores?: ConfigIgnoresOptions

gitignore?: boolean | ConfigGitIgnoreOptions

imports?: ConfigImportsOptions

javascript?: ConfigJavaScriptOptions
Expand Down

0 comments on commit 95683e8

Please sign in to comment.