From faba8d4a307bc94afbd3bfe81e9556d863ad3643 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 25 Jan 2023 07:05:09 +0100 Subject: [PATCH] test: add trailing commas in `test/js-native-api` PR-URL: https://github.com/nodejs/node/pull/46385 Reviewed-By: James M Snell Reviewed-By: Chengzhong Wu --- test/.eslintrc.yaml | 1 - test/js-native-api/test_array/test.js | 4 ++-- test/js-native-api/test_bigint/test.js | 2 +- test/js-native-api/test_constructor/test.js | 2 +- test/js-native-api/test_conversions/test.js | 22 +++++++++---------- test/js-native-api/test_error/test.js | 10 ++++----- test/js-native-api/test_exception/test.js | 4 ++-- test/js-native-api/test_function/test.js | 6 ++--- .../test_general/testEnvCleanup.js | 6 ++--- .../test_general/testInstanceOf.js | 4 ++-- test/js-native-api/test_object/test.js | 22 +++++++++---------- test/js-native-api/test_object/test_null.js | 4 ++-- 12 files changed, 43 insertions(+), 44 deletions(-) diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 5980fcd624db66..b4022563cfbfe9 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -76,7 +76,6 @@ overrides: - files: - es-module/*.js - es-module/*.mjs - - js-native-api/*/*.js - parallel/*.js - parallel/*.mjs - pummel/*.js diff --git a/test/js-native-api/test_array/test.js b/test/js-native-api/test_array/test.js index c2a6b11a6074d5..bec7e657a76d39 100644 --- a/test/js-native-api/test_array/test.js +++ b/test/js-native-api/test_array/test.js @@ -23,14 +23,14 @@ assert.throws( () => { test_array.TestGetElement(array, array.length + 1); }, - /^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/ + /^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/, ); assert.throws( () => { test_array.TestGetElement(array, -2); }, - /^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/ + /^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/, ); array.forEach(function(element, index) { diff --git a/test/js-native-api/test_bigint/test.js b/test/js-native-api/test_bigint/test.js index 509c263c733a53..75fccc8512717b 100644 --- a/test/js-native-api/test_bigint/test.js +++ b/test/js-native-api/test_bigint/test.js @@ -48,5 +48,5 @@ assert.throws(() => CreateTooBigBigInt(), { // Test that we correctly forward exceptions from the engine. assert.throws(() => MakeBigIntWordsThrow(), { name: 'RangeError', - message: 'Maximum BigInt size exceeded' + message: 'Maximum BigInt size exceeded', }); diff --git a/test/js-native-api/test_constructor/test.js b/test/js-native-api/test_constructor/test.js index c5be4c93bf81e9..6fb33d935489b5 100644 --- a/test/js-native-api/test_constructor/test.js +++ b/test/js-native-api/test_constructor/test.js @@ -58,5 +58,5 @@ assert.deepStrictEqual(TestConstructor.TestDefineClass(), { cbIsNull: 'Invalid argument', cbDataIsNull: 'napi_ok', propertiesIsNull: 'Invalid argument', - resultIsNull: 'Invalid argument' + resultIsNull: 'Invalid argument', }); diff --git a/test/js-native-api/test_conversions/test.js b/test/js-native-api/test_conversions/test.js index f7054f52744714..02227fd27920d1 100644 --- a/test/js-native-api/test_conversions/test.js +++ b/test/js-native-api/test_conversions/test.js @@ -143,28 +143,28 @@ assert.deepStrictEqual(test.testNull.getValueBool(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'A boolean was expected' + inputTypeCheck: 'A boolean was expected', }); assert.deepStrictEqual(test.testNull.getValueInt32(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'A number was expected' + inputTypeCheck: 'A number was expected', }); assert.deepStrictEqual(test.testNull.getValueUint32(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'A number was expected' + inputTypeCheck: 'A number was expected', }); assert.deepStrictEqual(test.testNull.getValueInt64(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'A number was expected' + inputTypeCheck: 'A number was expected', }); @@ -172,47 +172,47 @@ assert.deepStrictEqual(test.testNull.getValueDouble(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'A number was expected' + inputTypeCheck: 'A number was expected', }); assert.deepStrictEqual(test.testNull.coerceToBool(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'napi_ok' + inputTypeCheck: 'napi_ok', }); assert.deepStrictEqual(test.testNull.coerceToObject(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'napi_ok' + inputTypeCheck: 'napi_ok', }); assert.deepStrictEqual(test.testNull.coerceToString(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', resultIsNull: 'Invalid argument', - inputTypeCheck: 'napi_ok' + inputTypeCheck: 'napi_ok', }); assert.deepStrictEqual(test.testNull.getValueStringUtf8(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', wrongTypeIn: 'A string was expected', - bufAndOutLengthIsNull: 'Invalid argument' + bufAndOutLengthIsNull: 'Invalid argument', }); assert.deepStrictEqual(test.testNull.getValueStringLatin1(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', wrongTypeIn: 'A string was expected', - bufAndOutLengthIsNull: 'Invalid argument' + bufAndOutLengthIsNull: 'Invalid argument', }); assert.deepStrictEqual(test.testNull.getValueStringUtf16(), { envIsNull: 'Invalid argument', valueIsNull: 'Invalid argument', wrongTypeIn: 'A string was expected', - bufAndOutLengthIsNull: 'Invalid argument' + bufAndOutLengthIsNull: 'Invalid argument', }); diff --git a/test/js-native-api/test_error/test.js b/test/js-native-api/test_error/test.js index e39d4344b39b61..c9725df09dadba 100644 --- a/test/js-native-api/test_error/test.js +++ b/test/js-native-api/test_error/test.js @@ -70,35 +70,35 @@ assert.throws(() => { (err) => { assert.strictEqual(err, value); return true; - } + }, )); assert.throws( () => test_error.throwErrorCode(), { code: 'ERR_TEST_CODE', - message: 'Error [error]' + message: 'Error [error]', }); assert.throws( () => test_error.throwRangeErrorCode(), { code: 'ERR_TEST_CODE', - message: 'RangeError [range error]' + message: 'RangeError [range error]', }); assert.throws( () => test_error.throwTypeErrorCode(), { code: 'ERR_TEST_CODE', - message: 'TypeError [type error]' + message: 'TypeError [type error]', }); assert.throws( () => test_error.throwSyntaxErrorCode(), { code: 'ERR_TEST_CODE', - message: 'SyntaxError [syntax error]' + message: 'SyntaxError [syntax error]', }); let error = test_error.createError(); diff --git a/test/js-native-api/test_exception/test.js b/test/js-native-api/test_exception/test.js index 38e8fd1d6b6bdc..9e1d0d960628e9 100644 --- a/test/js-native-api/test_exception/test.js +++ b/test/js-native-api/test_exception/test.js @@ -31,7 +31,7 @@ const test_exception = (function() { // Test that the native side passes the exception through assert.throws( () => { test_exception.allowException(throwTheError); }, - (err) => err === theError + (err) => err === theError, ); // Test that the exception thrown above was marked as pending @@ -59,7 +59,7 @@ const test_exception = (function() { // Test that the native side passes the exception through assert.throws( () => { test_exception.constructAllowException(throwTheError); }, - (err) => err === theError + (err) => err === theError, ); // Test that the exception thrown above was marked as pending diff --git a/test/js-native-api/test_function/test.js b/test/js-native-api/test_function/test.js index 972adcd79f54b2..a976540f5d6230 100644 --- a/test/js-native-api/test_function/test.js +++ b/test/js-native-api/test_function/test.js @@ -40,13 +40,13 @@ assert.deepStrictEqual(test_function.TestCreateFunctionParameters(), { envIsNull: 'Invalid argument', nameIsNull: 'napi_ok', cbIsNull: 'Invalid argument', - resultIsNull: 'Invalid argument' + resultIsNull: 'Invalid argument', }); assert.throws( () => test_function.TestBadReturnExceptionPending(), { code: 'throwing exception', - name: 'Error' - } + name: 'Error', + }, ); diff --git a/test/js-native-api/test_general/testEnvCleanup.js b/test/js-native-api/test_general/testEnvCleanup.js index 99b47a3e62560f..4aa707d3de03ea 100644 --- a/test/js-native-api/test_general/testEnvCleanup.js +++ b/test/js-native-api/test_general/testEnvCleanup.js @@ -11,7 +11,7 @@ if (process.argv[2] === 'child') { 'simple wrap': 0, 'wrap, removeWrap': 1, 'first wrap': 2, - 'second wrap': 3 + 'second wrap': 3, }; // We attach the three objects we will test to `module.exports` to ensure they @@ -39,7 +39,7 @@ if (process.argv[2] === 'child') { const { spawnSync } = require('child_process'); const child = spawnSync(process.execPath, [__filename, 'child'], { - stdio: [ process.stdin, 'pipe', process.stderr ] + stdio: [ process.stdin, 'pipe', process.stderr ], }); // Grab the child's output and construct an object whose keys are the rows of @@ -49,7 +49,7 @@ if (process.argv[2] === 'child') { child.stdout.toString().split(/\r\n|\r|\n/g).reduce((obj, item) => Object.assign(obj, item ? { [item]: true } : {}), {}), { 'finalize at env cleanup for simple wrap': true, - 'finalize at env cleanup for second wrap': true + 'finalize at env cleanup for second wrap': true, }); // Ensure that the child exited successfully. diff --git a/test/js-native-api/test_general/testInstanceOf.js b/test/js-native-api/test_general/testInstanceOf.js index d50ce7a27c3efa..dedc5a0e6b96f8 100644 --- a/test/js-native-api/test_general/testInstanceOf.js +++ b/test/js-native-api/test_general/testInstanceOf.js @@ -61,7 +61,7 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol && function compareToNative(theObject, theConstructor) { assert.strictEqual( addon.doInstanceOf(theObject, theConstructor), - (theObject instanceof theConstructor) + (theObject instanceof theConstructor), ); } @@ -69,7 +69,7 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol && Object.defineProperty(MyClass, Symbol.hasInstance, { value: function(candidate) { return 'mark' in candidate; - } + }, }); function MySubClass() {} diff --git a/test/js-native-api/test_object/test.js b/test/js-native-api/test_object/test.js index 74d73482943cfa..012f737ba74b43 100644 --- a/test/js-native-api/test_object/test.js +++ b/test/js-native-api/test_object/test.js @@ -12,8 +12,8 @@ const object = { 1, 94, 'str', 12.321, { test: 'obj in arr' }, ], newObject: { - test: 'obj in obj' - } + test: 'obj in obj', + }, }; assert.strictEqual(test_object.Get(object, 'hello'), 'world'); @@ -91,7 +91,7 @@ assert.strictEqual(newObject.test_string, 'test string'); const cube = { x: 10, y: 10, - z: 10 + z: 10, }; assert.deepStrictEqual(test_object.Inflate(cube), { x: 11, y: 11, z: 11 }); @@ -107,7 +107,7 @@ assert.strictEqual(newObject.test_string, 'test string'); const sym4 = Symbol('4'); const object2 = { [sym1]: '@@iterator', - [sym2]: sym3 + [sym2]: sym3, }; assert(test_object.Has(object2, sym1)); @@ -236,7 +236,7 @@ assert.strictEqual(newObject.test_string, 'test string'); // and includes indices and converts them to strings. const object = { __proto__: { - inherited: 1 + inherited: 1, } }; const fooSymbol = Symbol('foo'); @@ -247,19 +247,19 @@ assert.strictEqual(newObject.test_string, 'test string'); value: 4, enumerable: false, writable: true, - configurable: true + configurable: true, }); Object.defineProperty(object, 'writable', { value: 4, enumerable: true, writable: true, - configurable: false + configurable: false, }); Object.defineProperty(object, 'configurable', { value: 4, enumerable: true, writable: false, - configurable: true + configurable: true, }); object[5] = 5; @@ -308,7 +308,7 @@ assert.deepStrictEqual(test_object.TestSetProperty(), { envIsNull: 'Invalid argument', objectIsNull: 'Invalid argument', keyIsNull: 'Invalid argument', - valueIsNull: 'Invalid argument' + valueIsNull: 'Invalid argument', }); // Verify that passing NULL to napi_has_property() results in the correct @@ -317,7 +317,7 @@ assert.deepStrictEqual(test_object.TestHasProperty(), { envIsNull: 'Invalid argument', objectIsNull: 'Invalid argument', keyIsNull: 'Invalid argument', - resultIsNull: 'Invalid argument' + resultIsNull: 'Invalid argument', }); // Verify that passing NULL to napi_get_property() results in the correct @@ -326,7 +326,7 @@ assert.deepStrictEqual(test_object.TestGetProperty(), { envIsNull: 'Invalid argument', objectIsNull: 'Invalid argument', keyIsNull: 'Invalid argument', - resultIsNull: 'Invalid argument' + resultIsNull: 'Invalid argument', }); { diff --git a/test/js-native-api/test_object/test_null.js b/test/js-native-api/test_object/test_null.js index b6f07881080e7c..399952aaeb0724 100644 --- a/test/js-native-api/test_object/test_null.js +++ b/test/js-native-api/test_object/test_null.js @@ -9,7 +9,7 @@ const expectedForProperty = { envIsNull: 'Invalid argument', objectIsNull: 'Invalid argument', keyIsNull: 'Invalid argument', - valueIsNull: 'Invalid argument' + valueIsNull: 'Invalid argument', }; assert.deepStrictEqual(testNull.setProperty(), expectedForProperty); assert.deepStrictEqual(testNull.getProperty(), expectedForProperty); @@ -28,7 +28,7 @@ assert.deepStrictEqual(testNull.hasNamedProperty(), expectedForProperty); const expectedForElement = { envIsNull: 'Invalid argument', objectIsNull: 'Invalid argument', - valueIsNull: 'Invalid argument' + valueIsNull: 'Invalid argument', }; assert.deepStrictEqual(testNull.setElement(), expectedForElement); assert.deepStrictEqual(testNull.getElement(), expectedForElement);