node/test/js-native-api
Tobias Nießen dd52c05046 test: avoid deep comparisons with literals
Comparing any value to any non-RegExp literal or undefined using
strictEqual (or notStrictEqual) passes if and only if deepStrictEqual
(or notDeepStrictEqual, respectively) passes.

Unnecessarily using deep comparisons adds confusion.

This patch adds an ESLint rule that forbids the use of deepStrictEqual
and notDeepStrictEqual when the expected value (i.e., the second
argument) is a non-RegExp literal or undefined.

For reference, an ESTree literal is defined as follows.

    extend interface Literal <: Expression {
        type: "Literal";
        value: string | boolean | null | number | RegExp | bigint;
    }

The value `undefined` is an `Identifier` with `name: 'undefined'`.

PR-URL: https://github.com/nodejs/node/pull/40634
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com>
2021-11-02 10:11:49 +00:00
..
2_function_arguments test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
3_callbacks test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
4_object_factory test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
5_function_factory test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
6_object_wrap test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
7_factory_wrap test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
8_passing_wrapped test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
test_array
test_bigint test: suppress compiler warning in test_bigint 2021-10-01 05:13:32 +02:00
test_constructor
test_conversions test: avoid deep comparisons with literals 2021-11-02 10:11:49 +00:00
test_dataview
test_date
test_error
test_exception node-api: rtn pending excep on napi_new_instance 2021-06-04 16:38:06 -04:00
test_function node-api: handle pending exception in cb wrapper 2021-08-03 16:38:45 -04:00
test_general
test_handle_scope
test_instance_data
test_new_target test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
test_number
test_object
test_promise
test_properties
test_reference src: make napi_create_reference accept symbol 2021-09-08 13:10:38 -04:00
test_reference_double_free
test_string node-api: avoid crashing on passed-in null string 2021-06-11 09:01:22 -07:00
test_symbol
test_typedarray
.gitignore
common.c
common.h
entry_point.c
testcfg.py