Skip to content

Commit 54c07f6

Browse files
author
Gabriel Schulhof
committed
napi: eslint the test
1 parent 806c24b commit 54c07f6

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/node_api.cc

+11-10
Original file line numberDiff line numberDiff line change
@@ -2053,38 +2053,39 @@ napi_status napi_instanceof(napi_env e,
20532053
return napi_set_last_error(napi_function_expected);
20542054
}
20552055

2056-
napi_value value, jsRes;
2056+
napi_value value, js_result;
20572057
napi_status status;
2058-
napi_valuetype valueType;
2058+
napi_valuetype value_type;
20592059

20602060
// Get "Symbol" from the global object
20612061
status = napi_get_global(e, &value);
20622062
if (status != napi_ok) return status;
20632063
status = napi_get_named_property(e, value, "Symbol", &value);
20642064
if (status != napi_ok) return status;
2065-
status = napi_get_type_of_value(e, value, &valueType);
2065+
status = napi_get_type_of_value(e, value, &value_type);
20662066
if (status != napi_ok) return status;
20672067

20682068
// Get "hasInstance" from Symbol
2069-
if (valueType == napi_function) {
2069+
if (value_type == napi_function) {
20702070
status = napi_get_named_property(e, value, "hasInstance", &value);
20712071
if (status != napi_ok) return status;
2072-
status = napi_get_type_of_value(e, value, &valueType);
2072+
status = napi_get_type_of_value(e, value, &value_type);
20732073
if (status != napi_ok) return status;
20742074

20752075
// Retrieve the function at the Symbol(hasInstance) key of the constructor
2076-
if (valueType == napi_symbol) {
2076+
if (value_type == napi_symbol) {
20772077
status = napi_get_property(e, constructor, value, &value);
20782078
if (status != napi_ok) return status;
2079-
status = napi_get_type_of_value(e, value, &valueType);
2079+
status = napi_get_type_of_value(e, value, &value_type);
20802080
if (status != napi_ok) return status;
20812081

20822082
// Call the function to determine whether the object is an instance of the
20832083
// constructor
2084-
if (valueType == napi_function) {
2085-
status = napi_call_function(e, constructor, value, 1, &object, &jsRes);
2084+
if (value_type == napi_function) {
2085+
status = napi_call_function(e, constructor, value, 1, &object,
2086+
&js_result);
20862087
if (status != napi_ok) return status;
2087-
return napi_get_value_bool(e, jsRes, result);
2088+
return napi_get_value_bool(e, js_result, result);
20882089
}
20892090
}
20902091
}

test/addons-napi/test_buffer/test_buffer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void staticBuffer(napi_env env, napi_callback_info info) {
122122
env,
123123
napi_create_external_buffer(env,
124124
sizeof(theText),
125-
(const char *)(theText),
125+
(void *)theText,
126126
noopDeleter,
127127
NULL, // finalize_hint
128128
&theBuffer));

test/addons-napi/test_instanceof/test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ testFile(
5252
if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
5353
typeof Symbol.hasInstance === 'symbol') {
5454

55-
function compareToNative( object, constructor ) {
56-
return (addon.doInstanceOf( object, constructor) ===
57-
(object instanceof constructor ));
55+
function compareToNative(object, constructor) {
56+
assert.strictEqual(addon.doInstanceOf(object, constructor),
57+
(object instanceof constructor));
5858
}
5959

60-
var MyClass = function MyClass() {}
60+
const MyClass = function MyClass() {};
6161
Object.defineProperty(MyClass, Symbol.hasInstance, {
62-
value: function( candidate ) {
62+
value: function(candidate) {
6363
return 'mark' in candidate;
6464
}
65-
} );
65+
});
6666

67-
var MySubClass = function MySubClass() {}
67+
const MySubClass = function MySubClass() {};
6868
MySubClass.prototype = new MyClass();
6969

70-
var x = new MySubClass();
71-
var y = new MySubClass();
70+
let x = new MySubClass();
71+
let y = new MySubClass();
7272
x.mark = true;
7373

7474
compareToNative(x, MySubClass);

0 commit comments

Comments
 (0)