VSCode Warning/Error: ‘foo’ is assigned a value but never used in JavaScript project [duplicate]

I have a small snippet on a JavaScript using Visual Studio Code, and I’ve encountered a warning/error that I find puzzling. In my project, I have three files: index.php, utils.js, and index.js.

Here’s the structure of my files:

index.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS Test</title>
</head>
<body>
    JS Test
    <script type="text/javascript" src="./utils.js"></script>
    <script type="text/javascript" src="./index.js"></script>
</body>
</html>

utils.js

console.log("utils.js");

const foo = () => {
    console.log('foo');
}

index.js

console.log("index.js");

foo();

In Visual Studio Code, I’m receiving a warning or error indicating that ‘foo’ is assigned a value but never used. However, I am indeed using foo in the index.js file. Despite this, the warning persists.

I’m seeking clarification on why this warning is appearing and if there’s a way to resolve it. I believe I am correctly using the foo function, but the IDE seems to think otherwise. Any insights or guidance on resolving this issue would be greatly appreciated.

This is a small snippet of what I’m trying to do in my actual project. Also I apologize for if any mistake I made in this post.

I tried making this snippet for same case but it didn’t work.

EDIT: I’m trying to use jslint/eslint on my project. I don’t know if it is possible with vanilla js or not.