@naturalcycles/dev-lib 20.76.0 → 20.76.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cfg/oxlint-plugin-nc.js +5 -3
- package/package.json +1 -1
package/cfg/oxlint-plugin-nc.js
CHANGED
|
@@ -45,7 +45,6 @@ const preferAssertRule = {
|
|
|
45
45
|
return {
|
|
46
46
|
IfStatement(node) {
|
|
47
47
|
if (node.alternate || node.parent.type === 'IfStatement') return
|
|
48
|
-
if (!isAssertableTest(node.test)) return
|
|
49
48
|
|
|
50
49
|
const { consequent } = node
|
|
51
50
|
const statement =
|
|
@@ -59,11 +58,14 @@ const preferAssertRule = {
|
|
|
59
58
|
error.type !== 'NewExpression' ||
|
|
60
59
|
error.callee.type !== 'Identifier' ||
|
|
61
60
|
!ASSERTABLE_ERRORS.has(error.callee.name) ||
|
|
62
|
-
error.arguments.length > maxArguments(error.callee.name)
|
|
63
|
-
error.arguments.some(argument => containsEvaluation(argument))
|
|
61
|
+
error.arguments.length > maxArguments(error.callee.name)
|
|
64
62
|
) {
|
|
65
63
|
return
|
|
66
64
|
}
|
|
65
|
+
// The checks below walk subtrees, so they run after the cheap shape checks above: most `if`
|
|
66
|
+
// statements do not throw and never reach them
|
|
67
|
+
if (!isAssertableTest(node.test)) return
|
|
68
|
+
if (error.arguments.some(argument => containsEvaluation(argument))) return
|
|
67
69
|
const narrowed = referencedNames(node.test)
|
|
68
70
|
if (error.arguments.some(argument => referencesAny(argument, narrowed))) return
|
|
69
71
|
|