Skip to content

Commit b3f399c

Browse files
authored
chore(deps): migrate to ESLint 9 and @lichtblick/eslint-plugin 2.x (#191)
* chore(deps): migrate to ESLint 9 and @lichtblick/eslint-plugin 2.x Migrate from ESLint 8 to ESLint 9 flat config, aligning with Lichtblick v1.25.0: - Replace .eslintrc.yaml + .eslintignore with eslint.config.mjs (flat config) - Upgrade @lichtblick/eslint-plugin from 1.x to 2.0.7 - Upgrade eslint from 8.x to 9.x - Remove standalone ESLint plugins now bundled in @lichtblick/eslint-plugin 2.x: eslint-plugin-es, eslint-plugin-filenames, eslint-plugin-import, eslint-plugin-jest, eslint-plugin-prettier, eslint-plugin-react, eslint-plugin-react-hooks, @typescript-eslint/eslint-plugin, @typescript-eslint/parser - Disable import/named for TypeScript files (false positives, same as Lichtblick) Security: resolves 3 high-severity minimatch ReDoS vulnerabilities (GHSA-2qfj-455h-2qmm, GHSA-952p-fqcp-g8pc, GHSA-3fvg-4v2m-98jf) that were rooted in the eslint@8 / @lichtblick/eslint-plugin@1.x dependency tree. Audit: 23 vulnerabilities (3 High) -> 19 vulnerabilities (0 High) Lint: 76 errors -> 73 errors (net improvement from autofix of newly detected issues) Resolves #180 * refactor: remove unnecessary type assertions Autofix from @typescript-eslint/no-unnecessary-type-assertion rule newly enabled by @lichtblick/eslint-plugin 2.x. Removes redundant `as Point3`, `as LinePrimitive`, `as GroundTruth` etc. casts and their now-unused imports. --------- Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
1 parent 7a2d192 commit b3f399c

13 files changed

Lines changed: 363 additions & 553 deletions

File tree

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.yaml

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

eslint.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import lichtblickPlugin from "@lichtblick/eslint-plugin";
2+
3+
export default [
4+
{
5+
ignores: ["dist/**", "*.js", "*.mjs", "website/**"],
6+
},
7+
8+
...lichtblickPlugin.configs.base,
9+
10+
...lichtblickPlugin.configs.typescript.map((config) => ({
11+
...config,
12+
files: ["**/*.ts", "**/*.tsx"],
13+
})),
14+
15+
{
16+
files: ["**/*.ts", "**/*.tsx"],
17+
languageOptions: {
18+
parserOptions: {
19+
projectService: false,
20+
project: "./tsconfig.json",
21+
tsconfigRootDir: import.meta.dirname,
22+
},
23+
},
24+
rules: {
25+
"linebreak-style": ["error", "unix"],
26+
// TypeScript validates named imports at compile time; the ESLint rule
27+
// produces false positives for packages with non-standard exports.
28+
"import/named": "off",
29+
},
30+
},
31+
32+
...lichtblickPlugin.configs.react,
33+
34+
...lichtblickPlugin.configs.jest.map((config) => ({
35+
...config,
36+
files: ["**/*.spec.ts", "**/*.test.ts", "tests/**/*.ts"],
37+
rules: {
38+
...config.rules,
39+
"@typescript-eslint/no-unsafe-assignment": "off",
40+
"@typescript-eslint/no-unsafe-return": "off",
41+
"@typescript-eslint/no-unsafe-member-access": "off",
42+
"@typescript-eslint/no-explicit-any": "off",
43+
},
44+
})),
45+
];

package.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,16 @@
3232
"@commitlint/config-conventional": "^19.6.0",
3333
"@foxglove/schemas": "^1.9.0",
3434
"@lichtblick/asam-osi-types": "^3.7.0",
35-
"@lichtblick/eslint-plugin": "^1.0.2",
35+
"@lichtblick/eslint-plugin": "^2.0.7",
3636
"@lichtblick/suite": "^1.25.0",
3737
"@types/jest": "^30.0.0",
3838
"@types/minimatch": "^5.1.2",
3939
"@types/react": "18.2.55",
4040
"@types/react-dom": "18.2.19",
41-
"@typescript-eslint/eslint-plugin": "^8.48.0",
42-
"@typescript-eslint/parser": "^8.48.0",
4341
"create-lichtblick-extension": "^1.0.0",
4442
"esbuild": "^0.25.0",
45-
"eslint": "^8.57.0",
43+
"eslint": "^9.38.0",
4644
"eslint-config-prettier": "9.1.0",
47-
"eslint-plugin-es": "4.1.0",
48-
"eslint-plugin-filenames": "1.3.2",
49-
"eslint-plugin-import": "2.31.0",
50-
"eslint-plugin-jest": "29.0.1",
51-
"eslint-plugin-prettier": "5.5.4",
52-
"eslint-plugin-react": "7.37.5",
53-
"eslint-plugin-react-hooks": "4.6.0",
5445
"husky": "^9.1.7",
5546
"jest": "^29.7.0",
5647
"jest-environment-jsdom": "^29.7.0",

src/features/lanes/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { TriangleListPrimitive, type Point3 } from "@foxglove/schemas";
2-
import { Time } from "@foxglove/schemas";
1+
import { TriangleListPrimitive, Time } from "@foxglove/schemas";
32
import { LaneBoundary, LaneBoundary_Classification_Type, Lane } from "@lichtblick/asam-osi-types";
43
import {
54
pointListToTriangleListPrimitive,
@@ -42,7 +41,7 @@ export function buildLaneBoundaryEntity(
4241
// Create LaneBoundaryPoint objects using only necessary fields for rendering
4342
const laneBoundaryPoints = osiLaneBoundary.boundary_line.map((point) => {
4443
return {
45-
position: { x: point.position.x, y: point.position.y, z: point.position.z } as Point3,
44+
position: { x: point.position.x, y: point.position.y, z: point.position.z },
4645
width: point.width === 0 ? LANE_BOUNDARY_MIN_RENDERING_WIDTH : point.width, // prevent zero-width lane boundaries from being invisible
4746
height: point.height,
4847
dash: point.dash,
@@ -83,7 +82,7 @@ export function buildLaneEntity(
8382
for (const lb of osiLeftLaneBoundaries) {
8483
const laneBoundaryPoints = lb.boundary_line.map((point) => {
8584
return {
86-
position: { x: point.position.x, y: point.position.y, z: point.position.z } as Point3,
85+
position: { x: point.position.x, y: point.position.y, z: point.position.z },
8786
width: point.width === 0 ? LANE_BOUNDARY_MIN_RENDERING_WIDTH : point.width, // prevent zero-width lane boundaries from being invisible
8887
height: point.height,
8988
dash: point.dash,
@@ -95,7 +94,7 @@ export function buildLaneEntity(
9594
for (const lb of osiRightLaneBoundaries) {
9695
const laneBoundaryPoints = lb.boundary_line.map((point) => {
9796
return {
98-
position: { x: point.position.x, y: point.position.y, z: point.position.z } as Point3,
97+
position: { x: point.position.x, y: point.position.y, z: point.position.z },
9998
width: point.width === 0 ? LANE_BOUNDARY_MIN_RENDERING_WIDTH : point.width, // prevent zero-width lane boundaries from being invisible
10099
height: point.height,
101100
dash: point.dash,
@@ -109,7 +108,7 @@ export function buildLaneEntity(
109108
if (LANE_CENTERLINE_SHOW) {
110109
const centerlinePoints = osiLane.classification.centerline.map((point) => {
111110
return {
112-
position: { x: point.x, y: point.y, z: point.z } as Point3,
111+
position: { x: point.x, y: point.y, z: point.z },
113112
width: LANE_CENTERLINE_WIDTH,
114113
height: 0,
115114
};

src/features/logicallanes/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { type Point3 } from "@foxglove/schemas";
21
import { Time } from "@foxglove/schemas";
32
import { LogicalLane, LogicalLaneBoundary } from "@lichtblick/asam-osi-types";
43
import {
@@ -33,7 +32,7 @@ export function buildLogicalLaneBoundaryEntity(
3332
x: point.position.x,
3433
y: point.position.y,
3534
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
36-
} as Point3,
35+
},
3736
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
3837
height: 0,
3938
};
@@ -74,7 +73,7 @@ export function buildLogicalLaneEntity(
7473
x: point.position.x,
7574
y: point.position.y,
7675
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
77-
} as Point3,
76+
},
7877
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
7978
height: 0, // no need to set height for logical lanes
8079
};
@@ -89,7 +88,7 @@ export function buildLogicalLaneEntity(
8988
x: point.position.x,
9089
y: point.position.y,
9190
z: point.position.z + LOGICAL_LANE_RENDERING_HEIGHT_OFFSET,
92-
} as Point3,
91+
},
9392
width: LOGICAL_LANE_BOUNDARY_RENDERING_WIDTH,
9493
height: 0, // no need to set height for logical lanes
9594
};

src/features/referenceline/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Point3, Time } from "@foxglove/schemas";
1+
import { Time } from "@foxglove/schemas";
22
import { ReferenceLine } from "@lichtblick/asam-osi-types";
33
import { MarkerPoint, pointListToTriangleListPrimitive } from "@utils/index";
44
import { PartialSceneEntity, generateSceneEntityId } from "@utils/scene";
@@ -19,7 +19,7 @@ export function buildReferenceLineEntity(
1919
x: p.world_position.x,
2020
y: p.world_position.y,
2121
z: p.world_position.z,
22-
} as Point3,
22+
},
2323
width: REFERENCE_LINE_VISUALIZATION_WIDTH,
2424
height: 0.0,
2525
}));

src/utils/primitives/lines.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,5 +611,5 @@ export function pointListToDashedLinePrimitive(
611611
color: { r: 0, g: 0, b: 0, a: 0 },
612612
colors: new_colors,
613613
indices: [],
614-
} as LinePrimitive;
614+
};
615615
}

tests/converters.registration.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
MovingObject,
99
MovingObject_Type,
1010
MovingObject_VehicleClassification_Type,
11-
ReferenceLine,
1211
ReferenceLine_Type,
1312
StationaryObject,
1413
} from "@lichtblick/asam-osi-types";
@@ -186,7 +185,7 @@ describe("OSI Visualizer: Message Converter", () => {
186185
t_axis_yaw: 0,
187186
},
188187
],
189-
} as unknown as DeepRequired<ReferenceLine>;
188+
};
190189
const mockMessageData = {
191190
timestamp: {
192191
seconds: 0,

tests/emitAlert.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function minimalGroundTruth(overrides?: Partial<GroundTruth>): GroundTruth {
4141
},
4242
],
4343
...overrides,
44-
} as GroundTruth;
44+
};
4545
}
4646

4747
describe("emitAlert — GroundTruth FrameTransforms", () => {
@@ -104,7 +104,7 @@ describe("emitAlert — GroundTruth FrameTransforms", () => {
104104
vehicle_attributes: {},
105105
},
106106
],
107-
} as Partial<GroundTruth>);
107+
});
108108

109109
convertGroundTruthToFrameTransforms(msg, undefined, undefined, context);
110110

@@ -147,7 +147,7 @@ describe("emitAlert — SensorView SceneUpdate", () => {
147147
const { context, emitAlert } = mockContext();
148148
const converter = registerSensorViewConverter();
149149

150-
converter({} as SensorView, dummyEvent, undefined, context);
150+
converter({}, dummyEvent, undefined, context);
151151

152152
expect(emitAlert).toHaveBeenCalledWith(
153153
expect.objectContaining({ severity: "warn" }),
@@ -159,7 +159,7 @@ describe("emitAlert — SensorView SceneUpdate", () => {
159159
const { context } = mockContext();
160160
const converter = registerSensorViewConverter();
161161

162-
const result = converter({} as SensorView, dummyEvent, undefined, context) as {
162+
const result = converter({}, dummyEvent, undefined, context) as {
163163
deletions: unknown[];
164164
entities: unknown[];
165165
};

0 commit comments

Comments
 (0)