-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update all packages to use
createConfig
(#375)
* Update all packages to use `createConfig` * Update main config to use `createConfig` * Update all READMEs
- Loading branch information
Showing
17 changed files
with
332 additions
and
391 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,64 @@ | ||
declare module '@metamask/eslint-config' { | ||
import type { Linter } from 'eslint'; | ||
|
||
const config: Linter.Config[]; | ||
/** | ||
* An ESLint configuration object. | ||
*/ | ||
type Config = Linter.Config; | ||
|
||
/** | ||
* An ESLint configuration object that may extend other configurations. This | ||
* can only be used with the {@link createConfig} function. | ||
*/ | ||
type ConfigWithExtends = Config & { | ||
extends?: Config | Config[] | Config[][]; | ||
}; | ||
|
||
/** | ||
* Create a config object that extends other configs. | ||
* | ||
* ESLint 9 removed support for extending arrays of configs, so this function | ||
* provides a workaround. It takes an array of config objects, where each object | ||
* may have an `extends` property that is an array of other config objects. | ||
* | ||
* This function is inspired by the `config` function in the `typescript-eslint` | ||
* package, but to avoid a dependency on that package, this function is | ||
* implemented here. | ||
* | ||
* @param configs - An array of config objects. | ||
* @returns An array of config objects with all `extends` properties | ||
* resolved. | ||
* @example Basic usage. | ||
* import { createConfig } from '@metamask/eslint-config'; | ||
* import typescript from '@metamask/eslint-config-typescript'; | ||
* | ||
* const configs = createConfig([ | ||
* { | ||
* files: ['**\/*.ts'], | ||
* extends: typescript, | ||
* }, | ||
* ]); | ||
* | ||
* export default configs; | ||
* | ||
* @example Multiple extends are supported as well. | ||
* import { createConfig } from '@metamask/eslint-config'; | ||
* import typescript from '@metamask/eslint-config-typescript'; | ||
* import nodejs from '@metamask/eslint-config-nodejs'; | ||
* | ||
* const configs = createConfig([ | ||
* { | ||
* files: ['**\/*.ts'], | ||
* extends: [typescript, nodejs], | ||
* }, | ||
* ]); | ||
* | ||
* export default configs; | ||
*/ | ||
export function createConfig( | ||
configs: ConfigWithExtends | ConfigWithExtends[], | ||
): Config[]; | ||
|
||
const config: Config[]; | ||
export default config; | ||
} |
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
Oops, something went wrong.