Skip to content

Commit 1d8b40c

Browse files
authored
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
1 parent 120fcd0 commit 1d8b40c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+152
-242
lines changed

.eslintrc.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/linux-build-and-test-compatibility.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ jobs:
3535
run: |
3636
source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
3737
npm i
38+
npm run lint
3839
npm test

.github/workflows/linux-build-and-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ jobs:
5050
run: |
5151
source /opt/ros/${{ needs.identify-ros-distro.outputs.distro }}/setup.bash
5252
npm i
53+
npm run lint
5354
npm test

eslint.config.mjs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import prettier from "eslint-plugin-prettier";
3+
import globals from "globals";
4+
import tsParser from "@typescript-eslint/parser";
5+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
6+
import js from "@eslint/js";
7+
8+
export default [
9+
{
10+
ignores: [
11+
"eslint.config.mjs",
12+
"types/interfaces.d.ts",
13+
"test/types/index.test-d.ts",
14+
"**/generated/",
15+
"**/scripts/",
16+
"**/benchmark/",
17+
"**/docs/",
18+
"**/electron_demo/",
19+
],
20+
},
21+
{
22+
...js.configs.recommended,
23+
files: ["lib/**/*.js", "index.js"],
24+
},
25+
{
26+
rules: {
27+
'no-dupe-class-members': 'off',
28+
},
29+
},
30+
{
31+
plugins: {
32+
"@typescript-eslint": typescriptEslint,
33+
},
34+
languageOptions: {
35+
globals: {
36+
...globals.node,
37+
},
38+
parser: tsParser,
39+
ecmaVersion: "latest",
40+
sourceType: "module",
41+
},
42+
files: ['types/*.d.ts'],
43+
rules: {
44+
...typescriptEslint.configs.recommended.rules,
45+
"@typescript-eslint/no-explicit-any": "off",
46+
},
47+
},
48+
{
49+
plugins: {
50+
prettier,
51+
},
52+
languageOptions: {
53+
globals: {
54+
...globals.node,
55+
},
56+
ecmaVersion: "latest",
57+
sourceType: "commonjs",
58+
},
59+
files: ["lib/**/*.js", "rosidl_parser/**/*.js", "rosidl_gen/**/*.js",
60+
"rostsd_gen/**/*.js", "test/**/*.js", "example/**/*.js", "index.js"],
61+
rules: {
62+
...eslintPluginPrettierRecommended.rules,
63+
},
64+
}
65+
];

example/publisher-content-filter-example.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
/* eslint-disable camelcase */
18-
1917
const rclnodejs = require('../index.js');
2018

2119
async function main() {

example/publisher-message-example.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
/* eslint-disable camelcase */
18-
1917
const rclnodejs = require('../index.js');
2018

2119
rclnodejs

example/publisher-multiarray-example.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
/* eslint-disable camelcase */
18-
1917
const rclnodejs = require('../index.js');
2018

2119
rclnodejs

example/publisher-raw-message.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
/* eslint-disable camelcase */
18-
1917
const rclnodejs = require('../index.js');
2018

2119
rclnodejs

example/subscription-multiarray-example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ rclnodejs
3636
const weightStride = dim[1].stride;
3737
const channel = dim[2].size;
3838
const channelStride = dim[2].stride;
39-
// eslint-disable-next-line
39+
4040
const offset = multiArray.layout.data_offset;
4141

4242
for (let i = 0; i < height; i++) {

example/subscription-raw-message.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
/* eslint-disable camelcase */
18-
1917
const rclnodejs = require('../index.js');
2018

2119
rclnodejs.init().then(() => {

0 commit comments

Comments
 (0)