I have three files in my project.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<script src="./a.js"></script>
<script src="./b.js"></script>
</body>
</html>
a.js
function test() {
console.log("test");
}
b.js
test();
test2();
I would like to run ESLint to look for errors. If I run npx eslint .\**\index.html
I don't get any errors because it doesn't scan the code included by the src tag. If I run npx eslint .\**\*
I get the following errors even though the test function is actually defined and used.
C:\Git\work\New folder\a.js
1:10 error 'test' is defined but never used no-unused-vars
C:\Git\work\New folder\b.js
1:1 error 'test' is not defined no-undef
2:1 error 'test2' is not defined no-undef
✖ 3 problems (3 errors, 0 warnings)
I have eslint-plugin-html installed and included in my eslint.config.mjs file. How can I configure it to scan the code from the src tags. Ideally I would run npx eslint .\**\index.html
and get an error report that tells me test2 is not defined.
This is a test project for a much larger legacy project so rewriting the code to use modern imports or modules is not an option.