Skip to content

Commit

Permalink
chore(eslint-config): wrap remaining configs with `requireOf (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrbrown authored Dec 27, 2024
1 parent 5bc17fd commit bccde3a
Show file tree
Hide file tree
Showing 9 changed files with 530 additions and 447 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilly-pots-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bfra.me/eslint-config": patch
---

Wrap remaining configs with `requireOf`.

21 changes: 15 additions & 6 deletions packages/eslint-config/src/configs/command.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import type {Config} from '../config'
import config from 'eslint-plugin-command/config'
import {interopDefault} from '../plugins'
import {requireOf} from '../require-of'
import {fallback} from './fallback'

export async function command(): Promise<Config[]> {
return [
{
...config(),
name: '@bfra.me/command',
return requireOf(
['eslint-plugin-command'],
async () => {
const config = await interopDefault(import('eslint-plugin-command/config'))
return [
{
...config(),
name: '@bfra.me/command',
},
]
},
]
fallback,
)
}
43 changes: 26 additions & 17 deletions packages/eslint-config/src/configs/imports.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
import type {Config} from '../config'
import {importX as pluginImportX} from '../plugins'
import {interopDefault} from '../plugins'
import {requireOf} from '../require-of'
import {fallback} from './fallback'

export async function imports(): Promise<Config[]> {
return [
{
name: '@bfra.me/imports',
plugins: {
'import-x': pluginImportX as any,
},
rules: {
'import-x/no-named-default': 'error',
'import-x/first': 'error',
'import-x/no-duplicates': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-self-import': 'error',
'import-x/no-useless-path-segments': 'error',
'import-x/no-webpack-loader-syntax': 'error',
},
return requireOf(
['eslint-plugin-import-x'],
async () => {
const pluginImportX = await interopDefault(import('eslint-plugin-import-x'))
return [
{
name: '@bfra.me/imports',
plugins: {
'import-x': pluginImportX as any,
},
rules: {
'import-x/no-named-default': 'error',
'import-x/first': 'error',
'import-x/no-duplicates': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-self-import': 'error',
'import-x/no-useless-path-segments': 'error',
'import-x/no-webpack-loader-syntax': 'error',
},
},
]
},
]
fallback,
)
}
Loading

0 comments on commit bccde3a

Please sign in to comment.