Skip to content

Commit

Permalink
Re-enable cpplint & eslint on Actions for Linux platform
Browse files Browse the repository at this point in the history
  • Loading branch information
minggangw committed Mar 4, 2025
1 parent 120fcd0 commit 395ed22
Show file tree
Hide file tree
Showing 55 changed files with 102 additions and 183 deletions.
25 changes: 0 additions & 25 deletions .eslintrc.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/linux-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ jobs:
run: |
source /opt/ros/${{ needs.identify-ros-distro.outputs.distro }}/setup.bash
npm i
npm run lint
npm test
55 changes: 55 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import prettier from "eslint-plugin-prettier";
import globals from "globals";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["generated/", "eslint.config.mjs", "lib/", "types/", "scripts/", "benchmark/", "docs/", "electron_demo/"],
}, ...compat.extends("prettier"), {
plugins: {
prettier,
},

languageOptions: {
globals: {
...globals.node,
every: true,
after: true,
constantly: true,
},

ecmaVersion: "latest",
sourceType: "commonjs",
},

rules: {
"prettier/prettier": "error",
},
}, {
files: ["types/*.d.ts"],

plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
sourceType: "module",
},

rules: {
strict: [0, "global"],
},
}];
2 changes: 0 additions & 2 deletions example/publisher-content-filter-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

const rclnodejs = require('../index.js');

async function main() {
Expand Down
2 changes: 0 additions & 2 deletions example/publisher-message-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

const rclnodejs = require('../index.js');

rclnodejs
Expand Down
2 changes: 0 additions & 2 deletions example/publisher-multiarray-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

const rclnodejs = require('../index.js');

rclnodejs
Expand Down
2 changes: 0 additions & 2 deletions example/publisher-raw-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

const rclnodejs = require('../index.js');

rclnodejs
Expand Down
2 changes: 1 addition & 1 deletion example/subscription-multiarray-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 0 additions & 2 deletions example/subscription-raw-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

const rclnodejs = require('../index.js');

rclnodejs.init().then(() => {
Expand Down
2 changes: 1 addition & 1 deletion lib/action/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
2 changes: 0 additions & 2 deletions lib/clock_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable camelcase */

/**
* Enum for ClockType
* @readonly
Expand Down
3 changes: 1 addition & 2 deletions lib/interface_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -108,7 +107,7 @@ let interfaceLoader = {
packageName,
packageName + '__' + type + '__' + messageName + '.js'
);
// eslint-disable-next-line

if (fs.existsSync(filePath)) {
return require(filePath);
}
Expand Down
3 changes: 0 additions & 3 deletions lib/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,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);
Expand All @@ -619,7 +618,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);
Expand All @@ -634,7 +632,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);
Expand Down
2 changes: 0 additions & 2 deletions lib/parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

'use strict';

/* eslint-disable camelcase */

const IsClose = require('is-close');

/**
Expand Down
1 change: 0 additions & 1 deletion lib/parameter_service.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 0 additions & 2 deletions lib/qos.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable */

/**
* Enum for HistoryPolicy
* @readonly
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -44,6 +44,8 @@
},
"devDependencies": {
"@babel/eslint-parser": "^7.25.9",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.21.0",
"@types/node": "^22.13.5",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
Expand All @@ -54,6 +56,7 @@
"eslint": "^9.16.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^16.0.0",
"husky": "^9.1.7",
"jsdoc": "^4.0.4",
"lint-staged": "^15.2.10",
Expand Down
1 change: 0 additions & 1 deletion rosidl_gen/action_msgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

'use strict';

/* eslint-disable camelcase */
const GOAL_ID_FIELD = {
name: 'goal_id',
type: {
Expand Down
1 change: 0 additions & 1 deletion rosidl_gen/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
1 change: 0 additions & 1 deletion rosidl_gen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ async function generateAll(forcedGenerating) {

const generator = {
version() {
// eslint-disable-next-line
return fse.readJsonSync(path.join(__dirname, 'generator.json')).version;
},

Expand Down
3 changes: 0 additions & 3 deletions rosidl_gen/message_translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

'use strict';

/* eslint-disable max-depth */

function isTypedArray(value) {
return ArrayBuffer.isView(value) && !(value instanceof DataView);
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions rosidl_gen/primitive_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -65,5 +63,3 @@ module.exports = {
wstring: StringRefStruct,
initString: initString,
};

/* eslint-enable camelcase */
4 changes: 0 additions & 4 deletions rostsd_gen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ declare module "rclnodejs" {
}
*/

/* eslint-disable max-depth */
/* eslint-disable no-sync */
/* eslint-disable camelcase */

'use strict';

const path = require('path');
Expand Down
7 changes: 3 additions & 4 deletions scripts/cpplint.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ 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) => {
if (err) {
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);
Expand Down
6 changes: 3 additions & 3 deletions src/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rcl/wait.h>
#include <uv.h>
Expand Down Expand Up @@ -74,4 +74,4 @@ class Executor {

} // namespace rclnodejs

#endif
#endif // SRC_EXECUTOR_HPP_
6 changes: 3 additions & 3 deletions src/handle_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <nan.h>
#include <rcl/wait.h>
Expand Down Expand Up @@ -132,4 +132,4 @@ class HandleManager {

} // namespace rclnodejs

#endif
#endif // SRC_HANDLE_MANAGER_HPP_
6 changes: 3 additions & 3 deletions src/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -43,4 +43,4 @@
#define RCLNODEJS_DEBUG(...)
#endif

#endif
#endif // SRC_MACROS_HPP_
Loading

0 comments on commit 395ed22

Please sign in to comment.