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
Throw error on non-existent files unless allow-empty-input is enabled #3965
Changes from 9 commits
0a49405
acd6924
898494c
2947db4
2a70cc1
2c0e3f7
651156d
8d44521
71112d3
3200db0
2295829
2d086cc
5db6689
4ed2ee9
7b66272
168a5f5
47b3d61
903080b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,10 +114,28 @@ it("standalone without input css and file(s) should throw error", () => { | |
); | ||
}); | ||
|
||
it("standalone with non-existent-file quietly exits", () => { | ||
it("standalone with non-existent-file throws an error", () => { | ||
const expectedError = new Error( | ||
"The specified `files` glob returns no results" | ||
); | ||
|
||
return standalone({ | ||
files: `${fixturesPath}/non-existent-file.css`, | ||
config: configBlockNoEmpty | ||
}) | ||
.then(() => { | ||
throw new Error("should not have succeeded"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just curious why to throw an error here? Isn't stylelint should throw an error and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, I removed this, it was left over from testing |
||
}) | ||
.catch(actualError => { | ||
expect(actualError).toEqual(expectedError); | ||
}); | ||
}); | ||
|
||
it("standalone with non-existent-file and allowEmptyInput enabled quietly exits", () => { | ||
return standalone({ | ||
files: `${fixturesPath}/non-existent-file.css`, | ||
config: configBlockNoEmpty, | ||
allowEmptyInput: true | ||
}).then(linted => { | ||
expect(typeof linted.output).toBe("string"); | ||
expect(linted.results).toHaveLength(0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we adopt the ESLint approach of?:
This feels a little more explicit as we're stating the glob pattern in the error message, rather than just referring to it.