Skip to content
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

fix: STRF-13077 Change hasOwnProperty usage #345

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helpers/3p/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ helpers.extend = function(/*objects*/) {
var obj = args[i];
if (utils.isObject(obj)) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (Object.hasOwnProperty.call(obj, key)) {
context[key] = obj[key];
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ helpers.forOwn = function(obj, options) {
var result = '';

for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (Object.hasOwnProperty.call(obj, key)) {
data.key = key;
result += options.fn(obj[key], {data: data});
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/3p/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ utils.isUndefined = function (val) {
*/

utils.isOptions = function (val) {
return utils.isObject(val) && val.hasOwnProperty('hash');
return utils.isObject(val) && Object.hasOwnProperty.call(val, 'hash');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion helpers/3p/utils/lib/deepMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function matchArray(arr, value) {

function matchObject(obj, value) {
for (var key in value) {
if (value.hasOwnProperty(key)) {
if (Object.hasOwnProperty.call(value, key)) {
if (deepMatches(obj[key], value[key]) === false) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/3p/utils/lib/isPlainObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function isPlainObject(o) {
if (isObject(prot) === false) {return false;}

// If constructor does not have an Object-specific method
if (prot.hasOwnProperty('isPrototypeOf') === false) {
if (Object.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion helpers/3p/utils/lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function markdown(config) {

options = merge({html: true, breaks: true}, config, options);
options = merge({}, options, options.markdown, options.hash);
if (options.hasOwnProperty('lang')) {
if (Object.hasOwnProperty.call(options, 'lang')) {
options.langPrefix = options.lang;
}

Expand Down
4 changes: 2 additions & 2 deletions helpers/decrementVar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const factory = globals => {
globals.storage.variables = {};
}

if (globals.storage.variables.hasOwnProperty(key) && Number.isInteger(globals.storage.variables[key])) {
if (Object.hasOwnProperty.call(globals.storage.variables, key) && Number.isInteger(globals.storage.variables[key])) {
// Decrement value if it already exists
globals.storage.variables[key] -= 1;
} else {
Expand All @@ -28,7 +28,7 @@ const factory = globals => {
}

// Return current value
return globals.storage.variables.hasOwnProperty(key) ? globals.storage.variables[key] : undefined;
return Object.hasOwnProperty.call(globals.storage.variables, key) ? globals.storage.variables[key] : undefined;
};
};

Expand Down
2 changes: 1 addition & 1 deletion helpers/deprecated/pick.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const factory = () => {
const paths = args[0];
if (paths && Array.isArray(paths)) {
paths.forEach((key) => {
if (target.hasOwnProperty(key)) {
if (Object.hasOwnProperty.call(target, key)) {
toReturn[key] = target[key];
}
})
Expand Down
2 changes: 1 addition & 1 deletion helpers/dynamicComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const factory = globals => {

path = Path.join(path, this['partial']);

if (globals.handlebars.partials[path] && globals.handlebars.partials.hasOwnProperty(path)) {
if (globals.handlebars.partials[path] && Object.hasOwnProperty.call(globals.handlebars.partials, path)) {
return globals.handlebars.partials[path](this);
}
};
Expand Down
2 changes: 1 addition & 1 deletion helpers/getVar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const factory = globals => {
throw new ValidationError("getVar helper key must be a string");
}

return globals.storage.variables && globals.storage.variables.hasOwnProperty(key) ? globals.storage.variables[key] : undefined
return globals.storage.variables && Object.hasOwnProperty.call(globals.storage.variables, key) ? globals.storage.variables[key] : undefined
};
};

Expand Down
4 changes: 2 additions & 2 deletions helpers/incrementVar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const factory = globals => {
globals.storage.variables = {};
}

if (globals.storage.variables.hasOwnProperty(key) && Number.isInteger(globals.storage.variables[key])) {
if (Object.hasOwnProperty.call(globals.storage.variables, key) && Number.isInteger(globals.storage.variables[key])) {
// Increment value if it already exists
globals.storage.variables[key] += 1;
} else {
Expand All @@ -28,7 +28,7 @@ const factory = globals => {
}

// Return current value
return globals.storage.variables.hasOwnProperty(key) ? globals.storage.variables[key] : undefined;
return Object.hasOwnProperty.call(globals.storage.variables, key) ? globals.storage.variables[key] : undefined;
};
};

Expand Down
2 changes: 1 addition & 1 deletion helpers/lib/cdnify.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = globals => {

if (cdnSettings) {
const endpointKey = protocol.slice(0, protocol.length - 1);
if (cdnSettings.hasOwnProperty(endpointKey)) {
if (Object.hasOwnProperty.call(cdnSettings, endpointKey)) {
if (cdnUrl) {
return [cdnSettings[endpointKey], path].join('/');
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/pluck.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const factory = () => {
return function(collection, path) {
if (collection && Array.isArray(collection)) {
return collection.map(item => item.hasOwnProperty(path) ? item[path] : undefined);
return collection.map(item => Object.hasOwnProperty.call(item, path) ? item[path] : undefined);
}
return [];
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"lint": "eslint .",
"lint-and-fix": "eslint . --fix",
"test": "lab -v -t 97.4 --ignore FinalizationRegistry,WeakRef,WebAssembly,__propKey,__esDecorate,__runInitializers,__setFunctionName,_time,format,SharedArrayBuffer,Atomics,BigUint64Array,BigInt64Array,BigInt,URL,URLSearchParams,TextEncoder,TextDecoder,queueMicrotask,__extends,__assign,__rest,__decorate,__param,__metadata,__awaiter,__generator,__exportStar,__createBinding,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,AggregateError,BroadcastChannel,structuredClone,DOMException,AbortController,AbortSignal,EventTarget,Event,MessageChannel,MessagePort,MessageEvent,atob,btoa,Blob,Performance,performance,ReadableStream,ReadableStreamDefaultReader,ReadableStreamBYOBReader,ReadableStreamBYOBRequest,ReadableByteStreamController,ReadableStreamDefaultController,TransformStream,TransformStreamDefaultController,WritableStream,WritableStreamDefaultWriter,WritableStreamDefaultController,ByteLengthQueuingStrategy,CountQueuingStrategy,TextEncoderStream,TextDecoderStream,CompressionStream,DecompressionStream,fetch,FormData,Headers,Request,Response,__addDisposableResource,__disposeResources,File,PerformanceEntry,PerformanceMark,PerformanceMeasure,PerformanceObserver,PerformanceObserverEntryList,PerformanceResourceTiming,crypto,Crypto,CryptoKey,SubtleCrypto,CustomEvent,WebSocket,Iterator,Navigator,navigator spec",
"test": "lab -v -t 97.4 --ignore FinalizationRegistry,WeakRef,WebAssembly,__propKey,__esDecorate,__runInitializers,__setFunctionName,_time,format,SharedArrayBuffer,Atomics,BigUint64Array,BigInt64Array,BigInt,URL,URLSearchParams,TextEncoder,TextDecoder,queueMicrotask,__extends,__assign,__rest,__decorate,__param,__metadata,__awaiter,__generator,__exportStar,__createBinding,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,AggregateError,BroadcastChannel,structuredClone,DOMException,AbortController,AbortSignal,EventTarget,Event,MessageChannel,MessagePort,MessageEvent,atob,btoa,Blob,Performance,performance,ReadableStream,ReadableStreamDefaultReader,ReadableStreamBYOBReader,ReadableStreamBYOBRequest,ReadableByteStreamController,ReadableStreamDefaultController,TransformStream,TransformStreamDefaultController,WritableStream,WritableStreamDefaultWriter,WritableStreamDefaultController,ByteLengthQueuingStrategy,CountQueuingStrategy,TextEncoderStream,TextDecoderStream,CompressionStream,DecompressionStream,fetch,FormData,Headers,Request,Response,__addDisposableResource,__disposeResources,File,PerformanceEntry,PerformanceMark,PerformanceMeasure,PerformanceObserver,PerformanceObserverEntryList,PerformanceResourceTiming,crypto,Crypto,CryptoKey,SubtleCrypto,CustomEvent,WebSocket,Iterator,Navigator,navigator,__rewriteRelativeImportExtension spec",
"coverage": "lab -c -r console -o stdout -r html -o coverage.html spec",
"release": "semantic-release"
},
Expand Down