-
-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Hello,
Not sure if this is a convention but it seems like the error messages that are used with Node's assert
sometimes describe the expected situation rather than the actual one.
For example:
const result = linter.lintResult.files[0].updatedSource;
const expectedResult = normalizeNewLines(check.after);
const effectiveDiff = getDiff(expectedResult, result, source);
assert(effectiveDiff.length === 0, "Code has been formatted correctly");
I think this is a bit confusing, I would expect the error message to describe the situation when the asserted value is falsy since this is when the message will be displayed (in that case "Code was not formatted correctly).
There are other occurrences which is why I assume this was done on purpose.
assert(linter.outputString.includes("warning"), "Output string contains warning");
assert(linter.lintResult.summary.totalFoundWarningNumber > 0, "Warnings found");
assert(linter.lintResult.summary.totalFoundInfoNumber > 0, "Infos found");
Looking at the docs, assert() is an alias of ok(), the message seems to describe the situation when the asserted value is falsy:
assert.ok(false, 'it\'s false');
// AssertionError: it's false
I guess either option can make sense so this issue is mainly asking the expected content of the message parameter when using assert()
in this project.
Thanks!