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

fix: revert back to cosmiconfig from lilconfig #1035

Merged
merged 2 commits into from Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
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
@@ -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