Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6 #216

Merged
merged 65 commits into from
Nov 2, 2019
Merged

V6 #216

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5210758
Fail CI if package.json and yarn lock are out of sync (#186)
koenpunt May 18, 2019
0a84b90
Warn against filename-unfriendly chars in moduleName (#187)
May 19, 2019
d49dad0
Remove support for Node 4 and 6 (#190)
Jun 13, 2019
0783a34
update packages
chrisblossom Jun 13, 2019
a7c760e
fix npm config to correctly remove package-lock.json
chrisblossom Jun 13, 2019
e8a16e9
enable test undefined checks
chrisblossom Jun 13, 2019
1b452bc
set prettier trailingComma to all
chrisblossom Jun 15, 2019
6003890
set node/no-unsupported-features to first node 8 LTS release when new…
chrisblossom Jun 13, 2019
6da6871
use prettier for all supported file types (except markdown) (#193)
chrisblossom Jun 15, 2019
26a961a
add eslint-plugin-jest (#196)
chrisblossom Jun 18, 2019
128e42c
use babel to compile source
chrisblossom Jun 22, 2019
5560b29
remove unused coverage script
chrisblossom Jun 22, 2019
b68a566
add pre-push git hook, and consolidate all checks into check:all script
chrisblossom Jun 23, 2019
1d4b35b
eslint: remove plugin-node from src enable module parsing, and remove…
chrisblossom Jun 23, 2019
8f7d24a
convert common-js to es modules named exports
chrisblossom Jun 23, 2019
53d2d40
move flow-typed/defs.js to src/types.js and remove unused types
chrisblossom Jun 23, 2019
748a03c
migrate build system to typescript
chrisblossom Jun 24, 2019
f9c6880
remove flow comments
chrisblossom Jul 1, 2019
e2e5dd9
test files to typescript
chrisblossom Jun 26, 2019
ed37ddd
source files to typescript
chrisblossom Jul 1, 2019
cb058a1
run prettier on all files
chrisblossom Jul 1, 2019
0ea62ce
rename all files to .ts and update changelog
chrisblossom Jul 1, 2019
47d8951
Typescript code quality tools (#202)
chrisblossom Jul 5, 2019
0e10c02
export Options and combine multiple Options definitions
chrisblossom Jul 8, 2019
709ca57
export Transform and add correctly type it can be a Promise (async only)
chrisblossom Jul 8, 2019
f18cf0c
fix cacheWrapper to cache the result instead of a Promise, merge mult…
chrisblossom Jul 8, 2019
0d7b647
export LoaderSync and LoaderAsync
chrisblossom Jul 8, 2019
e98bd6a
correctly type LoadedFileContent
chrisblossom Jul 8, 2019
c6ef21d
split loadFileContent into async / sync separate functions
chrisblossom Jul 8, 2019
5a7053e
use default function parameters
chrisblossom Jul 8, 2019
dc17101
use object spread
chrisblossom Jul 8, 2019
2dd9157
export getDirectorySync
chrisblossom Jul 8, 2019
9f9dda9
export readFileSync
chrisblossom Jul 8, 2019
76547e4
update import-fresh to use built-in types
chrisblossom Jul 8, 2019
17f743f
replace is-directory with path-type
chrisblossom Jul 11, 2019
b9649ec
remove unused global.d.ts
chrisblossom Jul 8, 2019
eec912f
use builtin Object.prototype.hasOwnProperty
chrisblossom Jul 9, 2019
3ccdea8
group async and sync versions of functions, async first
chrisblossom Jul 9, 2019
4933f69
use async await where possible
chrisblossom Jul 9, 2019
3f520f4
convert tests that throw to .toThrow syntax
chrisblossom Jul 9, 2019
9c9adc1
Prevent pushing and publishing with unformatted files
chrisblossom Jul 16, 2019
318d638
Breaking: remove `cosmiconfig.loaders` and add named export `defaultL…
chrisblossom Jul 25, 2019
67d41b0
Tweak readme
Aug 3, 2019
69696dd
split create explorer async and sync methods into different files
chrisblossom Aug 22, 2019
2a270c0
createExplorer and createExplorerSync
chrisblossom Aug 25, 2019
24bc87e
remove excess getLoaderEntryForFile functions
chrisblossom Sep 5, 2019
91209d2
update readme and changelog
chrisblossom Sep 5, 2019
7e8e11a
Minor v6 test revisions (#217)
Oct 6, 2019
ad63f7f
rename createExplorer*
chrisblossom Oct 7, 2019
b89752e
Move createExplorer* to index.ts
chrisblossom Oct 7, 2019
a7bc28e
remove outdated line in readme
chrisblossom Oct 7, 2019
26b65bb
export actual defaultLoaders object
chrisblossom Oct 22, 2019
7a0f0e6
freeze defaultLoaders so it cannot be mutated causing unexpected results
chrisblossom Oct 22, 2019
83ff4b1
update changelog
chrisblossom Sep 5, 2019
60337c9
replace js-yaml with yaml
chrisblossom Oct 22, 2019
6935c0f
update all packages and ensure prefix is correctly set for future npm…
chrisblossom Oct 22, 2019
1e1ae77
refactor test/index.test.ts to remove jest inline snapshot hacks
chrisblossom Oct 23, 2019
fad0ebc
remove yarn.lock
chrisblossom Oct 23, 2019
080256a
Revert "remove yarn.lock"
chrisblossom Oct 23, 2019
358104c
Include absolute file path to yaml parse error
chrisblossom Oct 23, 2019
db8f2cd
windows del fix
chrisblossom Oct 23, 2019
c8c8817
remove yarn.lock
chrisblossom Oct 23, 2019
08ebcd5
Lazy load all default loaders
chrisblossom Oct 23, 2019
ed83eaa
Prepare 6.0.0
Oct 26, 2019
b7b2ae6
Fix typo
Oct 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
'use strict';

// first node 8.x LTS release
const supportedNodeVersion = '8.9';
const allExtensions = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.json'];

module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
project: './tsconfig.eslint.json',
},
extends: [
'eslint-config-davidtheclark-node',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:jest/recommended',
'prettier',
'prettier/@typescript-eslint',
],
plugins: ['jest', '@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',
'object-shorthand': [
'error',
'always',
{ avoidExplicitReturnArrows: true },
],

/**
* eslint-plugin-typescript
*/
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowTypedFunctionExpressions: true,
},
],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],

// requires type information rules
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
// '@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': ['error', { allowAny: true }],
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
// '@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/unbound-method': 'error',

// rules not in recommended
'@typescript-eslint/ban-ts-ignore': 'off', // maybe enable?
'@typescript-eslint/member-ordering': 'off', // maybe enable?
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/unified-signatures': 'error',

/**
* eslint-plugin-node
*/
'node/no-unpublished-require': 'off',
'node/no-unsupported-features': 'off',
'node/no-unsupported-features/es-builtins': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-unsupported-features/node-builtins': 'off',
// Redundant with import/no-extraneous-dependencies
'node/no-extraneous-import': 'off',
'node/no-extraneous-require': 'off',
// Redundant with import/no-unresolved
'node/no-missing-import': 'off',
'node/no-missing-require': 'off',

/**
* eslint-plugin-import
*/
'import/no-default-export': 'error',
'import/no-named-export': 'off',
'import/prefer-default-export': 'off',

/**
* eslint-plugin-jest
*/
'jest/consistent-test-it': ['error', { fn: 'test' }],
'jest/no-empty-title': 'error',
'jest/no-test-callback': 'error',
'jest/prefer-todo': 'error',
'jest/require-tothrow-message': 'error',
},
settings: {
node: {
convertPath: {
'src/**/*.{js,ts}': ['^src/(.+?)\\.(js|ts)$', 'dist/$1.js'],
'src/**/.*.{js,ts}': ['^src/(.+?)\\.(js|ts)$', 'dist/$1.js'],
},
tryExtensions: allExtensions,
},
'import/resolver': {
node: {
extensions: allExtensions,
},
},
'import/extensions': allExtensions,
},
overrides: [
{
files: ['*.test.{js,ts}', '.*.test.{js,ts}'],
rules: {
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/require-await': 'off',
},
},
{
files: ['*.js', '.*.js'],
excludedFiles: ['*/**', '*/.**'],
parserOptions: {
sourceType: 'script',
},
rules: {
strict: ['error', 'safe'],

'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-builtins': [
'error',
{ version: supportedNodeVersion },
],
'node/no-unsupported-features/es-syntax': [
'error',
{ version: supportedNodeVersion },
],
'node/no-unsupported-features/node-builtins': [
'error',
{ version: supportedNodeVersion },
],
},
},
],
};
27 changes: 0 additions & 27 deletions .eslintrc.json

This file was deleted.

11 changes: 0 additions & 11 deletions .flowconfig

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage
dist
.idea
.vscode
wallaby.config.js
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"package-lock=false"
package-lock=false
save-exact=false
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
*.log
.nyc_output
coverage
flow-typed
*.DS_Store
dist
.idea
.vscode
*.md
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ cache: yarn
branches:
only:
- master
- v6
matrix:
include:
- node_js: "4"
- node_js: "6"
- node_js: "8"
after_success: "bash <(curl -s https://codecov.io/bash)"
- node_js: "10"
- node_js: '8'
- node_js: '10'
after_success: 'bash <(curl -s https://codecov.io/bash)'
- node_js: '12'
install:
- yarn install --frozen-lockfile
script:
- yarn run check:all
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
save-prefix "^"
--no-lockfile true
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## 6.0.0

- **Breaking change:** The package now has named exports. See examples below.
- **Breaking change:** Separate async and sync APIs, accessible from different named exports. If you used `explorer.searchSync()` or `explorer.loadSync()`, you'll now create a sync explorer with `cosmiconfigSync()`, then use `explorerSync.search()` and `explorerSync.load()`.

```js
// OLD: cosmiconfig v5
import cosmiconfig from 'cosmiconfig';

const explorer = cosmiconfig('example');
const searchAsyncResult = await explorer.search();
const loadAsyncResult = await explorer.load('./file/to/load');
const searchSyncResult = explorer.searchSync();
const loadSyncResult = explorer.loadSync('./file/to/load');

// NEW: cosmiconfig v6
import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig';

const explorer = cosmiconfig('example');
const searchAsyncResult = await explorer.search();
const loadAsyncResult = await explorer.load('./file/to/load');

const explorerSync = cosmiconfigSync('example');
const searchSyncResult = explorerSync.search();
const loadSyncResult = explorerSync.load('./file/to/load');
```
- **Breaking change:** Remove support for Node 4 and 6. Requires Node 8+.
- **Breaking change:** Use npm package [yaml](https://www.npmjs.com/package/yaml) to parse YAML instead of npm package [js-yaml](https://www.npmjs.com/package/js-yaml).
- **Breaking change:** Remove `cosmiconfig.loaders` and add named export `defaultLoaders` that exports the default loaders used for each extension.

```js
import { defaultLoaders } from 'cosmiconfig';

console.log(Object.entries(defaultLoaders))
// [
// [ '.js', [Function: loadJs] ],
// [ '.json', [Function: loadJson] ],
// [ '.yaml', [Function: loadYaml] ],
// [ '.yml', [Function: loadYaml] ],
// [ 'noExt', [Function: loadYaml] ]
// ]
```
- Migrate from Flowtype to Typescript.
- Lazy load all default loaders.

## 5.2.1

- Chore: Upgrade `js-yaml` to avoid npm audit warning.
Expand Down
Loading