# find-babel-config

> Find the closest babel config based on a directory

Latest version **2.1.2** (published 2024-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-babel-config
pnpm add find-babel-config
yarn add find-babel-config
bun add find-babel-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2024-09-02 |
| First published | 2016-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Tommy Leunen |
| Maintainers | tleunen |
| Keywords | babel, config, loader, finder, babelrc |

## Links

- npm: https://www.npmjs.com/package/find-babel-config
- Repository: https://github.com/tleunen/find-babel-config
- Homepage: https://github.com/tleunen/find-babel-config#readme
- Issues: https://github.com/tleunen/find-babel-config/issues
- npm.io page: https://npm.io/package/find-babel-config

## Dependencies (1)

- [json5](https://npm.io/package/json5.md) ^2.2.3

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.1.2 (latest) — 2024-09-02
- 1.2.2 (previous) — 2024-04-25
- 2.1.1 — 2024-04-17
- 2.1.0 — 2024-04-17
- 1.2.1 — 2024-04-17
- 2.0.0 — 2023-01-09
- 1.2.0 — 2019-03-04
- 1.1.0 — 2017-05-08
- 1.0.1 — 2016-08-20
- 1.0.0 — 2016-08-06
- 0.1.1 — 2016-07-10
- 0.1.0 — 2016-07-10

## README

# find-babel-config
[![npm][npm-version-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coverage Status][coverage-image]][coverage-url]

Helper function to retrieve the closest Babel configuration from a specific directory.

## Installation

```sh
npm install --save find-babel-config
```

## Usage

### Async

```js
// directory can be an absolute or relative path
// If it's a relative path, it is relative to the current working directory (process.cwd())
const directory = 'src';
findBabelConfig(directory).then(({ file, config }) => {
    if (file) {
        // file is the file in which the config is found
        console.log(file);
        // config is a JS plain object with the babel config
        console.log(config);
    }
});
```

### Sync

```js
// directory can be an absolute or relative path
// If it's a relative path, it is relative to the current working directory (process.cwd())
const directory = 'src';
const { file, config } = findBabelConfig.sync(directory);
// if file === null, the config wasn't found. (Also config === null)
if (file) {
    // file is the file in which the config is found
    console.log(file);
    // config is a JS plain object with the babel config
    console.log(config);
}
```

A second parameter can be given to `findBabelConfig`, it specifies the `depth` of search. By default, this value is `Infinity` but you can set the value you want: `findBabelConfig('src', 10)`.

## License

MIT, see [LICENSE.md](/LICENSE.md) for details.

[ci-image]: https://circleci.com/gh/tleunen/find-babel-config.svg?style=shield
[ci-url]: https://circleci.com/gh/tleunen/find-babel-config
[coverage-image]: https://codecov.io/gh/tleunen/find-babel-config/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/tleunen/find-babel-config
[npm-version-image]: https://img.shields.io/npm/v/find-babel-config.svg
[npm-url]: https://www.npmjs.com/package/find-babel-config

---
_Source: https://npm.io/package/find-babel-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
