Skip to content

Commit

Permalink
fix: revert back to cosmiconfig from lilconfig (#1035)
Browse files Browse the repository at this point in the history
* Revert "fix: correctly import `js-yaml` to fix yaml config loading (#1033)"

This reverts commit 612d806.

* Revert "perf: replace `cosmiconfig` with `lilconfig` (#981)"

This reverts commit 04529e2.
  • Loading branch information
iiroj authored Oct 26, 2021
1 parent 612d806 commit e035b80
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 229 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Starting with v3.1 you can now use different ways of configuring lint-staged:
- `lint-staged.config.js`, `.lintstagedrc.js`, or `.lintstagedrc.cjs` file in JS format
- Pass a configuration file using the `--config` or `-c` flag
See [lilconfig](https://github.com/antonk52/lilconfig) for more details on what formats are supported.
See [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for more details on what formats are supported.
Configuration should be an object where each value is a command to run and its key is a glob pattern to use for this command. This package uses [micromatch](https://github.com/micromatch/micromatch) for glob patterns.
Expand Down
14 changes: 3 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const { lilconfig } = require('lilconfig')
const yaml = require('js-yaml')
const { cosmiconfig } = require('cosmiconfig')
const debugLog = require('debug')('lint-staged')
const stringifyObject = require('stringify-object')

Expand All @@ -25,10 +24,8 @@ const resolveConfig = (configPath) => {
}
}

const jsYamlLoad = (filepath, content) => yaml.load(content)

const loadConfig = (configPath) => {
const explorer = lilconfig('lint-staged', {
const explorer = cosmiconfig('lint-staged', {
searchPlaces: [
'package.json',
'.lintstagedrc',
Expand All @@ -40,11 +37,6 @@ const loadConfig = (configPath) => {
'lint-staged.config.js',
'lint-staged.config.cjs',
],
loaders: {
'.yml': jsYamlLoad,
'.yaml': jsYamlLoad,
noExt: jsYamlLoad,
},
})

return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
Expand Down Expand Up @@ -92,7 +84,7 @@ const lintStaged = async (
) => {
await validateOptions({ shell }, logger)

debugLog('Loading config using `lilconfig`')
debugLog('Loading config using `cosmiconfig`')

const resolved = configObject
? { config: configObject, filepath: '(input)' }
Expand Down
Loading

0 comments on commit e035b80

Please sign in to comment.