Skip to content

Commit

Permalink
Merge branch 'main' into local-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
beerose committed Apr 28, 2023
2 parents 89efcff + dee5198 commit d86fcd3
Show file tree
Hide file tree
Showing 30 changed files with 1,042 additions and 25,324 deletions.
19 changes: 9 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ module.exports = {
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:jest/recommended',
'plugin:vitest/recommended',
'prettier',
'prettier/@typescript-eslint',
],
plugins: ['jest', '@typescript-eslint', 'import'],
plugins: ['vitest', '@typescript-eslint', 'import'],
rules: {
'no-var': 'off',
'prefer-const': 'off',
'prefer-arrow-callback': 'off',
'func-names': ['error', 'always'],
'prefer-template': 'error',
'no-prototype-builtins': 'error',
'no-use-before-define': 'off',
'object-shorthand': [
'error',
'always',
Expand Down Expand Up @@ -102,17 +103,14 @@ module.exports = {
'import/prefer-default-export': 'off',

/**
* eslint-plugin-jest
* eslint-plugin-vitest
*/
'jest/consistent-test-it': ['error', { fn: 'test' }],
'jest/valid-title': 'error',
'jest/no-test-callback': 'error',
'jest/prefer-todo': 'error',
'jest/require-to-throw-message': 'off',
'vitest/consistent-test-it': ['error', { fn: 'test' }],
'vitest/valid-title': 'error',
'vitest/no-done-callback': 'error',
// Many tests make assertions indirectly in a way the plugin
// does not understand.
'jest/expect-expect': 'off',
'jest/no-identical-title': 'off',
'vitest/expect-expect': 'off',
},
settings: {
node: {
Expand All @@ -126,6 +124,7 @@ module.exports = {
node: {
extensions: allExtensions,
},
typescript: {},
},
'import/extensions': allExtensions,
},
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: d-fischer
custom: paypal.me/dfischerdev
12 changes: 4 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node: [12, 14, 16, 18]
node: [14, 16, 18]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand All @@ -32,19 +32,15 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Install latest npm
run: npm install --global npm@latest

- name: Install dependencies
run: npm ci
run: npm i

- name: Test
run: npm run test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: startsWith(matrix.os, 'ubuntu') && matrix.node == 16
if: startsWith(matrix.os, 'ubuntu-latest') && matrix.node == 18
with:
files: ./.coverage/lcov.info
files: ./coverage/lcov.info
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ dist
.idea
.vscode
wallaby.config.js

# lock files
package-lock.json
yarn.lock
pnpm-lock.yaml
2 changes: 0 additions & 2 deletions .yarnrc

This file was deleted.

32 changes: 28 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
# Changelog

## HEAD
## 8.1.4

- **Breaking change:** Add support for ECMAScript modules (ESM) to the [*asynchronous* API](./README.md#asynchronous-api). End users running Node versions that support ESM can provide `.mjs` files, or `.js` files whose nearest parent `package.json` file contains `"type": "module"`.
- `${moduleName}rc.mjs` and `${moduleName}.config.mjs` are included in the default `searchPlaces` of the asynchronous API.
- The [synchronous API](./README.md#synchronous-api) does not support ECMAScript modules, so does not look for `.mjs` files.
- To learn more, read ["Loading JS modules"](./README.md#loading-js-modules).
- **Breaking change:** Drop support for Node 10.

## 8.1.3

- Fixed: existence of meta config breaking default loaders

## 8.1.2

- Fixed: generation of TypeScript types going to the wrong output path

## 8.1.1

- Fixed: meta config overriding original options completely (now merges correctly)

## 8.1.0

- Added: always look at `.config.{yml,yaml,json,js,cjs}` file to configure cosmiconfig itself, and look for tool configuration in it using `packageProp` (similar to package.json)
- For more info on this, look at the [end user configuration section of the README](README.md#usage-for-end-users)

## 8.0.0

**No major breaking changes!** We dropped support for Node 10 and 12 -- which you're probably not using. And we swapped out the YAML parser -- which you probably won't notice.

- **Breaking change:** Drop support for Node 10 and 12.

- **Breaking change:** Use npm package [js-yaml](https://www.npmjs.com/package/js-yaml) to parse YAML instead of npm package [yaml](https://www.npmjs.com/package/yaml).
- Added: Loader errors now include the path of the file that was tried to be loaded.

## 7.1.0

- Added: additional default `searchPlaces` within a .config subdirectory (without leading dot in the file name)
- Added: Additional default `searchPlaces` within a .config subdirectory (without leading dot in the file name)

## 7.0.1

Expand Down Expand Up @@ -215,4 +239,4 @@ More details:

[parse-json-pr-12]: https://github.com/sindresorhus/parse-json/pull/12

[pr-101]: https://github.com/davidtheclark/cosmiconfig/pull/101
[pr-101]: https://github.com/cosmiconfig/cosmiconfig/pull/101
97 changes: 91 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# cosmiconfig

[![codecov](https://codecov.io/gh/davidtheclark/cosmiconfig/branch/main/graph/badge.svg)](https://codecov.io/gh/davidtheclark/cosmiconfig)

> **MAINTAINERS WANTED!** If you're interested in taking over and maintaining Cosmiconfig, please let @davidtheclark know (with an issue or email). I'd like to hand over the keys completely, so I'm looking for **owners**, not people who just want to merge a PR or two! You can make the decisions about what happens in v8 and subsequent versions, how the package balances stability and opinionated features, and so on. Take a look at open issues and PRs to learn about possibilities that have been on people's minds over the years.
[![codecov](https://codecov.io/gh/cosmiconfig/cosmiconfig/branch/main/graph/badge.svg)](https://codecov.io/gh/cosmiconfig/cosmiconfig)

Cosmiconfig searches for and loads configuration for your program.

Expand Down Expand Up @@ -30,7 +28,7 @@ Cosmiconfig continues to search up the directory tree, checking each of these pl
## Table of contents

- [Installation](#installation)
- [Usage](#usage)
- [Usage for tooling developers](#usage-for-tooling-developers)
- [Result](#result)
- [Asynchronous API](#asynchronous-api)
- [cosmiconfig()](#cosmiconfig-1)
Expand All @@ -57,6 +55,7 @@ Cosmiconfig continues to search up the directory tree, checking each of these pl
- [Loading JS modules](#loading-js-modules)
- [Caching](#caching)
- [Differences from rc](#differences-from-rc)
- [Usage for end users](#usage-for-end-users)
- [Contributing & Development](#contributing--development)

## Installation
Expand All @@ -65,9 +64,12 @@ Cosmiconfig continues to search up the directory tree, checking each of these pl
npm install cosmiconfig
```

Tested in Node 12+.
Tested in Node 14+.

## Usage for tooling developers

## Usage
*If you are an end user (i.e. a user of a tool that uses cosmiconfig, like `prettier` or `stylelint`),
you can skip down to [the end user section](#usage-for-end-users).*

Create a Cosmiconfig explorer, then either `search` for or directly `load` a configuration file.

Expand Down Expand Up @@ -558,6 +560,89 @@ To avoid or work around caching, you can do the following:
- Options.
- Asynchronous by default (though can be run synchronously).

## Usage for end users

When configuring a tool, you can use multiple file formats and put these in multiple places.

Usually, a tool would mention this in its own README file,
but by default, these are the following places, where `{NAME}` represents the name of the tool:

```
package.json
.{NAME}rc
.{NAME}rc.json
.{NAME}rc.yaml
.{NAME}rc.yml
.{NAME}rc.js
.{NAME}rc.cjs
.config/{NAME}rc
.config/{NAME}rc.json
.config/{NAME}rc.yaml
.config/{NAME}rc.yml
.config/{NAME}rc.js
.config/{NAME}rc.cjs
{NAME}.config.js
{NAME}.config.cjs
```

The contents of these files are defined by the tool.
For example, you can configure prettier to enforce semicolons at the end of the line
using a file named `.config/prettierrc.yml`:

```yaml
semi: true
```

Additionally, you have the option to put a property named after the tool in your `package.json` file,
with the contents of that property being the same as the file contents. To use the same example as above:

```json
{
"name": "your-project",
"dependencies": {},
"prettier": {
"semi": true
}
}
```

This has the advantage that you can put the configuration of all tools
(at least the ones that use cosmiconfig) in one file.

You can also add a `cosmiconfig` key within your `package.json` file or create one of the following files
to configure `cosmiconfig` itself:

```
.config.json
.config.yaml
.config.yml
.config.js
.config.cjs
```

The following property is currently actively supported in these places:

```yaml
cosmiconfig:
# overrides where configuration files are being searched to enforce a custom naming convention and format
searchPlaces:
- .config/{name}.yml
```

> **Note:** technically, you can overwrite all options described in [cosmiconfigOptions](#cosmiconfigoptions) here,
> but everything not listed above should be used at your own risk, as it has not been tested explicitly.
You can also add more root properties outside the `cosmiconfig` property
to configure your tools, entirely eliminating the need to look for additional configuration files:

```yaml
cosmiconfig:
searchPlaces: []

prettier:
semi: true
```

## Contributing & Development

Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
comment: off;
comment: false

0 comments on commit d86fcd3

Please sign in to comment.