Skip to content

Commit

Permalink
feat: provide filesOverride config
Browse files Browse the repository at this point in the history
  • Loading branch information
xsjcTony committed Nov 28, 2023
1 parent 36ce3f5 commit f880077
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/configs/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const importConfig = async (options: ImportOptions = {}): Promise<FlatCon
return [
{
name: 'aelita:import',
files,
...files && files,
plugins: {
// @ts-expect-error - no dts file available
'import': await interopDefault(import('eslint-plugin-import'))
Expand Down
2 changes: 1 addition & 1 deletion src/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const javascriptStylisticRules: FlatConfigItem['rules'] = {
export const javascript = ({ files, overrides }: JavascriptOptions = {}): FlatConfigItem[] => [
{
name: 'aelita:javascript',
files,
...files && files,
languageOptions: {
ecmaVersion: 'latest',
globals: {
Expand Down
6 changes: 3 additions & 3 deletions src/configs/unocss.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { interopDefault } from '../utils'
import type { OptionsConfig, FlatConfigItem, OptionsUnocss } from '../types'
import type { OptionsConfig, FlatConfigItem, OptionsUnocss, OptionsFiles } from '../types'


interface UnocssOptions extends OptionsUnocss {
interface UnocssOptions extends OptionsUnocss, OptionsFiles {
overrides?: NonNullable<OptionsConfig['overrides']>['unocss']
}

Expand All @@ -21,7 +21,7 @@ export const unocss = async ({
}: UnocssOptions): Promise<FlatConfigItem[]> => [
{
name: 'aelita:playwright',
files,
...files && files,
plugins: {
unocss: await interopDefault(import('@unocss/eslint-plugin'))
},
Expand Down
26 changes: 18 additions & 8 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const defineConfig = async (
unocss: enableUnocss = isPackageExists('unocss'),
gitignore: enableGitignore = true,
overrides = {},
componentExtensions = []
componentExtensions = [],
filesOverride = {}
} = options


Expand Down Expand Up @@ -91,14 +92,18 @@ export const defineConfig = async (
*/
configs.push(
ignores(),
javascript({ overrides: overrides.javascript }),
javascript({
overrides: overrides.javascript,
files: filesOverride.javascript
}),
importConfig({
typescript: !!enableTypescript,
vue: !!enableVue,
overrides: {
'import': overrides.import,
importTypescript: overrides.importTypescript
}
},
files: filesOverride.import
})
)

Expand All @@ -110,7 +115,8 @@ export const defineConfig = async (
configs.push(typescript({
...typeof enableTypescript !== 'boolean' && enableTypescript,
componentExtensions,
overrides: overrides.typescript
overrides: overrides.typescript,
files: filesOverride.typescript
}))
}

Expand All @@ -125,7 +131,8 @@ export const defineConfig = async (
overrides: {
vue: overrides.vue,
vueAccessibility: overrides.vueAccessibility
}
},
files: filesOverride.vue
}))
}

Expand All @@ -140,7 +147,8 @@ export const defineConfig = async (
overrides: {
react: overrides.react,
jsxA11y: overrides.jsxA11y
}
},
files: filesOverride.react
}))
}

Expand All @@ -150,7 +158,8 @@ export const defineConfig = async (
*/
if (enablePlaywright) {
configs.push(playwright({
overrides: overrides.playwright
overrides: overrides.playwright,
files: filesOverride.playwright
}))
}

Expand All @@ -161,7 +170,8 @@ export const defineConfig = async (
if (enableUnocss) {
configs.push(unocss({
...typeof enableUnocss !== 'boolean' && enableUnocss,
overrides: overrides.unocss
overrides: overrides.unocss,
files: filesOverride.unocss
}))
}

Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { defineConfig } from './factory'
export * from './factory'
export * from './utils'
export * from './globs'
export * from './plugins'
export * from './configs'
export type * from './types'

Expand Down
15 changes: 14 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export interface OptionsReact extends OptionsHasTypeScript, OptionsFiles {
}


export interface OptionsUnocss extends OptionsFiles {
export interface OptionsUnocss {
attributify?: boolean
}

Expand Down Expand Up @@ -671,4 +671,17 @@ export interface OptionsConfig extends OptionsComponentExtensions {
playwright?: FlatConfigItem['rules']
unocss?: FlatConfigItem['rules']
}

/**
* Customize `files`
*/
filesOverride?: {
import?: string[]
javascript?: string[]
typescript?: string[]
vue?: string[]
react?: string[]
unocss?: string[]
playwright?: string[]
}
}

0 comments on commit f880077

Please sign in to comment.