Skip to content

Commit e9458e7

Browse files
committed
[INTERNAL] ESLint: Enforce max line length
1 parent e6546cb commit e9458e7

31 files changed

+272
-127
lines changed

.eslintrc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ module.exports = {
3131
"no-negated-condition": "off",
3232
"require-jsdoc": "off",
3333
"no-mixed-requires": "off",
34-
"max-len": ["warn", 120],
34+
"max-len": [
35+
"error",
36+
{
37+
"code": 120,
38+
"ignoreUrls": true,
39+
"ignoreRegExpLiterals": true
40+
}
41+
],
3542
"no-implicit-coercion": [
3643
2,
3744
{"allow": ["!!"]}

lib/builder/builder.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function getElapsedTime(startTime) {
3838
* @private
3939
* @param {object} parameters
4040
* @param {boolean} parameters.dev Sets development mode, which only runs essential tasks
41-
* @param {boolean} parameters.selfContained True if a the build should be self-contained or false for prelead build bundles
41+
* @param {boolean} parameters.selfContained
42+
* True if a the build should be self-contained or false for prelead build bundles
4243
* @param {boolean} parameters.jsdoc True if a JSDoc build should be executed
4344
* @param {Array} parameters.includedTasks Task list to be included from build
4445
* @param {Array} parameters.excludedTasks Task list to be excluded from build
@@ -207,9 +208,13 @@ module.exports = {
207208
* @param {string} parameters.destPath Target path
208209
* @param {boolean} [parameters.cleanDest=false] Decides whether project should clean the target path before build
209210
* @param {boolean} [parameters.buildDependencies=false] Decides whether project dependencies are built as well
210-
* @param {Array.<string|RegExp>} [parameters.includedDependencies=[]] List of build dependencies to be included if buildDependencies is true
211-
* @param {Array.<string|RegExp>} [parameters.excludedDependencies=[]] List of build dependencies to be excluded if buildDependencies is true. If the wildcard '*' is provided, only the included dependencies will be built.
212-
* @param {boolean} [parameters.dev=false] Decides whether a development build should be activated (skips non-essential and time-intensive tasks)
211+
* @param {Array.<string|RegExp>} [parameters.includedDependencies=[]]
212+
* List of build dependencies to be included if buildDependencies is true
213+
* @param {Array.<string|RegExp>} [parameters.excludedDependencies=[]]
214+
* List of build dependencies to be excluded if buildDependencies is true.
215+
* If the wildcard '*' is provided, only the included dependencies will be built.
216+
* @param {boolean} [parameters.dev=false]
217+
* Decides whether a development build should be activated (skips non-essential and time-intensive tasks)
213218
* @param {boolean} [parameters.selfContained=false] Flag to activate self contained build
214219
* @param {boolean} [parameters.jsdoc=false] Flag to activate JSDoc build
215220
* @param {Array.<string>} [parameters.includedTasks=[]] List of tasks to be included
@@ -367,7 +372,8 @@ module.exports = {
367372
resource.getPath());
368373
return; // Skip target write for this resource
369374
}
370-
if (projectContext.isRootProject() && project.type === "application" && project.metadata.namespace) {
375+
if (projectContext.isRootProject() && project.type === "application" &&
376+
project.metadata.namespace) {
371377
// Root-application projects only: Remove namespace prefix if given
372378
resource.setPath(resource.getPath().replace(
373379
new RegExp(`^/resources/${project.metadata.namespace}`), ""));

lib/lbt/analyzer/JSModuleAnalyzer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ class JSModuleAnalyzer {
554554
} else {
555555
nUnnamedDefines++;
556556
if ( nUnnamedDefines > 1 ) {
557-
throw new Error("if multiple modules are contained in a file, only one of them may omit the module ID " + name + " " + nUnnamedDefines);
557+
throw new Error(
558+
"if multiple modules are contained in a file, only one of them may omit the module ID " +
559+
name + " " + nUnnamedDefines);
558560
}
559561
if ( defaultName == null ) {
560562
throw new Error("unnamed module found, but no default name given");

lib/lbt/bundle/Resolver.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class BundleResolver {
3333
/**
3434
* @param {ModuleDefinition} bundle Bundle definition to resolve
3535
* @param {object} [options] Options
36-
* @param {string[]} [options.defaultFileTypes] List of default file types to which a prefix pattern shall be expanded.
36+
* @param {string[]} [options.defaultFileTypes]
37+
List of default file types to which a prefix pattern shall be expanded.
3738
* @returns {Promise<ResolvedBundleDefinition>}
3839
*/
3940
resolve(bundle, options) {
@@ -51,7 +52,8 @@ class BundleResolver {
5152
let prevLength;
5253
let newKeys;
5354

54-
const filters = new ResourceFilterList( section.filters, fileTypes ); // resolvePlaceholders(section.getFilters());
55+
// NODE-TODO resolvePlaceholders(section.getFilters());
56+
const filters = new ResourceFilterList( section.filters, fileTypes );
5557

5658
function isAccepted(resourceName, required) {
5759
let match = required;

lib/lbt/resources/ResourceCollector.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class ResourceCollector {
100100
// Note: ignores .theme files in library folders
101101

102102
// .theming files are not always present therefore this check is relevant for the library.source.less
103-
if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library\\.source\\.less)") && !this._themePackages.has(prefix) ) {
103+
if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library\\.source\\.less)") &&
104+
!this._themePackages.has(prefix) ) {
104105
// log.info("found new theme package %s", prefix);
105106
this._themePackages.set(prefix, new ResourceInfoList(prefix));
106107
}
@@ -230,7 +231,8 @@ class ResourceCollector {
230231

231232
createOrphanFilters() {
232233
log.verbose(
233-
` configured external resources filters (resources outside the namespace): ${this._externalResources == null ? "(none)" : this._externalResources}`);
234+
` configured external resources filters (resources outside the namespace): ` +
235+
`${this._externalResources == null ? "(none)" : this._externalResources}`);
234236

235237
const filtersByComponent = new Map();
236238

@@ -260,7 +262,8 @@ class ResourceCollector {
260262
list.add(resource, !isDebugBundle);
261263
contained = true;
262264
} else if ( orphanFilters.has(prefix) ) {
263-
// log.verbose(` checking '${resource.name}' against orphan filter '${orphanFilters.get(prefix)}' (${prefix})`);
265+
// log.verbose(` checking '${resource.name}' against orphan filter ` +
266+
// `'${orphanFilters.get(prefix)}' (${prefix})`);
264267
if ( orphanFilters.get(prefix).matches(resource.name) ) {
265268
list.add(resource, !isDebugBundle);
266269
contained = true;

lib/processors/bundlers/flexChangesBundler.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const resourceFactory = require("@ui5/fs").resourceFactory;
1010
* @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed
1111
* @param {object} parameters.options Options
1212
* @param {string} parameters.options.pathPrefix Prefix for bundle path
13-
* @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.73 than create flexibility-bundle.json
13+
* @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.73 than
14+
* create flexibility-bundle.json
1415
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with flex changes bundle resources
1516
*/
1617
module.exports = function({resources, options: {pathPrefix, hasFlexBundleVersion}}) {
@@ -38,7 +39,8 @@ module.exports = function({resources, options: {pathPrefix, hasFlexBundleVersion
3839
changesContent.forEach(function(content) {
3940
switch (content.fileType) {
4041
case "change":
41-
if (content.appDescriptorChange && (content.appDescriptorChange === "true" || content.appDescriptorChange == true)) {
42+
if (content.appDescriptorChange && (content.appDescriptorChange === "true" ||
43+
content.appDescriptorChange == true)) {
4244
break;
4345
}
4446
if (content.variantReference && content.variantReference !== "") {
@@ -62,8 +64,11 @@ module.exports = function({resources, options: {pathPrefix, hasFlexBundleVersion
6264
}
6365
});
6466

65-
if (!hasFlexBundleVersion && (compVariants.length != 0 || variants.length != 0 || variantChanges.length != 0 || variantDependentControlChanges.length != 0 || variantManagementChanges.length != 0)) {
66-
throw new Error("There are some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher");
67+
if (!hasFlexBundleVersion && (compVariants.length != 0 || variants.length != 0 || variantChanges.length != 0 ||
68+
variantDependentControlChanges.length != 0 || variantManagementChanges.length != 0)) {
69+
throw new Error(
70+
"There are some control variant changes in the changes folder. This only works with a " +
71+
"minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher");
6772
}
6873
// create changes-bundle.json
6974
if (!hasFlexBundleVersion) {

lib/processors/bundlers/moduleBundler.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,40 @@ const EvoResource = require("@ui5/fs").Resource;
1010
* <b>Module bundle section modes</b><br>
1111
* <ul>
1212
* <li>
13-
* <code>provided</code>: A section of mode 'provided' defines a set of modules that should not be included in the bundle file itself, but
14-
which should be assumed to be already loaded (or 'provided') by the environment into which the bundle module is loaded.
13+
* <code>provided</code>: A section of mode 'provided' defines a set of modules that should not be included in
14+
* the bundle file itself, but which should be assumed to be already loaded (or 'provided') by the environment into
15+
* which the bundle module is loaded.
1516
* </li>
1617
* <li>
17-
<code>raw</code>: A raw section determines the set of modules that should be embedded,
18-
sorts them according to their dependencies and writes them out 1:1 without any transformation or wrapping (raw). Only JavaScript sources
19-
can be embedded in a raw section.
20-
</li>
18+
* <code>raw</code>: A raw section determines the set of modules that should be embedded, sorts them according
19+
* to their dependencies and writes them out 1:1 without any transformation or wrapping (raw). Only JavaScript
20+
* sources can be embedded in a raw section.
21+
* </li>
2122
* <li>
22-
<code>preload</code>: A preload section packages resources that should be stored in the preload cache in the client.
23-
They can embed any textual resource type (JavaScript, XML, JSON and .properties files) that the bundling supports.
24-
UI5 modules are wrapped into a 'sap.ui.predefine' call. Other JavaScript modules will be embedded into a 'jQuery.sap.registerPreload' call, unless the
25-
asynchronous ui5loader is used. With the ui5loader 'sap.ui.require.preload' is used for other modules.
26-
</li>
23+
* <code>preload</code>: A preload section packages resources that should be stored in the preload cache in the
24+
* client. They can embed any textual resource type (JavaScript, XML, JSON and .properties files) that the
25+
* bundling supports. UI5 modules are wrapped into a 'sap.ui.predefine' call. Other JavaScript modules will be
26+
* embedded into a 'jQuery.sap.registerPreload' call, unless the asynchronous ui5loader is used. With the
27+
* ui5loader 'sap.ui.require.preload' is used for other modules.
28+
* </li>
2729
* <li>
28-
<code>require</code>: A 'require' section is transformed into a sequence of jQuery.sap.require calls. The list will be resolved like an include pattern list
29-
in any of the other sections and for each of the resolved modules, a jQuery.sap.require will be created. In case the ui5loader is available, 'sap.ui.requireSync' is used instead.
30-
</li>
30+
* <code>require</code>: A 'require' section is transformed into a sequence of jQuery.sap.require calls. The
31+
* list will be resolved like an include pattern list in any of the other sections and for each of the resolved
32+
* modules, a jQuery.sap.require will be created. In case the ui5loader is available, 'sap.ui.requireSync' is
33+
* used instead.
34+
* </li>
3135
* </ul>
3236
* </p>
3337
*
3438
* @public
3539
* @typedef {object} ModuleBundleDefinitionSection
3640
* @property {string} mode The embedding mode. Either 'provided', 'raw', 'preload' or 'require'
37-
* @property {string[]} filters List of modules declared as glob patterns (resource name patterns) that should be in- or excluded.
38-
* A pattern either contains of a trailing slash '/' or single '*' and double '**' asterisks which denote an arbitrary number of characters or folder names.
39-
* Exludes should be marked with a leading exclamation mark '!'. The order of filters is relevant, a later exclusion overrides an earlier inclusion and vice versa.
41+
* @property {string[]} filters List of modules declared as glob patterns (resource name patterns) that should be
42+
* in- or excluded.
43+
* A pattern either contains of a trailing slash '/' or single '*' and double '**' asterisks which denote an
44+
* arbitrary number of characters or folder names.
45+
* Exludes should be marked with a leading exclamation mark '!'. The order of filters is relevant, a later
46+
* exclusion overrides an earlier inclusion and vice versa.
4047
* @example <caption>List of modules as glob patterns that should be in- or excluded</caption>
4148
* // Includes everything from "some/path/to/module/",
4249
* // but excludes the subfolder "some/path/to/module/to/be/excluded/"
@@ -47,12 +54,13 @@ const EvoResource = require("@ui5/fs").Resource;
4754
* ]
4855
* };
4956
*
50-
* @property {boolean} [resolve=false] Whether (transitive) dependencies of modules that match the given filters should be resolved
51-
* and added to the module set
57+
* @property {boolean} [resolve=false] Whether (transitive) dependencies of modules that match the given filters
58+
* should be resolved and added to the module set
5259
* @property {boolean} [resolveConditional=false] Whether conditional dependencies of modules should be resolved
5360
* and added to the module set for this section
5461
* @property {boolean} [renderer=false] Whether renderers for controls should be added to the module set
55-
* @property {boolean} [declareRawModules=false] Whether raw modules should be declared after jQuery.sap.global became available. With the usage of the ui5loader, this flag should be set to 'false'
62+
* @property {boolean} [declareRawModules=false] Whether raw modules should be declared after jQuery.sap.global
63+
* became available. With the usage of the ui5loader, this flag should be set to 'false'
5664
* @property {boolean} [sort=true] Whether the modules should be sorted by their dependencies
5765
*/
5866

@@ -79,7 +87,8 @@ const EvoResource = require("@ui5/fs").Resource;
7987
* a try/catch to filter out "Restart" errors
8088
* @property {boolean} [usePredefineCalls=false] If set to 'true', sap.ui.predefine is used for UI5 modules
8189
* @property {number} [numberOfParts=1] The number of parts the module bundle should be splitted
82-
* @property {boolean} [ignoreMissingModules=false] When searching for modules which are optional for further processing, do not throw in case they are missing
90+
* @property {boolean} [ignoreMissingModules=false] When searching for modules which are optional for further
91+
* processing, do not throw in case they are missing
8392
*/
8493

8594
/**

lib/processors/manifestCreator.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,11 @@ module.exports = function({libraryResource, resources, options}) {
571571
return Promise.resolve(null); // a fulfillment of null indicates that no manifest has been created
572572
}
573573

574-
return createManifest(libraryResource, libBundle, options.descriptorVersion, options.include3rdParty).then((manifest) => {
575-
return new EvoResource({
576-
path: resourcePathPrefix + "manifest.json",
577-
string: JSON.stringify(manifest, null, options.prettyPrint ? " " : undefined)
574+
return createManifest(libraryResource, libBundle, options.descriptorVersion, options.include3rdParty)
575+
.then((manifest) => {
576+
return new EvoResource({
577+
path: resourcePathPrefix + "manifest.json",
578+
string: JSON.stringify(manifest, null, options.prettyPrint ? " " : undefined)
579+
});
578580
});
579-
});
580581
};

lib/processors/nonAsciiEscaper.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ const encodingMap = {
9090

9191
/**
9292
* Provides a mapping from user-friendly encoding name (alias) such as "UTF-8" and "ISO-8859-1" to node
93-
* specific encoding name such as "utf8" or "latin1". Simplifies usage of nonAsciiEscaper encoding
94-
* option such that it can be used standalone without the respective task (e.g. in Splitter, Bundler and related projects).
93+
* specific encoding name such as "utf8" or "latin1". Simplifies usage of nonAsciiEscaper encoding option
94+
* such that it can be used standalone without the respective task (e.g. in Splitter, Bundler and related projects).
9595
*
9696
* @public
9797
* @alias module:@ui5/builder.processors.nonAsciiEscaper․getEncodingFromAlias
@@ -100,7 +100,8 @@ const encodingMap = {
100100
*/
101101
nonAsciiEscaper.getEncodingFromAlias = function(encoding) {
102102
if (!encodingMap[encoding]) {
103-
throw new Error(`Encoding "${encoding}" is not supported. Only ${Object.keys(encodingMap).join(", ")} are allowed values` );
103+
throw new Error(
104+
`Encoding "${encoding}" is not supported. Only ${Object.keys(encodingMap).join(", ")} are allowed values` );
104105
}
105106
return encodingMap[encoding];
106107
};

lib/processors/resourceListCreator.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function makeResourcesJSON(list, prefix) {
107107
// Adjust size until it is correct
108108
// This entry's size depends on the file size which depends on this entry's size,...
109109
// Updating the number of the size in the content might influence the size of the file itself
110-
// This is deterministic because e.g. in the content -> <code>"size": 1000</code> has the same amount of bytes as <code>"size": 9999</code>
111-
// the difference might only come for:
110+
// This is deterministic because e.g. in the content -> <code>"size": 1000</code> has the same
111+
// amount of bytes as <code>"size": 9999</code> the difference might only come for:
112112
// * adding the initial entry of resources.json
113113
// * changes when the number of digits of the number changes, e.g. 100 -> 1000
114114
while (resourcesJson.size !== newLength) {
@@ -193,7 +193,9 @@ module.exports = async function({resources, options}) {
193193
const unassigned = collector.resources;
194194
if ( unassigned.size > 0 && options.failOnOrphans ) {
195195
log.error(`resources.json generation failed because of unassigned resources: ${[...unassigned].join(", ")}`);
196-
throw new Error(`resources.json generation failed with error: There are ${unassigned.size} resources which could not be assigned to components.`);
196+
throw new Error(
197+
`resources.json generation failed with error: There are ${unassigned.size} ` +
198+
`resources which could not be assigned to components.`);
197199
}
198200

199201
return resourceLists;

0 commit comments

Comments
 (0)