forked from unplugin/unplugin-auto-import
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Anthony Fu <[email protected]>
- Loading branch information
1 parent
bcdedd8
commit a9a57b0
Showing
6 changed files
with
101 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,3 +80,4 @@ dist | |
# IDE | ||
.idea | ||
auto-imports.d.ts | ||
.eslintrc-auto-import.json |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { ESLintGlobalsPropValue, ESLintrc, ImportsFlatMap } from '../types' | ||
|
||
interface ESLintConfigs { | ||
globals: Record<string, ESLintGlobalsPropValue> | ||
} | ||
|
||
// const __comment__ = 'Generated by `unplugin-auto-import`' | ||
|
||
export function generateESLintConfigs( | ||
imports: ImportsFlatMap, | ||
resolvedImports: ImportsFlatMap = {}, | ||
eslintrc: ESLintrc, | ||
) { | ||
const eslintConfigs: ESLintConfigs = { globals: {} }; | ||
|
||
[ | ||
...Object.entries(imports), | ||
...Object.entries(resolvedImports), | ||
] | ||
.sort((a, b) => a[0].localeCompare(b[0])) | ||
.forEach(([name]) => { eslintConfigs.globals[name] = eslintrc.globalsPropValue || true }) | ||
const jsonBody = JSON.stringify(eslintConfigs, null, 2) | ||
return jsonBody | ||
} |
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