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: support running CLI in project without config file #80

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

ericcornelissen
Copy link
Collaborator

Closes #78
Supersedes #79


Re-add support for running the CLI in a project without a configuration file. This worked up to and including v2.1.1 but was broken by the changes of #64.

89ec927 adds a regression test where the CI demonstrates it can catch this bug in the future. 642ea76 fixes the bug itself.

\cc @luciansmith

Update the CLI tests to include a test for the case where a project does
not have a configuration file. This test currently fails because this is
currently not supported due to a bug introduced in v2.2.0.

To accomodate testing this, the configuration file that was present at
the root of the project has been moved and related tests updated
accordingly. This is necessary because svglint automatically searches
for a configuration file up the file tree, so having a configuration
file at the root of the project makes it impossible to test the scenario

The new tests matches against a string because unfortunately the error
is silent - it doesn't exit with a non-zero exit code. Improvements to
this are welcome as contributions.
Update the CLI to work if no configuration file is found.

This is the simplest fix I could think of. Theoretically the problem
could be addressed in the API (svglint.js line 137 and 150) by replacing
the default parameter `config={}` with an implementation that defaults
to an empty object for both `undefined` **and** `null`. However, it's
currently not clear that's the right move.

Another alternative would be for `loadConfigurationFile` to return
`undefined` instead of `null`. However, that could interfere with the
intended behaviour of that function, making it impossible to distinguish
a missing default export from no-configuration-file-found.
@ericcornelissen ericcornelissen merged commit 2d0f467 into master Apr 7, 2023
24 checks passed
@ericcornelissen ericcornelissen deleted the 78-support-no-config branch April 7, 2023 10:13
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

🎉 This PR is included in version 2.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: "Cannot read properties of null (reading 'rules')"
1 participant