Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui5lint fails with "Unable to find a UI5 Project" #43

Closed
rpbouman opened this issue Mar 21, 2024 · 4 comments
Closed

ui5lint fails with "Unable to find a UI5 Project" #43

rpbouman opened this issue Mar 21, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@rpbouman
Copy link

Expected Behavior

I ran ui5lint and expected a code quality report.

Current Behavior

Running ui5lint failed with the following error: "Unable to find a UI5 Project"

$ ui5lint --verbose
verb cli:middlewares:base using ui5lint version 0.1.3 (from C:\Users\Roland_Bouman\AppData\Roaming\npm\node_modules\@ui5\linter\bin\ui5lint.js)
verb cli:middlewares:base using node version v20.11.1

⚠️  Process Failed With Error

Error Message:
Unable to find a UI5 project at C:\roland\projects\s4explorer\zsavis-launchpad\web\zsavis.
Please make sure to run "ui5lint" in the root directory of your UI5 project.

Stack Trace:
Error: Unable to find a UI5 project at C:\roland\projects\s4explorer\zsavis-launchpad\web\zsavis.
Please make sure to run "ui5lint" in the root directory of your UI5 project.
    at getProjectGraph (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/linter/linter.js:61:15)
    at async lintProject (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/linter/linter.js:79:19)
    at async Object.handleLint [as handler] (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/cli/base.js:95:17)

If you think this is an issue of the ui5-linter, you might report it using the following URL: https://github.com/SAP/ui5-linter/issues/new/choose

Steps to Reproduce the Issue

See above

Context

  • UI5 linter package and version: 0.1.3
  • Node.js Version: v20.11.1
  • npm 9.6.4
  • OS/Platform: Microsoft Windows 10 Enterprise
  • Browser (if relevant): NA
  • Other information regarding your environment (optional): This is wat my project dir looks like:

image

Log Output / Stack Trace

Error: Unable to find a UI5 project at C:\roland\projects\s4explorer\zsavis-launchpad\web\zsavis.
Please make sure to run "ui5lint" in the root directory of your UI5 project.
    at getProjectGraph (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/linter/linter.js:61:15)
    at async lintProject (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/linter/linter.js:79:19)
    at async Object.handleLint [as handler] (file:///C:/Users/Roland_Bouman/AppData/Roaming/npm/node_modules/@ui5/linter/lib/cli/base.js:95:17)
@rpbouman rpbouman added the bug Something isn't working label Mar 21, 2024
@RandomByte
Copy link
Member

Other than tools like ESLint, UI5 linter tries to get an understanding of your project's structure in order to resolve dependencies between modules. For that it takes a guess based on the directory structure. For example it expects a top-level directory "webapp" for applications or a "src" directory for libraries.

It looks like in your case it fails to find either. Actually your project structure seems to be quite different from today's recommendations, so I'm not sure UI5 linter would ever be able to infer the correct runtime paths.

You could create a UI5 Tooling ui5.yaml file in the directory that contains "zsavis", configure it as an application, and set the path mapping to webapp: zsavis. UI5 linter will search for a ui5.yaml in the CWD and use it for resolving the paths.

However, you might end up scanning node_modules too until we have a mechanism in UI5 linter for excluding files.

@RandomByte RandomByte added enhancement New feature or request and removed bug Something isn't working labels Mar 22, 2024
@rpbouman
Copy link
Author

Hi @RandomByte ,

thanks for the quick reply, and thanks for thinking along! I added the ui5.yaml file and I can now get it to work. But, like you mentioned, it also scans the node_modules directory.

It certainly would be great if it would be possible to exclude certain dirs. Perhaps it would be possible to create a new command line parameter for that?

In fact, since I'm only using the ui5.yaml file to tell the linter what dir to use, would it not also be possible to get a command line parameter to tell the linter what directory to scan? It would make the linter much more widely applicable.

The argument that the directory structure does not conform to recommendations is not so strong in my opinion, since recommendations change over the years, plus, recommendations are just that - recommendations.

@RandomByte
Copy link
Member

A functionality to exclude paths is already planned.

For this initial release, we focused on projects that already use UI5 Tooling. Since those projects will always have a ui5.yaml, UI5 linter can re-use this configuration and offer an experience where no further configuration is necessary. As a fallback, we take an educated guesses based on the project's directory structure as described in my last comment.

Without an understanding of the project's structure, we can't derive the runtime paths of each resource and might not be able to analyze all dependencies within the resources properly. We'll have to investigate the actual impact for project's like yours though.

In any case I would recommend that your project starts using UI5 Tooling to be able to build an optimized version for deployment.

@rpbouman
Copy link
Author

A functionality to exclude paths is already #21.

Cool, thanks!

Without an understanding of the project's structure, we can't derive the runtime paths of each resource and might not be able to analyze all dependencies within the resources properly.

I get your point but there was a time when the recommendation was to stuff everything in resourceroots in the ui5 bootstrap script tag. I'm just saying, recommendations change, not all projects can keep up with whatever recommendations happen to be in fashion now, while it certainly is useful to lint regardless.

In any case I would recommend that your project starts using UI5 Tooling to be able to build an optimized version for deployment.

Let's not bicker about it. You built a cool tool and I love to use it. I'm just giving feedback from my pov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants