-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-config): support for multiple src dirs and auto infer dir…
…ectories structure
- Loading branch information
Showing
11 changed files
with
177 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
import type { NuxtESLintConfigOptions, NuxtESLintConfigOptionsResolved } from '../flat' | ||
|
||
export function removeUndefined<T extends object>(obj: T): T { | ||
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) as T | ||
} | ||
|
||
export function resolveOptions( | ||
config: NuxtESLintConfigOptions, | ||
): NuxtESLintConfigOptionsResolved { | ||
if ('__resolved' in config) { | ||
return config as NuxtESLintConfigOptionsResolved | ||
} | ||
|
||
const dirs = { | ||
...config.dirs, | ||
} as NuxtESLintConfigOptionsResolved['dirs'] | ||
|
||
dirs.root ||= [process.cwd()] | ||
dirs.src ||= dirs.root | ||
dirs.pages ||= dirs.src.map(src => `${src}/pages`) | ||
dirs.layouts ||= dirs.src.map(src => `${src}/layouts`) | ||
dirs.components ||= dirs.src.map(src => `${src}/components`) | ||
dirs.composables ||= dirs.src.map(src => `${src}/composables`) | ||
dirs.plugins ||= dirs.src.map(src => `${src}/plugins`) | ||
dirs.modules ||= dirs.src.map(src => `${src}/modules`) | ||
dirs.middleware ||= dirs.src.map(src => `${src}/middleware`) | ||
dirs.servers ||= dirs.src.map(src => `${src}/servers`) | ||
|
||
const resolved: NuxtESLintConfigOptionsResolved = { | ||
features: { | ||
standalone: true, | ||
stylistic: false, | ||
...config.features, | ||
}, | ||
dirs, | ||
} | ||
|
||
Object.defineProperty(resolved, '__resolved', { value: true, enumerable: false }) | ||
|
||
return resolved | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.