12. Linters
To catch potential errors in code early, it is highly recommended to use a linter.
The most convenient option is ui5plugin-linter. It is included in all modern SAP UI5 project templates and integrated with the SAP Fiori Tools - Extension Pack in VSCode, highlighting errors in real time.
How to use:
- If you have VSCode with the SAP Fiori Tools - Extension Pack plugins installed, everything already works — just add a config file to the project root (name it .ui5pluginrc.json).
- If you want to use it via CLI:
- Install the linter
(npm install ui5plugin-linter -g) - Place the configuration file (see below) in the project root, named .ui5pluginrc.json
- Run ui5linter in the project directory from the console
- Install the linter
Recommended configuration:
.ui5pluginrc.json
{
"ui5": {
"ui5parser": {
"excludeFolderPatterns": ["**/resources/**", "**/dist/**", "**/node_modules/**", "**/test/**", "**/test-resources/**"]
},
"ui5linter": {
"severity": {
"WrongParametersLinter": "Error",
"WrongOverrideLinter": "Error",
"WrongImportLinter": "Warning",
"WrongFilePathLinter": "Warning",
"WrongFieldMethodLinter": "Warning",
"WrongClassNameLinter": "Warning",
"UnusedTranslationsLinter": "Information",
"UnusedNamespaceLinter": "Warning",
"UnusedMemberLinter": "Information",
"TagLinter": "Information",
"TagAttributeLinter": "Information",
"TagAttributeDefaultValueLinter": "Information",
"PublicMemberLinter": "Information",
"InterfaceLinter": "Error",
"AbstractClassLinter": "Error",
"UnusedClassLinter": "Error",
"WrongNamespaceLinter": "Warning",
"DuplicateTranslationLinter": "Error",
"EventTypeLinter": "Error"
},
"usage": {
"WrongParametersLinter": true,
"WrongOverrideLinter": true,
"WrongImportLinter": true,
"WrongFilePathLinter": true,
"WrongFieldMethodLinter": true,
"WrongClassNameLinter": true,
"UnusedTranslationsLinter": true,
"UnusedNamespaceLinter": true,
"UnusedMemberLinter": true,
"TagLinter": true,
"TagAttributeLinter": true,
"TagAttributeDefaultValueLinter": true,
"PublicMemberLinter": true,
"InterfaceLinter": true,
"AbstractClassLinter": true,
"UnusedClassLinter": true,
"WrongNamespaceLinter": true,
"DuplicateTranslationLinter": true,
"EventTypeLinter": true
},
"idNamingPattern": "",
"eventNamingPattern": ""
}
}
}