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
feat: replace cosmiconfig
with lilconfig
+ yaml
to reduce dependencies
#1042
Conversation
Ping @antonk52, it seems |
Codecov Report
@@ Coverage Diff @@
## fix-esm-config #1042 +/- ##
================================================
Coverage 100.00% 100.00%
================================================
Files 21 21
Lines 579 583 +4
Branches 156 156
================================================
+ Hits 579 583 +4
Continue to review full report at Codecov.
|
Hey @iiroj If I got that right and you mean ecmascript modules in terms of |
@antonk52 See this part in the PR: without it, a test will fail that tries to load config from
|
Thanks for the explanation. I'm currently out. I will have a good look through the PR later on |
Thank you for the patience. I've checked the PR. You're statement is correct about lilconfig not supporting (resolving paths for) node_modules out of the box. I want to note that the same can be said about cosmiconfig as they resolve provided paths the same using I can see that some part of the code was modified in this PR. More specifically the const resolveConfig = (configPath) => {
try {
return require.resolve(configPath)
} catch {
return configPath
}
}
const loadConfig = (configPath) => {
- const explorer = cosmiconfig('lint-staged', {
+ const explorer = lilconfig('lint-staged', {
searchPlaces: [
'package.json',
'.lintstagedrc',
'.lintstagedrc.json',
'.lintstagedrc.yaml',
'.lintstagedrc.yml',
'.lintstagedrc.js',
'.lintstagedrc.cjs',
'lint-staged.config.js',
'lint-staged.config.cjs',
],
})
return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
// ^^^^^^^^^^^^^ This function call should not be removed
} By preserving Please let me know if this helps. |
@antonk52 I don't think we should use Anyway, you are right that it was that part that handled the module stuff before! I actually think I need to extract a bug fix from this branch into a separate PR (the |
65e7cce
to
37f4e75
Compare
Looks great! 👍 One thing I noticed is that you've also added support for ESM, I think this line can be misleading to some as this PR effectively overwrote all default loaders. Perhaps replacing it with something that mentions that lint-staged supports ESM with default export and YAML can be more useful for some people. |
I would be happy to merge a PR adding ESM support, but this would make lilconfig converge from cosmiconfig feature set. I prefer it to stay as close as possible as a drop in replacement. I think I saw an issue about adding ESM support to cosmiconfig in the next major version. Once this happens I am happy to release the next major version to preserve the compatibility with cosmiconfig. I've read through #1045 and left a comment. Looks great! |
@antonk52 cool. I think changing the async |
This will add a difference to how |
Makes sense, thanks a lot for the help with this @antonk52. |
Sure thing. Please do ping me if there will be future issues regarding lilconfig |
This PR revives #981 by replacing
cosmiconfig
withlilconfig
+yaml
to reduce the number and size of dependencies used by lint-staged. The first PR introduced some problems (#1033) and was later reverted (#1035).It seems
lilconfig
doesn't support loading configurations from a module, so that functionality was added as well.This draft will be left for later...