-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Component best practices- async flags check #73
Conversation
f14afdd
to
ea65aa3
Compare
test/fixtures/linter/rules/BestPractices/Negative_1/Component.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see test cases for the other common base component classes in UI5:
- sap/ui/generic/app/AppComponent
- sap/suite/ui/generic/template/lib/AppComponent
- sap/fe/core/AppComponent
These are all extending the
|
66c09e8
to
d60a47e
Compare
This change updates `@sapui5/types` to 1.120.13 which is vital for #73
Snapshots reflect unexpected behavior. Negative tests should have no findings while positive tests should show findings.
…string extraction
…terface flag Since the async interface is either used or not, the information whether it is "not set" is redundant and the "parent property not set" information is not applicable.
Use enum value for implicit searching
Document test fixtures
src/linter/linter.ts
Outdated
if (pathsToLint?.length) { | ||
const absoluteFilePaths = resolveFilePaths(rootDir, pathsToLint); | ||
resolvedFilePaths = transformFilePathsToVirtualPaths( | ||
absoluteFilePaths, rootDir, "/", rootDir); | ||
// Extract the (virtual) path from the filename | ||
virBasePath = resolvedFilePaths[0].split("/").slice(0, -1).join("/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason for adae2ac ?
I'm wondering whether this approach still works if the first path in the array is deeply nested. For example /resources/my/app/controller/MyController.js
would lead to virtual base path /resources/my/app/controller/
. Which does not match for other paths like /resources/my/app/view/MyView.view.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for that change and the related ones is that for the test cases it used to read files one by one and didn't have the context for the parent components, for example.
The problem lies in the fact that without a /resource
prefix, the files were not found. To be honest, I'm not sure for the core reason behnid this behaviour, but I guess it might be something with the Reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, you're right about the deeply nested components 🤔
But, how to extract the namespace without breaking the signature of the function?
Maybe, reuse the logic from lintProject()
, but then we need a project, not a single file...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted the commit and all tests are still green 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it’s not just that change 😅
I have tried several things to provide a better handling of those resources.
Maybe, directly comparing/reseting the file with the main branch would be easier 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, not sure I understand the implications...
I just pushed the revert which restores the behavior I think is better (and should work for deep paths). Let's discuss it based on that 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look here: src/linter/linter.ts
This is the original change compared to the main branch.
The change is working pretty well, except that it cannot handle /test-resources/
and that's why I needed to find a better way of doing it.
Please take a look at the conversation we had with @flovogt on that matter here: https://github.com/SAP/ui5-linter/pull/73/files#r1601613818
But, if we take a look at the implementation of the lintProject()
method, it again relies only on the /resources
path, ignoring the /test-resources
.
If this is ok, then we can leave it as it is now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks. Since the lintFile
API is currently only used in our tests, I think we can safely go with the current state and ignore the test-resources case for now 👍
108c6a2
to
f136e64
Compare
I'm fine with this PR and once #73 (comment) is clarified we can merge it. As a follow-up I would like us to extract the texts similar to https://github.com/SAP/ui5-linter/pull/112/files#diff-9d3ca30e9cd9e1355253f085c67fd2abafe4dfff649602cacf8b3ddef81db990 and hand them over to UA for review. |
This reverts commit adae2ac.
8e42467
to
f136e64
Compare
GitHub requires an additional review from someone other than me 😅 @flovogt |
JIRA: CPOUI5FOUNDATION-792