From 1d8b40c1f5eb45ee5a124950c1ee3d5de96699e3 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 5 Mar 2025 15:25:42 +0800 Subject: [PATCH] Re-enable cpplint & eslint for Linux platform actions (#1057) This patch migrates `ESLint` configuration, `.eslintrc.yml` to [the new flat config format](https://eslint.org/docs/latest/use/configure/migration-guide) by creating `eslint.config.mjs`, meanwhile, re-enables [cpplint](https://github.com/cpplint/cpplint) for Linux platform actions, including: 1. Config `eslint` using recommended configs for `*.js` files in`eslint.config.mjs`. 2. Config `eslint-plugin-prettier` using recommended configs for `*.js` files in `eslint.config.mjs`. 3. Config `@typescript-eslint/eslint-plugin` using recommended configs for `*.d.ts` files in `eslint.config.mjs`. 4. Re-enable [`cpplint.py`](https://github.com/cpplint/cpplint/blob/develop/cpplint.py) for `*.{hpp,cpp}` files. 5. Fix errors/warnings reported by linters above. 6. Add `npm run lint` as addition step for actions, `.github/workflows/linux-build-and-test-compatibility.yml` and `.github/workflows/linux-build-and-test.yml`. 7. Remove original `.eslintrc.yml`. Fix: #1056 --- .eslintrc.yml | 25 ------- .../linux-build-and-test-compatibility.yml | 1 + .github/workflows/linux-build-and-test.yml | 1 + eslint.config.mjs | 65 +++++++++++++++++++ example/publisher-content-filter-example.js | 2 - example/publisher-message-example.js | 2 - example/publisher-multiarray-example.js | 2 - example/publisher-raw-message.js | 2 - example/subscription-multiarray-example.js | 2 +- example/subscription-raw-message.js | 2 - lib/action/client.js | 2 +- lib/clock_type.js | 2 - lib/distro.js | 2 +- lib/interface_loader.js | 3 +- lib/lifecycle.js | 5 -- lib/node.js | 4 +- lib/parameter.js | 14 ++-- lib/parameter_service.js | 2 - lib/qos.js | 2 - lib/time_source.js | 1 - package.json | 10 +-- rosidl_gen/action_msgs.js | 1 - rosidl_gen/filter.js | 1 - rosidl_gen/index.js | 1 - rosidl_gen/message_translator.js | 3 - rosidl_gen/primitive_types.js | 4 -- rostsd_gen/index.js | 4 -- scripts/cpplint.js | 7 +- src/executor.hpp | 6 +- src/handle_manager.hpp | 6 +- src/macros.hpp | 6 +- src/rcl_action_bindings.hpp | 6 +- src/rcl_bindings.cpp | 13 ++-- src/rcl_bindings.hpp | 6 +- src/rcl_handle.hpp | 6 +- src/rcl_lifecycle_bindings.hpp | 6 +- src/rcl_utilities.hpp | 6 +- src/shadow_node.hpp | 6 +- test/publisher_array_setup.js | 2 - test/publisher_msg_header.js | 2 - test/publisher_msg_jointstate.js | 2 - test/test-array-data.js | 17 +---- test/test-bounded-sequences.js | 3 - test/test-disable-typedarray.js | 3 - test/test-fixed-array.js | 4 -- test/test-message-properties-validation.js | 3 - test/test-message-translator-complex.js | 7 -- test/test-message-translator-primitive.js | 5 -- test/test-msg-type-cpp-node.js | 2 - test/test-msg-type-py-node.js | 2 - test/test-non-primitive-array.js | 4 -- test/test-non-primitive-msg-type-check.js | 1 - test/test-parameter-service.js | 1 - test/test-parameters.js | 2 - test/test-promise-gc.js | 1 - test/test-security-related.js | 2 +- test/utils.js | 1 - tsconfig.json | 19 ------ types/action_client.d.ts | 1 - types/action_server.d.ts | 1 - types/base.d.ts | 55 ++++++++-------- types/index.d.ts | 3 +- types/lifecycle.d.ts | 2 - types/node.d.ts | 1 - types/parameter.d.ts | 2 - types/publisher.d.ts | 1 - types/time.d.ts | 6 +- 67 files changed, 152 insertions(+), 242 deletions(-) delete mode 100644 .eslintrc.yml create mode 100644 eslint.config.mjs delete mode 100644 tsconfig.json diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 2a2f672c..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,25 +0,0 @@ -env: - node: true - es6: true -globals: - every: true - after: true - constantly: true -ignorePatterns: ['generated/', 'types/interfaces.d.ts'] -parser: 'babel-eslint' -rules: - prettier/prettier: 'error' -extends: ['prettier'] -plugins: ['prettier'] -parserOptions: - ecmaVersion: 2018 -overrides: - - files: ['*.ts'] - parser: '@typescript-eslint/parser' - plugins: ['@typescript-eslint'] - parserOptions: { - sourceType: 'module' - } - rules: { - strict: [0, 'global'] - } diff --git a/.github/workflows/linux-build-and-test-compatibility.yml b/.github/workflows/linux-build-and-test-compatibility.yml index 5d3f8caa..1b8e0de4 100644 --- a/.github/workflows/linux-build-and-test-compatibility.yml +++ b/.github/workflows/linux-build-and-test-compatibility.yml @@ -35,4 +35,5 @@ jobs: run: | source /opt/ros/${{ matrix.ros_distribution }}/setup.bash npm i + npm run lint npm test diff --git a/.github/workflows/linux-build-and-test.yml b/.github/workflows/linux-build-and-test.yml index 8a3ae654..06a43149 100644 --- a/.github/workflows/linux-build-and-test.yml +++ b/.github/workflows/linux-build-and-test.yml @@ -50,4 +50,5 @@ jobs: run: | source /opt/ros/${{ needs.identify-ros-distro.outputs.distro }}/setup.bash npm i + npm run lint npm test diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..1d12dd5f --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,65 @@ +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import prettier from "eslint-plugin-prettier"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import js from "@eslint/js"; + +export default [ + { + ignores: [ + "eslint.config.mjs", + "types/interfaces.d.ts", + "test/types/index.test-d.ts", + "**/generated/", + "**/scripts/", + "**/benchmark/", + "**/docs/", + "**/electron_demo/", + ], + }, + { + ...js.configs.recommended, + files: ["lib/**/*.js", "index.js"], + }, + { + rules: { + 'no-dupe-class-members': 'off', + }, + }, + { + plugins: { + "@typescript-eslint": typescriptEslint, + }, + languageOptions: { + globals: { + ...globals.node, + }, + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", + }, + files: ['types/*.d.ts'], + rules: { + ...typescriptEslint.configs.recommended.rules, + "@typescript-eslint/no-explicit-any": "off", + }, + }, + { + plugins: { + prettier, + }, + languageOptions: { + globals: { + ...globals.node, + }, + ecmaVersion: "latest", + sourceType: "commonjs", + }, + files: ["lib/**/*.js", "rosidl_parser/**/*.js", "rosidl_gen/**/*.js", + "rostsd_gen/**/*.js", "test/**/*.js", "example/**/*.js", "index.js"], + rules: { + ...eslintPluginPrettierRecommended.rules, + }, + } +]; diff --git a/example/publisher-content-filter-example.js b/example/publisher-content-filter-example.js index 8cae8a18..8c75608c 100644 --- a/example/publisher-content-filter-example.js +++ b/example/publisher-content-filter-example.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); async function main() { diff --git a/example/publisher-message-example.js b/example/publisher-message-example.js index ae595e45..e81147ca 100644 --- a/example/publisher-message-example.js +++ b/example/publisher-message-example.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/example/publisher-multiarray-example.js b/example/publisher-multiarray-example.js index 9db6aef7..65c738e9 100644 --- a/example/publisher-multiarray-example.js +++ b/example/publisher-multiarray-example.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/example/publisher-raw-message.js b/example/publisher-raw-message.js index c4850455..3b53d133 100644 --- a/example/publisher-raw-message.js +++ b/example/publisher-raw-message.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/example/subscription-multiarray-example.js b/example/subscription-multiarray-example.js index 73011b6c..596bb59c 100644 --- a/example/subscription-multiarray-example.js +++ b/example/subscription-multiarray-example.js @@ -36,7 +36,7 @@ rclnodejs const weightStride = dim[1].stride; const channel = dim[2].size; const channelStride = dim[2].stride; - // eslint-disable-next-line + const offset = multiArray.layout.data_offset; for (let i = 0; i < height; i++) { diff --git a/example/subscription-raw-message.js b/example/subscription-raw-message.js index 3c3c9773..4f6c3468 100644 --- a/example/subscription-raw-message.js +++ b/example/subscription-raw-message.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs.init().then(() => { diff --git a/lib/action/client.js b/lib/action/client.js index 28099230..0a7180e3 100644 --- a/lib/action/client.js +++ b/lib/action/client.js @@ -172,7 +172,7 @@ class ActionClient extends Entity { goalHandle.status = status; // Remove done handles from the list - // eslint-disable-next-line max-depth + if ( status === ActionInterfaces.GoalStatus.STATUS_SUCCEEDED || status === ActionInterfaces.GoalStatus.STATUS_CANCELED || diff --git a/lib/clock_type.js b/lib/clock_type.js index 65d7faeb..ad21b71b 100644 --- a/lib/clock_type.js +++ b/lib/clock_type.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - /** * Enum for ClockType * @readonly diff --git a/lib/distro.js b/lib/distro.js index 7313e522..d8df6321 100644 --- a/lib/distro.js +++ b/lib/distro.js @@ -63,7 +63,7 @@ const DistroUtils = { return process.env.ROS_DISTRO; } - return [...DistroNameIdMap].find(([key, val]) => val == distroId)[0]; + return [...DistroNameIdMap].find(([, val]) => val == distroId)[0]; }, getKnownDistroNames: function () { diff --git a/lib/interface_loader.js b/lib/interface_loader.js index 97ea76d4..e7d195ff 100644 --- a/lib/interface_loader.js +++ b/lib/interface_loader.js @@ -59,7 +59,6 @@ let interfaceLoader = { // Suppose the name is a package, and traverse the path to collect the IDL files. let packagePath = path.join(generator.generatedRoot, name); - // eslint-disable-next-line let interfaces = fs.readdirSync(packagePath); if (interfaces.length > 0) { return this.loadInterfaceByPath(packagePath, interfaces); @@ -108,7 +107,7 @@ let interfaceLoader = { packageName, packageName + '__' + type + '__' + messageName + '.js' ); - // eslint-disable-next-line + if (fs.existsSync(filePath)) { return require(filePath); } diff --git a/lib/lifecycle.js b/lib/lifecycle.js index 07d88808..15012d59 100644 --- a/lib/lifecycle.js +++ b/lib/lifecycle.js @@ -588,8 +588,6 @@ class LifecycleNode extends Node { * @throws {Error} If transition is invalid for the current state. */ shutdown(callbackReturnValue) { - let state = this.currentState; - return this._changeState(SHUTDOWN_TRANSITION_LABEL, callbackReturnValue); } @@ -603,7 +601,6 @@ class LifecycleNode extends Node { _onGetState(request, response) { let result = response.template; - // eslint-disable-next-line camelcase result.current_state = this.currentState; response.send(result); @@ -619,7 +616,6 @@ class LifecycleNode extends Node { _onGetAvailableStates(request, response) { let result = response.template; - // eslint-disable-next-line camelcase result.available_states = this.availableStates; response.send(result); @@ -634,7 +630,6 @@ class LifecycleNode extends Node { _onGetAvailableTransitions(request, response) { let result = response.template; - // eslint-disable-next-line camelcase result.available_transitions = this.availableTransitions; response.send(result); diff --git a/lib/node.js b/lib/node.js index aecf1ba4..f132ba09 100644 --- a/lib/node.js +++ b/lib/node.js @@ -1549,7 +1549,7 @@ class Node extends rclnodejs.ShadowNode { // detect invalid parameter try { parameter.validate(); - } catch (e) { + } catch { return { successful: false, reason: `Invalid ${parameter.name}`, @@ -1577,7 +1577,7 @@ class Node extends rclnodejs.ShadowNode { if (parameter.type != ParameterType.PARAMETER_NOT_SET) { try { descriptor.validateParameter(parameter); - } catch (e) { + } catch { return { successful: false, reason: `Parameter ${parameter.name} does not readonly`, diff --git a/lib/parameter.js b/lib/parameter.js index 9d267c4e..40e08f20 100644 --- a/lib/parameter.js +++ b/lib/parameter.js @@ -19,8 +19,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const IsClose = require('is-close'); /** @@ -273,7 +271,6 @@ class ParameterDescriptor { static fromParameter(parameter) { const name = parameter.name; const type = parameter.type; - const value = parameter.value; return new ParameterDescriptor(name, type, 'Created from parameter.'); } @@ -386,7 +383,7 @@ class ParameterDescriptor { return; } if (!(range instanceof Range)) { - throw TypeException('Expected instance of Range.'); + throw TypeError('Expected instance of Range.'); } if (!range.isValidType(this.type)) { throw TypeError('Incompatible Range'); @@ -442,14 +439,14 @@ class ParameterDescriptor { // ensure parameter is valid try { parameter.validate(); - } catch (e) { + } catch { throw new TypeError('Parameter is invalid'); } // ensure this descriptor is valid try { this.validate(); - } catch (e) { + } catch { throw new Error('Descriptor is invalid.'); } @@ -566,6 +563,7 @@ class Range { * @param {ParameterType} parameterType - The parameter type to test. * @return {boolean} - True if parameterType is compatible; otherwise return false. */ + // eslint-disable-next-line no-unused-vars isValidType(parameterType) { return false; } @@ -701,6 +699,7 @@ class IntegerRange extends Range { * @param {any} value - The value to infer it's ParameterType * @returns {ParameterType} - The ParameterType that best scribes the value. */ +// eslint-disable-next-line no-unused-vars function parameterTypeFromValue(value) { if (!value) return ParameterType.PARAMETER_NOT_SET; if (typeof value === 'boolean') return ParameterType.PARAMETER_BOOL; @@ -777,8 +776,7 @@ function validValue(value, type) { case ParameterType.PARAMETER_INTEGER_ARRAY: case ParameterType.PARAMETER_DOUBLE_ARRAY: case ParameterType.PARAMETER_STRING_ARRAY: - const values = value; - result = _validArray(values, type); + result = _validArray(value, type); break; default: result = false; diff --git a/lib/parameter_service.js b/lib/parameter_service.js index 772c04d4..6056950c 100644 --- a/lib/parameter_service.js +++ b/lib/parameter_service.js @@ -1,4 +1,3 @@ -/* eslint-disable max-depth */ // Copyright (c) 2020 Wayne Parrott. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ 'use strict'; -const rclnodejs = require('bindings')('rclnodejs'); const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js'); /** diff --git a/lib/qos.js b/lib/qos.js index b9bb0f4d..d6e0412b 100644 --- a/lib/qos.js +++ b/lib/qos.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable */ - /** * Enum for HistoryPolicy * @readonly diff --git a/lib/time_source.js b/lib/time_source.js index 2cdaf963..fc6f5814 100644 --- a/lib/time_source.js +++ b/lib/time_source.js @@ -17,7 +17,6 @@ const rclnodejs = require('bindings')('rclnodejs'); const { Clock, ROSClock } = require('./clock.js'); const { ClockType } = Clock; -const Node = require('./node.js'); const { Parameter, ParameterType } = require('./parameter.js'); const Time = require('./time.js'); diff --git a/package.json b/package.json index f0f9374c..51cd7633 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "postinstall": "npm run generate-messages", "docs": "cd docs && make", "test": "node --expose-gc ./scripts/run_test.js && npx tsd", - "lint": "eslint --max-warnings=0 --ext js,ts index.js types scripts lib example rosidl_gen rosidl_parser test benchmark/rclnodejs && node ./scripts/cpplint.js", + "lint": "eslint && node ./scripts/cpplint.js", "format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}", "prepare": "husky" }, @@ -43,17 +43,17 @@ "url": "git+https://github.com/RobotWebTools/rclnodejs.git" }, "devDependencies": { - "@babel/eslint-parser": "^7.25.9", - "@types/node": "^22.13.5", + "@eslint/js": "^10.0.0", + "@types/node": "^22.13.9", "@typescript-eslint/eslint-plugin": "^8.18.0", "@typescript-eslint/parser": "^8.18.0", - "babel-eslint": "^10.1.0", "clang-format": "^1.8.0", "commander": "^13.1.0", "deep-equal": "^2.2.3", "eslint": "^9.16.0", - "eslint-config-prettier": "^10.0.1", + "eslint-config-prettier": "^10.0.2", "eslint-plugin-prettier": "^5.2.1", + "globals": "^16.0.0", "husky": "^9.1.7", "jsdoc": "^4.0.4", "lint-staged": "^15.2.10", diff --git a/rosidl_gen/action_msgs.js b/rosidl_gen/action_msgs.js index 8305cf63..f6ab5f05 100644 --- a/rosidl_gen/action_msgs.js +++ b/rosidl_gen/action_msgs.js @@ -12,7 +12,6 @@ 'use strict'; -/* eslint-disable camelcase */ const GOAL_ID_FIELD = { name: 'goal_id', type: { diff --git a/rosidl_gen/filter.js b/rosidl_gen/filter.js index 03273bc1..d28e88ad 100644 --- a/rosidl_gen/filter.js +++ b/rosidl_gen/filter.js @@ -87,7 +87,6 @@ const RosPackageFilters = { if (!fs.existsSync(blocklistPath)) return; - // eslint-disable-next-line let blocklistData = JSON.parse(fs.readFileSync(blocklistPath, 'utf8')); let filters = blocklistData.map((pkgFilterData) => { diff --git a/rosidl_gen/index.js b/rosidl_gen/index.js index 2e428160..cc1a48d3 100644 --- a/rosidl_gen/index.js +++ b/rosidl_gen/index.js @@ -64,7 +64,6 @@ async function generateAll(forcedGenerating) { const generator = { version() { - // eslint-disable-next-line return fse.readJsonSync(path.join(__dirname, 'generator.json')).version; }, diff --git a/rosidl_gen/message_translator.js b/rosidl_gen/message_translator.js index 94e4da49..9b2ff311 100644 --- a/rosidl_gen/message_translator.js +++ b/rosidl_gen/message_translator.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable max-depth */ - function isTypedArray(value) { return ArrayBuffer.isView(value) && !(value instanceof DataView); } @@ -133,7 +131,6 @@ function toPlainObject(message, enableTypedArray = true) { array.push(toPlainObject(e, enableTypedArray)); // Translate every elements }); return array; - // eslint-disable-next-line no-else-return } else { // It's a ROS message const def = message.constructor.ROSMessageDef; diff --git a/rosidl_gen/primitive_types.js b/rosidl_gen/primitive_types.js index a2d60998..7099fc6d 100644 --- a/rosidl_gen/primitive_types.js +++ b/rosidl_gen/primitive_types.js @@ -18,8 +18,6 @@ const ref = require('@rclnodejs/ref-napi'); const StructType = require('@rclnodejs/ref-struct-di')(ref); const rclnodejs = require('bindings')('rclnodejs'); -/* eslint-disable camelcase */ - const StringRefStruct = StructType({ data: ref.types.CString, size: ref.types.size_t, @@ -65,5 +63,3 @@ module.exports = { wstring: StringRefStruct, initString: initString, }; - -/* eslint-enable camelcase */ diff --git a/rostsd_gen/index.js b/rostsd_gen/index.js index 4c9f6b68..176517a4 100644 --- a/rostsd_gen/index.js +++ b/rostsd_gen/index.js @@ -23,10 +23,6 @@ declare module "rclnodejs" { } */ -/* eslint-disable max-depth */ -/* eslint-disable no-sync */ -/* eslint-disable camelcase */ - 'use strict'; const path = require('path'); diff --git a/scripts/cpplint.js b/scripts/cpplint.js index 793f6488..1f25fcb7 100644 --- a/scripts/cpplint.js +++ b/scripts/cpplint.js @@ -18,10 +18,9 @@ const exec = require('child_process').exec; const cmd = 'wget -nc '; const cpplintUrl = - 'https://raw.githubusercontent.com/google/styleguide' + - '/gh-pages/cpplint/cpplint.py'; + 'https://raw.githubusercontent.com/cpplint/cpplint/refs/heads/develop/cpplint.py'; const root = `${__dirname}/../src`; -const args = `--extensions=cpp,h,hpp,cc ${root}/*`; +const args = `--filter=-build/include_subdir,-whitespace/indent_namespace --extensions=cpp,h,hpp,cc ${root}/*`; console.log('Downloading the cpplint...'); exec(cmd + cpplintUrl, (err, stdout, stderr) => { @@ -29,7 +28,7 @@ exec(cmd + cpplintUrl, (err, stdout, stderr) => { console.log(`Downloading failed: ${stderr}`); } else { console.log('Running the cpplint...'); - exec('python cpplint.py ' + args, (err, stdout, stderr) => { + exec('python3 cpplint.py ' + args, (err, stdout, stderr) => { console.log(stdout); if (err) { console.log(stderr); diff --git a/src/executor.hpp b/src/executor.hpp index 0469e6e8..5d16bf56 100644 --- a/src/executor.hpp +++ b/src/executor.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_EXECUTOR_HPP_ -#define RCLNODEJS_EXECUTOR_HPP_ +#ifndef SRC_EXECUTOR_HPP_ +#define SRC_EXECUTOR_HPP_ #include #include @@ -74,4 +74,4 @@ class Executor { } // namespace rclnodejs -#endif +#endif // SRC_EXECUTOR_HPP_ diff --git a/src/handle_manager.hpp b/src/handle_manager.hpp index d17f05f2..9605c8a8 100644 --- a/src/handle_manager.hpp +++ b/src/handle_manager.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_HANDLE_MANAGER_HPP_ -#define RCLNODEJS_HANDLE_MANAGER_HPP_ +#ifndef SRC_HANDLE_MANAGER_HPP_ +#define SRC_HANDLE_MANAGER_HPP_ #include #include @@ -132,4 +132,4 @@ class HandleManager { } // namespace rclnodejs -#endif +#endif // SRC_HANDLE_MANAGER_HPP_ diff --git a/src/macros.hpp b/src/macros.hpp index 9cf374dd..399d0fc5 100644 --- a/src/macros.hpp +++ b/src/macros.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_MARCOS_HPP_ -#define RCLNODEJS_MARCOS_HPP_ +#ifndef SRC_MACROS_HPP_ +#define SRC_MACROS_HPP_ #include "rcutils/logging_macros.h" @@ -43,4 +43,4 @@ #define RCLNODEJS_DEBUG(...) #endif -#endif +#endif // SRC_MACROS_HPP_ diff --git a/src/rcl_action_bindings.hpp b/src/rcl_action_bindings.hpp index 898ae6e0..115816fc 100644 --- a/src/rcl_action_bindings.hpp +++ b/src/rcl_action_bindings.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_RCL_ACTION_BINDINGS_HPP_ -#define RCLNODEJS_RCL_ACTION_BINDINGS_HPP_ +#ifndef SRC_RCL_ACTION_BINDINGS_HPP_ +#define SRC_RCL_ACTION_BINDINGS_HPP_ #include #include @@ -28,4 +28,4 @@ extern std::vector action_binding_methods; } // namespace rclnodejs -#endif +#endif // SRC_RCL_ACTION_BINDINGS_HPP_ diff --git a/src/rcl_bindings.cpp b/src/rcl_bindings.cpp index c5a7f4f2..4514d09e 100644 --- a/src/rcl_bindings.cpp +++ b/src/rcl_bindings.cpp @@ -40,6 +40,7 @@ #include #endif +#include #include #include #include @@ -963,7 +964,7 @@ NAN_METHOD(SendRequest) { THROW_ERROR_IF_NOT_EQUAL(rcl_send_request(client, buffer, &sequence_number), RCL_RET_OK, rcl_get_error_string().str); - info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number)); + info.GetReturnValue().Set(Nan::New(static_cast(sequence_number))); } NAN_METHOD(RclTakeResponse) { @@ -980,7 +981,7 @@ NAN_METHOD(RclTakeResponse) { int64_t sequence_number = header.request_id.sequence_number; if (ret == RCL_RET_OK) { - info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number)); + info.GetReturnValue().Set(Nan::New(static_cast(sequence_number))); return; } @@ -1161,7 +1162,7 @@ NAN_METHOD(ValidateFullTopicName) { Nan::Set( result_list, 0, Nan::New(std::string(validation_message)).ToLocalChecked()); - Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index)); + Nan::Set(result_list, 1, Nan::New(static_cast(invalid_index))); info.GetReturnValue().Set(result_list); } @@ -1196,7 +1197,7 @@ NAN_METHOD(ValidateNodeName) { Nan::Set( result_list, 0, Nan::New(std::string(validation_message)).ToLocalChecked()); - Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index)); + Nan::Set(result_list, 1, Nan::New(static_cast(invalid_index))); info.GetReturnValue().Set(result_list); } @@ -1231,7 +1232,7 @@ NAN_METHOD(ValidateTopicName) { Nan::Set( result_list, 0, Nan::New(std::string(validation_message)).ToLocalChecked()); - Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index)); + Nan::Set(result_list, 1, Nan::New(static_cast(invalid_index))); info.GetReturnValue().Set(result_list); } @@ -1266,7 +1267,7 @@ NAN_METHOD(ValidateNamespace) { Nan::Set( result_list, 0, Nan::New(std::string(validation_message)).ToLocalChecked()); - Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index)); + Nan::Set(result_list, 1, Nan::New(static_cast(invalid_index))); info.GetReturnValue().Set(result_list); } diff --git a/src/rcl_bindings.hpp b/src/rcl_bindings.hpp index 998d5676..8c8476f0 100644 --- a/src/rcl_bindings.hpp +++ b/src/rcl_bindings.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_RCL_BINDINGS_HPP_ -#define RCLNODEJS_RCL_BINDINGS_HPP_ +#ifndef SRC_RCL_BINDINGS_HPP_ +#define SRC_RCL_BINDINGS_HPP_ #include #include @@ -43,4 +43,4 @@ extern std::vector binding_methods; } // namespace rclnodejs -#endif +#endif // SRC_RCL_BINDINGS_HPP_ diff --git a/src/rcl_handle.hpp b/src/rcl_handle.hpp index aff9b186..143009e0 100644 --- a/src/rcl_handle.hpp +++ b/src/rcl_handle.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_RCL_HANDLE_HPP_ -#define RCLNODEJS_RCL_HANDLE_HPP_ +#ifndef SRC_RCL_HANDLE_HPP_ +#define SRC_RCL_HANDLE_HPP_ #include @@ -68,4 +68,4 @@ class RclHandle : public Nan::ObjectWrap { } // namespace rclnodejs -#endif +#endif // SRC_RCL_HANDLE_HPP_ diff --git a/src/rcl_lifecycle_bindings.hpp b/src/rcl_lifecycle_bindings.hpp index 2f84cb19..a7c75155 100644 --- a/src/rcl_lifecycle_bindings.hpp +++ b/src/rcl_lifecycle_bindings.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_ -#define RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_ +#ifndef SRC_RCL_LIFECYCLE_BINDINGS_HPP_ +#define SRC_RCL_LIFECYCLE_BINDINGS_HPP_ #include @@ -25,4 +25,4 @@ extern std::vector lifecycle_binding_methods; } // namespace rclnodejs -#endif +#endif // SRC_RCL_LIFECYCLE_BINDINGS_HPP_ diff --git a/src/rcl_utilities.hpp b/src/rcl_utilities.hpp index 30ec30f2..300b6ae0 100644 --- a/src/rcl_utilities.hpp +++ b/src/rcl_utilities.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_RCL_UTILITIES_HPP_ -#define RCLNODEJS_RCL_UTILITIES_HPP_ +#ifndef SRC_RCL_UTILITIES_HPP_ +#define SRC_RCL_UTILITIES_HPP_ #include @@ -37,4 +37,4 @@ std::string GetErrorMessageAndClear(); } // namespace rclnodejs -#endif +#endif // SRC_RCL_UTILITIES_HPP_ diff --git a/src/shadow_node.hpp b/src/shadow_node.hpp index 359cd8a6..e1b7f456 100644 --- a/src/shadow_node.hpp +++ b/src/shadow_node.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef RCLNODEJS_SHADOW_NODE_HPP_ -#define RCLNODEJS_SHADOW_NODE_HPP_ +#ifndef SRC_SHADOW_NODE_HPP_ +#define SRC_SHADOW_NODE_HPP_ #include @@ -60,4 +60,4 @@ class ShadowNode : public Nan::ObjectWrap, public Executor::Delegate { } // namespace rclnodejs -#endif +#endif // SRC_SHADOW_NODE_HPP_ diff --git a/test/publisher_array_setup.js b/test/publisher_array_setup.js index 56315b60..e1d1b8b2 100644 --- a/test/publisher_array_setup.js +++ b/test/publisher_array_setup.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/test/publisher_msg_header.js b/test/publisher_msg_header.js index 64ee73dd..8e9fde43 100644 --- a/test/publisher_msg_header.js +++ b/test/publisher_msg_header.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/test/publisher_msg_jointstate.js b/test/publisher_msg_jointstate.js index b244d29d..32d15d59 100644 --- a/test/publisher_msg_jointstate.js +++ b/test/publisher_msg_jointstate.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const rclnodejs = require('../index.js'); rclnodejs diff --git a/test/test-array-data.js b/test/test-array-data.js index eac2742c..dfc2b58c 100644 --- a/test/test-array-data.js +++ b/test/test-array-data.js @@ -32,10 +32,6 @@ describe('rclnodejs message communication', function () { rclnodejs.shutdown(); }); - /* eslint-disable camelcase */ - /* eslint-disable key-spacing */ - /* eslint-disable comma-spacing */ - const layout = { dim: [ { label: 'height', size: 10, stride: 600 }, @@ -143,9 +139,6 @@ describe('rclnodejs message communication', function () { }, // Provide data via TypedArray ], }, - /* eslint-enable camelcase */ - /* eslint-enable key-spacing */ - /* eslint-enable comma-spacing */ ].forEach((testData) => { const topic = testData.topic || 'topic' + testData.type; testData.values.forEach((v, i) => { @@ -222,9 +215,6 @@ describe('rclnodejs message communication', function () { ); [ - /* eslint-disable camelcase */ - /* eslint-disable key-spacing */ - /* eslint-disable comma-spacing */ { pkg: 'sensor_msgs', type: 'PointCloud2', @@ -353,9 +343,6 @@ describe('rclnodejs message communication', function () { }, ], }, - /* eslint-enable camelcase */ - /* eslint-enable key-spacing */ - /* eslint-enable comma-spacing */ ].forEach((testData) => { const topic = testData.topic || 'topic' + testData.type; testData.values.forEach((v, i) => { @@ -383,7 +370,6 @@ describe('rclnodejs message communication', function () { const arrayLength = 1024; [ - /* eslint-disable max-len */ { type: 'ByteMultiArray', arrayType: Uint8Array, @@ -583,7 +569,6 @@ describe('rclnodejs message communication', function () { Math.floor ), }, - /* eslint-enable max-len */ ].forEach((testData) => { const topic = testData.topic || 'topic' + testData.type; it('Make sure ' + testData.type + ' use TypedArray', function () { @@ -591,7 +576,7 @@ describe('rclnodejs message communication', function () { const msg = translator.toROSMessage(MessageType, { layout: { dim: [{ label: 'length', size: 0, stride: 0 }], - // eslint-disable-next-line + data_offset: 0, }, data: testData.values, diff --git a/test/test-bounded-sequences.js b/test/test-bounded-sequences.js index d4ddf146..1cc47dda 100644 --- a/test/test-bounded-sequences.js +++ b/test/test-bounded-sequences.js @@ -17,9 +17,6 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -/* eslint-disable camelcase */ -/* eslint-disable key-spacing */ -/* eslint-disable comma-spacing */ describe('Test bounded sequeces', function () { this.timeout(60 * 1000); diff --git a/test/test-disable-typedarray.js b/test/test-disable-typedarray.js index 11c959b9..2e4688cb 100644 --- a/test/test-disable-typedarray.js +++ b/test/test-disable-typedarray.js @@ -17,9 +17,6 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -/* eslint-disable camelcase */ -/* eslint-disable key-spacing */ -/* eslint-disable comma-spacing */ describe('rclnodejs message communication', function () { this.timeout(60 * 1000); diff --git a/test/test-fixed-array.js b/test/test-fixed-array.js index 647260bd..91c5c6d5 100644 --- a/test/test-fixed-array.js +++ b/test/test-fixed-array.js @@ -17,10 +17,6 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -/* eslint-disable camelcase */ -/* eslint-disable key-spacing */ -/* eslint-disable comma-spacing */ - describe('Test message which has a fixed array of 36', function () { this.timeout(60 * 1000); diff --git a/test/test-message-properties-validation.js b/test/test-message-properties-validation.js index e2c22376..f38d72de 100644 --- a/test/test-message-properties-validation.js +++ b/test/test-message-properties-validation.js @@ -29,9 +29,6 @@ describe('Rclnodejs message properities validation', function () { rclnodejs.shutdown(); }); - /* eslint-disable camelcase */ - /* eslint-disable key-spacing */ - /* eslint-disable comma-spacing */ [ { pkg: 'std_msgs', diff --git a/test/test-message-translator-complex.js b/test/test-message-translator-complex.js index b7365bc6..355b8005 100644 --- a/test/test-message-translator-complex.js +++ b/test/test-message-translator-complex.js @@ -28,10 +28,6 @@ describe('Rclnodejs message translation: complex types', function () { rclnodejs.shutdown(); }); - /* eslint-disable camelcase */ - /* eslint-disable key-spacing */ - /* eslint-disable comma-spacing */ - [ { pkg: 'std_msgs', @@ -205,9 +201,6 @@ describe('Rclnodejs message translation: complex types', function () { }, ], }, - /* eslint-enable camelcase */ - /* eslint-enable key-spacing */ - /* eslint-enable comma-spacing */ ].forEach((testData) => { const topic = testData.topic || 'topic' + testData.type; testData.values.forEach((v, i) => { diff --git a/test/test-message-translator-primitive.js b/test/test-message-translator-primitive.js index 5bcefb71..8d5b3d91 100644 --- a/test/test-message-translator-primitive.js +++ b/test/test-message-translator-primitive.js @@ -19,9 +19,6 @@ const deepEqual = require('deep-equal'); const arrayGen = require('./array_generator.js'); const { isTypedArray } = require('./utils.js'); -/* eslint-disable camelcase */ -/* eslint-disable indent */ - describe('Rclnodejs message translation: primitive types', function () { this.timeout(60 * 1000); @@ -259,7 +256,6 @@ describe('Rclnodejs message translation: TypedArray large data', function () { const arrayLength = 100 * 1000; [ - /* eslint-disable max-len */ { type: 'ByteMultiArray', values: arrayGen.generateValues( @@ -464,7 +460,6 @@ describe('Rclnodejs message translation: TypedArray large data', function () { Math.floor ), }, - /* eslint-enable max-len */ ].forEach((testData) => { const topic = testData.topic || 'topic' + testData.type; it( diff --git a/test/test-msg-type-cpp-node.js b/test/test-msg-type-cpp-node.js index 38315682..6ea2d346 100644 --- a/test/test-msg-type-cpp-node.js +++ b/test/test-msg-type-cpp-node.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const assert = require('assert'); const path = require('path'); const childProcess = require('child_process'); diff --git a/test/test-msg-type-py-node.js b/test/test-msg-type-py-node.js index 26ab5044..6e9c9c32 100644 --- a/test/test-msg-type-py-node.js +++ b/test/test-msg-type-py-node.js @@ -14,8 +14,6 @@ 'use strict'; -/* eslint-disable camelcase */ - const assert = require('assert'); const childProcess = require('child_process'); const deepEqual = require('deep-equal'); diff --git a/test/test-non-primitive-array.js b/test/test-non-primitive-array.js index 2b3535c8..228fd713 100644 --- a/test/test-non-primitive-array.js +++ b/test/test-non-primitive-array.js @@ -17,10 +17,6 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -/* eslint-disable camelcase */ -/* eslint-disable key-spacing */ -/* eslint-disable comma-spacing */ - describe('Test message which has a non-primitive array', function () { this.timeout(60 * 1000); diff --git a/test/test-non-primitive-msg-type-check.js b/test/test-non-primitive-msg-type-check.js index f459b214..02e45817 100644 --- a/test/test-non-primitive-msg-type-check.js +++ b/test/test-non-primitive-msg-type-check.js @@ -17,7 +17,6 @@ const assert = require('assert'); const rclnodejs = require('../index.js'); -/* eslint-disable camelcase */ describe('Rclnodejs non primitive message type testing', function () { this.timeout(60 * 1000); diff --git a/test/test-parameter-service.js b/test/test-parameter-service.js index 047a99e8..ffe236be 100644 --- a/test/test-parameter-service.js +++ b/test/test-parameter-service.js @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ // Copyright (c) Wayne Parrott All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test/test-parameters.js b/test/test-parameters.js index eaf4892c..14039206 100644 --- a/test/test-parameters.js +++ b/test/test-parameters.js @@ -645,12 +645,10 @@ describe('rclnodejs parameters test suite', function () { let node; this.timeout(60 * 1000); - /* eslint-disable-next-line space-before-function-paren */ before(async () => { await rclnodejs.init(); }); - /* eslint-disable-next-line space-before-function-paren */ this.beforeEach(async () => { node = rclnodejs.createNode(NODE_NAME); PARAMETER = new Parameter(PARAM_NAME, PARAM_TYPE, PARAM_VALUE); diff --git a/test/test-promise-gc.js b/test/test-promise-gc.js index 99dc0b1e..1495b4c3 100644 --- a/test/test-promise-gc.js +++ b/test/test-promise-gc.js @@ -15,7 +15,6 @@ * */ -/* eslint-disable camelcase */ 'use strict'; const assert = require('assert'); diff --git a/test/test-security-related.js b/test/test-security-related.js index 4fe29395..539dcde9 100644 --- a/test/test-security-related.js +++ b/test/test-security-related.js @@ -292,7 +292,7 @@ describe('Fuzzing API calls testing', function () { for (let i = 0; i < dataLength; i++) { uint8Data[i] = i % 255; } - /* eslint-disable camelcase */ + const value = { header: { stamp: { sec: 11223, nanosec: 44556 }, frame_id: 'f001' }, height: 240, diff --git a/test/utils.js b/test/utils.js index f20d4105..d7d9ca28 100644 --- a/test/utils.js +++ b/test/utils.js @@ -66,7 +66,6 @@ function getAvailablePath(amentPrefixPath, otherDirs) { appendedPath = path.join(appendedPath, dir); }); - // eslint-disable-next-line if (fs.existsSync(appendedPath) || fs.existsSync(appendedPath + '.exe')) { availablePath = appendedPath; } diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index da883ca9..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "moduleResolution": "node", - "target": "es6", - /* Strict Type-Checking Options */ - "strict": true, - /* Additional Checks */ - /* next line commented out because we need unused vars for type tests */ - // "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "lib": ["es2017"] - }, - "include": [ - "types/**/*" - ] -} \ No newline at end of file diff --git a/types/action_client.d.ts b/types/action_client.d.ts index a02efb99..8f731dc0 100644 --- a/types/action_client.d.ts +++ b/types/action_client.d.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ declare module 'rclnodejs' { type ActionGoal = T extends ActionTypeClassName ? InstanceType diff --git a/types/action_server.d.ts b/types/action_server.d.ts index 194cb4a7..bd346ded 100644 --- a/types/action_server.d.ts +++ b/types/action_server.d.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ declare module 'rclnodejs' { /** * Goal handle for working with Action Servers. diff --git a/types/base.d.ts b/types/base.d.ts index 1bf78ef6..c42583ab 100644 --- a/types/base.d.ts +++ b/types/base.d.ts @@ -1,28 +1,27 @@ -/* eslint-disable spaced-comment */ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// diff --git a/types/index.d.ts b/types/index.d.ts index b0e4dafe..5e761c65 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,4 @@ -// eslint-disable-next-line spaced-comment -/// +/// declare module 'rclnodejs' { /** diff --git a/types/lifecycle.d.ts b/types/lifecycle.d.ts index 8ba0d043..4e089f1d 100644 --- a/types/lifecycle.d.ts +++ b/types/lifecycle.d.ts @@ -53,10 +53,8 @@ declare module 'rclnodejs' { asMessage(): { transition: SerializedState; - // eslint-disable-next-line camelcase start_state: SerializedState; - // eslint-disable-next-line camelcase goal_state: SerializedState; }; } diff --git a/types/node.d.ts b/types/node.d.ts index 82acd931..b6551629 100644 --- a/types/node.d.ts +++ b/types/node.d.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ declare module 'rclnodejs' { /** * Identifies type of ROS message such as msg or srv. diff --git a/types/parameter.d.ts b/types/parameter.d.ts index f0dde114..ca065126 100644 --- a/types/parameter.d.ts +++ b/types/parameter.d.ts @@ -1,5 +1,3 @@ -/* eslint-disable camelcase */ - declare module 'rclnodejs' { /** * The plus/minus tolerance for determining number equivalence. diff --git a/types/publisher.d.ts b/types/publisher.d.ts index bf9edf38..89fe12f7 100644 --- a/types/publisher.d.ts +++ b/types/publisher.d.ts @@ -8,7 +8,6 @@ declare module 'rclnodejs' { * Topic on which messages are published. */ readonly topic: string; - /** * Publish a message * diff --git a/types/time.d.ts b/types/time.d.ts index 3bc70cb4..f1fee901 100644 --- a/types/time.d.ts +++ b/types/time.d.ts @@ -1,6 +1,4 @@ -/* eslint-disable camelcase */ - -import { Message, builtin_interfaces } from 'rclnodejs'; +import { builtin_interfaces } from 'rclnodejs'; declare module 'rclnodejs' { /** @@ -100,7 +98,6 @@ declare module 'rclnodejs' { * * @returns The new Time message. */ - // eslint-disable-next-line camelcase toMsg(): builtin_interfaces.msg.Time; /** @@ -110,7 +107,6 @@ declare module 'rclnodejs' { * @param clockType - The type of the time object. Default is ClockType.ROS_TIME * @returns The new Time. */ - // eslint-disable-next-line camelcase static fromMsg( msg: builtin_interfaces.msg.Time, clockType?: ClockType