Skip to content

Commit f4d8111

Browse files
committed
[INTERNAL] lib/processors/jsdoc: prefer strict comparison over type coercion
Cherry-picked from UI5/openui5@e38626c0a.
1 parent ed75ed4 commit f4d8111

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/processors/jsdoc/lib/ui5/plugin.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
* newDoclet
5050
*
5151
* parseComplete
52-
* remove undocumented/ignored/private doclets or duplicate doclets
52+
* merge collected class info, DataType info and enum values into doclets
5353
*
54+
* processingComplete
55+
* remove undocumented/ignored/private doclets or duplicate doclets
5456
*
5557
* Last but not least, it implements an astNodeVisitor to detect UI5 specific "extend" calls and to create
5658
* documentation for the properties, aggregations etc. that are created with the "extend" call.
@@ -232,7 +234,7 @@ function resolveModuleName(base, name) {
232234
let stack = base.split('/');
233235
stack.pop();
234236
name.split('/').forEach((segment, i) => {
235-
if ( segment == '..' ) {
237+
if ( segment === '..' ) {
236238
stack.pop();
237239
} else if ( segment === '.' ) {
238240
// ignore
@@ -456,14 +458,14 @@ function createPropertyMap(node, defaultKey) {
456458
return result;
457459
}
458460

459-
if ( node.type != Syntax.ObjectExpression ) {
461+
if ( node.type !== Syntax.ObjectExpression ) {
460462
// something went wrong, it's not an object literal
461463
warning(`not an object literal: ${node.type}: ${node.value}`);
462464
// console.log(node.toSource());
463465
return undefined;
464466
}
465467

466-
// invariant: node.type == Syntax.ObjectExpression
468+
// invariant: node.type === Syntax.ObjectExpression
467469
result = {};
468470
for (let i = 0; i < node.properties.length; i++) {
469471
const prop = node.properties[i];
@@ -1170,7 +1172,7 @@ function collectVisibilityInfo(settings, doclet, className, n) {
11701172
access = "restricted";
11711173
}
11721174

1173-
if (visibility == "public" && (access === "restricted" || access === "protected")) {
1175+
if (visibility === "public" && (access === "restricted" || access === "protected")) {
11741176
visibility = access;
11751177
}
11761178
}
@@ -1869,7 +1871,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
18691871
lines.push("<li>Properties");
18701872
lines.push("<ul>");
18711873
for (let n in oClassInfo.properties) {
1872-
lines.push("<li>{@link " + rname("get", n) + " " + n + "} : " + oClassInfo.properties[n].type + (oClassInfo.properties[n].defaultValue !== null && oClassInfo.properties[n].defaultValue.value !== null ? " (default: " + oClassInfo.properties[n].defaultValue.raw + ")" : "") + (oClassInfo.defaultProperty == n ? " (default)" : "") + "</li>");
1874+
lines.push("<li>{@link " + rname("get", n) + " " + n + "} : " + oClassInfo.properties[n].type + (oClassInfo.properties[n].defaultValue !== null && oClassInfo.properties[n].defaultValue.value !== null ? " (default: " + oClassInfo.properties[n].defaultValue.raw + ")" : "") + (oClassInfo.defaultProperty === n ? " (default)" : "") + "</li>");
18731875
}
18741876
lines.push("</ul>");
18751877
lines.push("</li>");
@@ -1879,7 +1881,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
18791881
lines.push("<ul>");
18801882
for (let n in oClassInfo.aggregations) {
18811883
if ( oClassInfo.aggregations[n].visibility !== "hidden" ) {
1882-
lines.push("<li>{@link " + rname("get", n) + " " + n + "} : " + makeTypeString(oClassInfo.aggregations[n]) + (oClassInfo.defaultAggregation == n ? " (default)" : "") + "</li>");
1884+
lines.push("<li>{@link " + rname("get", n) + " " + n + "} : " + makeTypeString(oClassInfo.aggregations[n]) + (oClassInfo.defaultAggregation === n ? " (default)" : "") + "</li>");
18831885
}
18841886
}
18851887
lines.push("</ul>");
@@ -2067,7 +2069,7 @@ function createAutoDoc(oClassInfo, classComment, doclet, node, parser, filename,
20672069
"@name " + name("get", n),
20682070
"@function"
20692071
]);
2070-
if ( info.cardinality == "0..n" ) {
2072+
if ( info.cardinality === "0..n" ) {
20712073
const n1 = info.singularName;
20722074
newJSDoc([
20732075
"Inserts a " + n1 + " into the aggregation " + link + ".",
@@ -3045,7 +3047,7 @@ exports.handlers = {
30453047
doclets.sort((a, b) => {
30463048
if ( a.longname === b.longname ) {
30473049
if ( a.synthetic === b.synthetic ) {
3048-
if ( a.meta && b.meta && a.meta.filename == b.meta.filename ) {
3050+
if ( a.meta && b.meta && a.meta.filename === b.meta.filename ) {
30493051
if ( a.meta.lineno !== b.meta.lineno ) {
30503052
return a.meta.lineno < b.meta.lineno ? -1 : 1;
30513053
}

lib/processors/jsdoc/lib/ui5/template/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ function createAPIXML(symbols, filename, options = {}) {
35263526
}
35273527

35283528
if ( !legacyContent ) {
3529-
if ( hasSettings && j == 1 && /setting/i.test(param.name) && /object/i.test(param.type) ) {
3529+
if ( hasSettings && j === 1 && /setting/i.test(param.name) && /object/i.test(param.type) ) {
35303530
if ( addRedundancy ) {
35313531
tag("parameterProperties");
35323532
writeParameterPropertiesForMSettings(symbolAPI);

0 commit comments

Comments
 (0)