Skip to content

Library development best practices: detect missing noLibraryCSS: true in themeless libs #1084

Description

@boghyon

The noLibraryCSS flag passed to sap/ui/core/Lib.init or the deprecated sap/ui/core/Core#initLibrary tells the framework whether the library ships any theming resources. When it is not set to true, the framework requests library(-RTL).css at runtime for every registered library.

For custom libraries that never ship a library.css or library-RTL.css, this results in an unnecessary HTTP request that returns 404.

<lib namespace>/themes/<theme name>/library(-RTL).css --> 404 on themeless libs

I have seen several custom UI5 libraries where noLibraryCSS: true was simply forgotten, leading to those 404 requests.

Since the linter already inspects specific properties of the Lib.init config object (e.g. #33), the detection could be extended to also check noLibraryCSS, and warn if it is not set to true when the library doesn't provide/use theming.

Since the fix is a single property insertion into the LibraryInfo object literal, it could be also autofixed easily if applicable.

Edge case: some libraries might ship a *.less filee that is effectively empty (e.g. imports only the base theming). In my view, such libraries should count also as "theming-less".

Metadata

Metadata

Assignees

Labels

autofixAn issue related to the autofix capabilitiesdetectionAn issue related to detection capabilities

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions