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: prepare for consistent comma-dangle lint rule 2021-04-01 23:14:29 -07:00
test_bigint test: suppress compiler warning in test_bigint 2021-10-01 05:13:32 +02:00
test_constructor test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_conversions test: avoid deep comparisons with literals 2021-11-02 10:11:49 +00:00
test_dataview test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_date test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_error test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
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: prepare for consistent comma-dangle lint rule 2021-04-01 23:14:29 -07:00
test_handle_scope test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_instance_data test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_new_target test: give js-native-api tests consistent names 2021-05-19 16:43:19 -04:00
test_number test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_object test: prepare for consistent comma-dangle lint rule 2021-04-01 23:14:29 -07:00
test_promise test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_properties test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_reference src: make napi_create_reference accept symbol 2021-09-08 13:10:38 -04:00
test_reference_double_free node-api: force env shutdown deferring behavior 2021-02-18 20:31:03 -08:00
test_string node-api: avoid crashing on passed-in null string 2021-06-11 09:01:22 -07:00
test_symbol test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
test_typedarray test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
.gitignore test: partition N-API tests 2018-12-04 13:58:17 -08:00
common.c test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
common.h test: rename n-api to node-api 2021-02-06 05:03:38 -08:00
entry_point.c test: partition N-API tests 2018-12-04 13:58:17 -08:00
testcfg.py test: partition N-API tests 2018-12-04 13:58:17 -08:00