mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Migrate codebase to use Object.hasOwn instead of Object.hasOwnProperty (#186829)
## Summary This PR has breadth, but not depth. This adds 3 new `eslint` rules. The first two protect against the use of code generated from strings (`eval` and friends), which will not work client-side due to our CSP, and is not something we wish to support server-side. The last rule aims to prevent a subtle class of bugs, and to defend against a subset of prototype pollution exploits: - `no-new-func` to be compliant with our CSP, and to prevent code execution from strings server-side: https://eslint.org/docs/latest/rules/no-new-func - `no-implied-eval` to be compliant with our CSP, and to prevent code execution from strings server-side: https://eslint.org/docs/latest/rules/no-implied-eval. Note that this function implies that it prevents no-new-func, but I don't see [test cases](https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-implied-eval.js) covering this behavior, so I think we should play it safe and enable both rules. - `no-prototype-builtins` to prevent accessing shadowed properties: https://eslint.org/docs/latest/rules/no-prototype-builtins In order to be compliant with `no-prototype-builtins`, I've migrated all usages and variants of `Object.hasOwnProperty` to use the newer [`Object.hasOwn`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn).
This commit is contained in:
parent
386d290ea4
commit
74d88580a5
230 changed files with 458 additions and 437 deletions
|
@ -111,10 +111,10 @@ export const getSearchEmbeddableFactory = (services: Services) => {
|
|||
)
|
||||
.subscribe((next) => {
|
||||
dataLoading$.next(false);
|
||||
if (next && next.hasOwnProperty('count') && next.count !== undefined) {
|
||||
if (next && Object.hasOwn(next, 'count') && next.count !== undefined) {
|
||||
count$.next(next.count);
|
||||
}
|
||||
if (next && next.hasOwnProperty('error')) {
|
||||
if (next && Object.hasOwn(next, 'error')) {
|
||||
blockingError$.next(next.error);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -108,7 +108,7 @@ export function TriggerContextExample({ uiActionsApi }: Props) {
|
|||
|
||||
const renderCellValue = useMemo(() => {
|
||||
return ({ rowIndex, columnId }: EuiDataGridCellValueElementProps) => {
|
||||
return rows.hasOwnProperty(rowIndex) ? rows[rowIndex][columnId] : null;
|
||||
return Object.hasOwn(rows, rowIndex) ? rows[rowIndex][columnId] : null;
|
||||
};
|
||||
}, [rows]);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ describe('parseClientOptions', () => {
|
|||
it('`customHeaders` take precedence to default kibana headers', () => {
|
||||
const customHeader: Record<string, string> = {};
|
||||
for (const header in defaultHeaders) {
|
||||
if (defaultHeaders.hasOwnProperty(header)) {
|
||||
if (Object.hasOwn(defaultHeaders, header)) {
|
||||
customHeader[header] = 'foo';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ function validateAndMerge(
|
|||
if (k.startsWith('_')) {
|
||||
throw new Error(`Invalid mapping "${k}". Mappings cannot start with _.`);
|
||||
}
|
||||
if (dest.hasOwnProperty(k)) {
|
||||
if (Object.hasOwn(dest, k)) {
|
||||
throw new Error(`Cannot redefine core mapping "${k}".`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ export function createIndexMap({ kibanaIndexName, registry, indexMap }: CreateIn
|
|||
const script = typeDef?.convertToAliasScript;
|
||||
// Defaults to kibanaIndexName if indexPattern isn't defined
|
||||
const indexPattern = typeDef?.indexPattern || kibanaIndexName;
|
||||
if (!map.hasOwnProperty(indexPattern as string)) {
|
||||
if (!Object.hasOwn(map, indexPattern as string)) {
|
||||
map[indexPattern] = { typeMappings: {} };
|
||||
}
|
||||
map[indexPattern].typeMappings[type] = indexMap[type];
|
||||
|
|
|
@ -16,7 +16,7 @@ export const buildTypesMappings = (
|
|||
types: SavedObjectsType[]
|
||||
): SavedObjectsTypeMappingDefinitions => {
|
||||
return types.reduce<SavedObjectsTypeMappingDefinitions>((acc, { name: type, mappings }) => {
|
||||
const duplicate = acc.hasOwnProperty(type);
|
||||
const duplicate = Object.hasOwn(acc, type);
|
||||
if (duplicate) {
|
||||
throw new Error(`Type ${type} is already defined.`);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export abstract class BaseUiSettingsClient implements IUiSettingsClient {
|
|||
}
|
||||
|
||||
isOverridden(key: string) {
|
||||
return this.overrides.hasOwnProperty(key);
|
||||
return Object.hasOwn(this.overrides, key);
|
||||
}
|
||||
|
||||
isSensitive(key: string): boolean {
|
||||
|
|
|
@ -93,7 +93,7 @@ export abstract class UiSettingsClientCommon extends BaseUiSettingsClient {
|
|||
}
|
||||
|
||||
private assertUpdateAllowed(key: string) {
|
||||
if (this.overrides.hasOwnProperty(key)) {
|
||||
if (Object.hasOwn(this.overrides, key)) {
|
||||
throw new CannotOverrideError(`Unable to update "${key}" because it is overridden`);
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export abstract class UiSettingsClientCommon extends BaseUiSettingsClient {
|
|||
// validate value read from saved objects as it can be changed via SO API
|
||||
const filteredValues: UserProvided<T> = {};
|
||||
for (const [key, userValue] of Object.entries(values)) {
|
||||
if (userValue === null || this.overrides.hasOwnProperty(key)) continue;
|
||||
if (userValue === null || Object.hasOwn(this.overrides, key)) continue;
|
||||
try {
|
||||
this.validateKey(key, userValue);
|
||||
filteredValues[key] = {
|
||||
|
|
|
@ -94,7 +94,7 @@ export class UiSettingsService
|
|||
registerInternalRoutes(router);
|
||||
|
||||
// Register public routes by default unless the publicApiEnabled config setting is set to false
|
||||
if (!config.hasOwnProperty('publicApiEnabled') || config.publicApiEnabled === true) {
|
||||
if (!Object.hasOwn(config, 'publicApiEnabled') || config.publicApiEnabled === true) {
|
||||
registerRoutes(router);
|
||||
}
|
||||
|
||||
|
|
|
@ -472,9 +472,9 @@
|
|||
}, this.createAnchor = function(row, column) {
|
||||
return new Anchor(this, row, column)
|
||||
}, this.$split = 0 === "aaa".split(/a/).length ? function(text) {
|
||||
return text.replace(/\r\n|\r/g, "\n").split("\n")
|
||||
return text.replace(/\r\n|\r/g, "\n").split("\n");
|
||||
} : function(text) {
|
||||
return text.split(/\r\n|\r|\n/)
|
||||
return text.split(/\r\n|\r|\n/);
|
||||
}, this.$detectNewLine = function(text) {
|
||||
var match = text.match(/^.*?(\r\n|\r|\n)/m);
|
||||
this.$autoNewLine = match ? match[1] : "\n", this._signal("changeNewLineMode")
|
||||
|
@ -711,9 +711,9 @@
|
|||
}, exports.arrayRemove = function(array, value) {
|
||||
for (var i = 0; array.length >= i; i++) value === array[i] && array.splice(i, 1)
|
||||
}, exports.escapeRegExp = function(str) {
|
||||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
|
||||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
|
||||
}, exports.escapeHTML = function(str) {
|
||||
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<")
|
||||
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
|
||||
}, exports.getMatchOffsets = function(string, regExp) {
|
||||
var matches = [];
|
||||
return string.replace(regExp, function(str) {
|
||||
|
|
|
@ -92,7 +92,7 @@ export class Optimizer {
|
|||
);
|
||||
|
||||
const log = new ToolingLog();
|
||||
const has = <T extends object>(obj: T, x: any): x is keyof T => obj.hasOwnProperty(x);
|
||||
const has = <T extends object>(obj: T, x: any): x is keyof T => Object.hasOwn(obj, x);
|
||||
|
||||
log.setWriters([
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ function flattenAccum(
|
|||
params?: TabifyDocsOptions
|
||||
) {
|
||||
for (const k in obj) {
|
||||
if (!obj.hasOwnProperty(k)) {
|
||||
if (!Object.hasOwn(obj, k)) {
|
||||
continue;
|
||||
}
|
||||
const val = obj[k];
|
||||
|
@ -114,7 +114,7 @@ export function flattenHit(hit: Hit, indexPattern?: DataView, params?: TabifyDoc
|
|||
// merged, since we would otherwise duplicate values, since ignore_field_values and _source
|
||||
// contain the same values.
|
||||
for (const fieldName in hit.ignored_field_values) {
|
||||
if (!hit.ignored_field_values.hasOwnProperty(fieldName)) {
|
||||
if (!Object.hasOwn(hit.ignored_field_values, fieldName)) {
|
||||
continue;
|
||||
}
|
||||
const fieldValue = hit.ignored_field_values[fieldName];
|
||||
|
|
|
@ -121,7 +121,7 @@ export const createStubClient = (
|
|||
return { body: { ok: true } };
|
||||
}),
|
||||
create: sinon.spy(async ({ index }) => {
|
||||
if (existingIndices.includes(index) || aliases.hasOwnProperty(index)) {
|
||||
if (existingIndices.includes(index) || Object.hasOwn(aliases, index)) {
|
||||
throw createEsClientError('resource_already_exists_exception');
|
||||
} else {
|
||||
existingIndices.push(index);
|
||||
|
|
|
@ -312,5 +312,9 @@ module.exports = {
|
|||
'@kbn/imports/uniform_imports': 'error',
|
||||
'@kbn/imports/no_unused_imports': 'error',
|
||||
'@kbn/imports/no_boundary_crossing': 'error',
|
||||
|
||||
'no-new-func': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-prototype-builtins': 'error',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ function Assertion (obj, flag, parent) {
|
|||
this.flags[flag] = true;
|
||||
|
||||
for (var i in parent.flags) {
|
||||
if (parent.flags.hasOwnProperty(i)) {
|
||||
if (Object.hasOwn(parent.flags, i)) {
|
||||
this.flags[i] = true;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ function Assertion (obj, flag, parent) {
|
|||
};
|
||||
|
||||
for (var fn in Assertion.prototype) {
|
||||
if (Assertion.prototype.hasOwnProperty(fn) && fn != name) {
|
||||
if (Object.hasOwn(Assertion.prototype, fn) && fn != name) {
|
||||
if (typeof this[name] === 'function' && fn === 'length') {
|
||||
continue;
|
||||
}
|
||||
|
|
2
packages/kbn-flot-charts/lib/jquery_flot.js
vendored
2
packages/kbn-flot-charts/lib/jquery_flot.js
vendored
|
@ -2750,7 +2750,7 @@ Licensed under the MIT license.
|
|||
var ascending = options.legend.sorted != "descending";
|
||||
entries.sort(function(a, b) {
|
||||
return a.label == b.label ? 0 : (
|
||||
(a.label < b.label) != ascending ? 1 : -1 // Logical XOR
|
||||
((a.label < b.label) != ascending ? 1 : -1) // Logical XOR
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ describe('Regressions', () => {
|
|||
// It's valid to execute a block against an undefined context, but
|
||||
// helpers can not do so, so we expect to have an empty object here;
|
||||
for (const name in this) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
||||
if (Object.hasOwn(this, name)) {
|
||||
return 'found';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ export function allowUnsafeEval() {
|
|||
try {
|
||||
// Do not remove the `kbnUnsafeEvalTest` parameter.
|
||||
// It is used for filtering out expected CSP failures, and must be the first piece of content in this function.
|
||||
// eslint-disable-next-line no-new-func
|
||||
new Function('kbnUnsafeEvalTest', 'return true;');
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
|
|
@ -112,7 +112,7 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
|
|||
if (result == null) {
|
||||
return result;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
||||
if (Object.hasOwn(parent, propertyName)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ const mergeManagedProperties = (
|
|||
if (
|
||||
isBasicObjectProp(prop) &&
|
||||
isManaged(prop) &&
|
||||
!Object.prototype.hasOwnProperty.call(managedValue, prop.key.value)
|
||||
!Object.hasOwn(managedValue, prop.key.value)
|
||||
) {
|
||||
remove(properties, prop);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export const SelectInput = ({
|
|||
const options = useMemo(
|
||||
() =>
|
||||
optionsProp?.map((option) => ({
|
||||
text: optionLabels.hasOwnProperty(option) ? optionLabels[option] : option,
|
||||
text: Object.hasOwn(optionLabels, option) ? optionLabels[option] : option,
|
||||
value: option,
|
||||
})),
|
||||
[optionsProp, optionLabels]
|
||||
|
|
|
@ -39,7 +39,7 @@ export const useSave = (params: UseSaveParameters) => {
|
|||
await saveChanges(changes, params.scope);
|
||||
params.clearChanges();
|
||||
const requiresReload = params.fields.some(
|
||||
(setting) => changes.hasOwnProperty(setting.id) && setting.requiresPageReload
|
||||
(setting) => Object.hasOwn(changes, setting.id) && setting.requiresPageReload
|
||||
);
|
||||
if (requiresReload) {
|
||||
showReloadPagePrompt();
|
||||
|
|
|
@ -145,7 +145,7 @@ const createForm = (url: string, fields: Record<string, string>) => {
|
|||
form.setAttribute('action', url);
|
||||
|
||||
for (const key in fields) {
|
||||
if (!fields.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(fields, key)) {
|
||||
continue;
|
||||
}
|
||||
const input = document.createElement('input');
|
||||
|
|
|
@ -78,7 +78,7 @@ set(child, 'foo', 3);
|
|||
// object and the `parent` object has not been modified:
|
||||
console.log(child.foo); // 3
|
||||
console.log(parent.foo); // 1
|
||||
console.log(Object.prototype.hasOwnProperty.call(child, 'foo')); // true
|
||||
console.log(Object.hasOwn(child, 'foo')); // true
|
||||
```
|
||||
|
||||
### The `path` must not access function prototypes
|
||||
|
|
|
@ -190,7 +190,7 @@ setFunctions.forEach(([testPermutations, set, testName]) => {
|
|||
t.notStrictEqual(arr, result);
|
||||
t.ok(Array.isArray(result));
|
||||
Object.keys(expected).forEach((key) => {
|
||||
t.ok(Object.prototype.hasOwnProperty.call(result, key));
|
||||
t.ok(Object.hasOwn(result, key));
|
||||
t.deepEqual(result[key], expected[key]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -115,7 +115,7 @@ setAndSetWithFunctions.forEach(([set, testName]) => {
|
|||
const arr = [];
|
||||
set(arr, path, 'foo');
|
||||
Object.keys(expected).forEach((key) => {
|
||||
t.ok(Object.prototype.hasOwnProperty.call(arr, key));
|
||||
t.ok(Object.hasOwn(arr, key));
|
||||
t.deepEqual(arr[key], expected[key]);
|
||||
});
|
||||
t.end();
|
||||
|
|
|
@ -43,7 +43,7 @@ export function defaultValidationErrorHandler(
|
|||
//
|
||||
// The Hapi code we're 'overwriting' can be found here:
|
||||
// https://github.com/hapijs/hapi/blob/master/lib/validation.js#L102
|
||||
if (err && err.name === 'ValidationError' && err.hasOwnProperty('output')) {
|
||||
if (err && err.name === 'ValidationError' && Object.hasOwn(err, 'output')) {
|
||||
const validationError: HapiValidationError = err as HapiValidationError;
|
||||
const validationKeys: string[] = [];
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ function walk(obj: any, keys: string[], value: any, path: string[]) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!obj.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(obj, key)) {
|
||||
obj[key] = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,6 @@ interface StackItem {
|
|||
previousKey: string | null;
|
||||
}
|
||||
|
||||
// we have to do Object.prototype.hasOwnProperty because when you create an object using
|
||||
// Object.create(null), and I assume other methods, you get an object without a prototype,
|
||||
// so you can't use current.hasOwnProperty
|
||||
const hasOwnProperty = (obj: any, property: string) =>
|
||||
Object.prototype.hasOwnProperty.call(obj, property);
|
||||
|
||||
const isObject = (obj: any) => typeof obj === 'object' && obj !== null;
|
||||
|
||||
// we're using a stack instead of recursion so we aren't limited by the call stack
|
||||
|
@ -40,11 +34,11 @@ export function ensureNoUnsafeProperties(obj: any) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hasOwnProperty(value, '__proto__')) {
|
||||
if (Object.hasOwn(value, '__proto__')) {
|
||||
throw new Error(`'__proto__' is an invalid key`);
|
||||
}
|
||||
|
||||
if (hasOwnProperty(value, 'prototype') && previousKey === 'constructor') {
|
||||
if (Object.hasOwn(value, 'prototype') && previousKey === 'constructor') {
|
||||
throw new Error(`'constructor.prototype' is an invalid key`);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ export const createAsyncInstance = <T>(
|
|||
},
|
||||
|
||||
get(_, prop, receiver) {
|
||||
if (loadingTarget.hasOwnProperty(prop)) {
|
||||
if (Object.hasOwn(loadingTarget, prop)) {
|
||||
return Reflect.get(loadingTarget as any, prop, receiver);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ export const createAsyncInstance = <T>(
|
|||
},
|
||||
|
||||
getOwnPropertyDescriptor(_, prop) {
|
||||
if (loadingTarget.hasOwnProperty(prop)) {
|
||||
if (Object.hasOwn(loadingTarget, prop)) {
|
||||
return Reflect.getOwnPropertyDescriptor(loadingTarget, prop);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ export const createAsyncInstance = <T>(
|
|||
},
|
||||
|
||||
has(_, prop) {
|
||||
if (!loadingTarget.hasOwnProperty(prop)) {
|
||||
if (!Object.hasOwn(loadingTarget, prop)) {
|
||||
return Reflect.has(loadingTarget, prop);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ export function createVerboseInstance(
|
|||
};
|
||||
}
|
||||
|
||||
if (result.hasOwnProperty('thrown')) {
|
||||
if (Object.hasOwn(result, 'thrown')) {
|
||||
log.indent(-2);
|
||||
throw result.thrown;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ Object.defineProperty(window, 'MutationObserver', { value: MutationObserver });
|
|||
|
||||
require('whatwg-fetch');
|
||||
|
||||
if (!global.URL.hasOwnProperty('createObjectURL')) {
|
||||
if (!Object.hasOwn(global.URL, 'createObjectURL')) {
|
||||
Object.defineProperty(global.URL, 'createObjectURL', { value: () => '' });
|
||||
}
|
||||
|
||||
// https://github.com/jsdom/jsdom/issues/2524
|
||||
if (!global.hasOwnProperty('TextEncoder')) {
|
||||
if (!Object.hasOwn(global, 'TextEncoder')) {
|
||||
const customTextEncoding = require('@kayahr/text-encoding');
|
||||
global.TextEncoder = customTextEncoding.TextEncoder;
|
||||
global.TextDecoder = customTextEncoding.TextDecoder;
|
||||
|
@ -29,11 +29,11 @@ if (!global.hasOwnProperty('TextEncoder')) {
|
|||
// https://github.com/jsdom/jsdom/issues/2555
|
||||
global.Blob = require('blob-polyfill').Blob;
|
||||
|
||||
if (!global.hasOwnProperty('ResizeObserver')) {
|
||||
if (!Object.hasOwn(global, 'ResizeObserver')) {
|
||||
global.ResizeObserver = require('resize-observer-polyfill');
|
||||
}
|
||||
|
||||
if (!global.hasOwnProperty('Worker')) {
|
||||
if (!Object.hasOwn(global, 'Worker')) {
|
||||
class Worker {
|
||||
constructor(stringUrl) {
|
||||
this.url = stringUrl;
|
||||
|
@ -49,7 +49,7 @@ if (!global.hasOwnProperty('Worker')) {
|
|||
|
||||
// Mocking matchMedia to resolve TypeError: window.matchMedia is not a function
|
||||
// For more info, see https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
||||
if (!global.hasOwnProperty('matchMedia')) {
|
||||
if (!Object.hasOwn(global, 'matchMedia')) {
|
||||
Object.defineProperty(global, 'matchMedia', {
|
||||
writable: true,
|
||||
// eslint-disable-next-line no-undef
|
||||
|
|
|
@ -69,7 +69,7 @@ export class KbnClientUiSettings {
|
|||
};
|
||||
|
||||
for (const [name, { isOverridden }] of Object.entries(await this.getAll())) {
|
||||
if (!isOverridden && !changes.hasOwnProperty(name)) {
|
||||
if (!isOverridden && !Object.hasOwn(changes, name)) {
|
||||
changes[name] = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ const MSG_PREFIXES = {
|
|||
error: `${red('ERROR')} `,
|
||||
};
|
||||
|
||||
const has = <T extends object>(obj: T, key: any): key is keyof T => obj.hasOwnProperty(key);
|
||||
const has = <T extends object>(obj: T, key: any): key is keyof T => Object.hasOwn(obj, key);
|
||||
|
||||
export interface ToolingLogTextWriterConfig {
|
||||
/**
|
||||
|
|
|
@ -97,7 +97,7 @@ export function groupValues(
|
|||
return;
|
||||
}
|
||||
|
||||
if (groups.hasOwnProperty(value)) {
|
||||
if (Object.hasOwn(groups, value)) {
|
||||
groups[value].count++;
|
||||
} else {
|
||||
groups[value] = {
|
||||
|
|
|
@ -16,6 +16,6 @@ export const apiHasExecutionContext = (
|
|||
unknownApi: null | unknown
|
||||
): unknownApi is HasExecutionContext => {
|
||||
return Boolean(
|
||||
unknownApi && typeof unknownApi === 'object' && unknownApi.hasOwnProperty('executionContext')
|
||||
unknownApi && typeof unknownApi === 'object' && Object.hasOwn(unknownApi, 'executionContext')
|
||||
);
|
||||
};
|
||||
|
|
|
@ -44,4 +44,4 @@ export const isAccordionNode = (
|
|||
node: Pick<ChromeProjectNavigationNode, 'renderAs' | 'defaultIsCollapsed' | 'isCollapsible'>
|
||||
) =>
|
||||
node.renderAs === 'accordion' ||
|
||||
['defaultIsCollapsed', 'isCollapsible'].some((prop) => node.hasOwnProperty(prop));
|
||||
['defaultIsCollapsed', 'isCollapsible'].some((prop) => Object.hasOwn(node, prop));
|
||||
|
|
|
@ -32,7 +32,7 @@ run(
|
|||
throw createFlagError('Missing alias');
|
||||
}
|
||||
|
||||
if (!storybookAliases.hasOwnProperty(alias)) {
|
||||
if (!Object.hasOwn(storybookAliases, alias)) {
|
||||
throw createFlagError(`Unknown alias [${alias}]`);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ export const metricTrendlineFunction = (): TrendlineExpressionFunctionDefinition
|
|||
});
|
||||
|
||||
for (const breakdownTerm in rowsByBreakdown) {
|
||||
if (!rowsByBreakdown.hasOwnProperty(breakdownTerm)) continue;
|
||||
if (!Object.hasOwn(rowsByBreakdown, breakdownTerm)) continue;
|
||||
trends[breakdownTerm] = rowsByBreakdown[breakdownTerm].map((row) => ({
|
||||
x: row[timeColId] !== null ? row[timeColId] : NaN,
|
||||
y: row[metricColId] !== null ? row[metricColId] : NaN,
|
||||
|
|
|
@ -79,13 +79,13 @@ const getDistinctColor = (
|
|||
formattedCategoricalKey: string
|
||||
) => {
|
||||
// TODO move away from Record to a Map to avoid issues with reserved JS keywords
|
||||
if (overwriteColors.hasOwnProperty(categoricalKey)) {
|
||||
if (Object.hasOwn(overwriteColors, categoricalKey)) {
|
||||
return overwriteColors[categoricalKey];
|
||||
}
|
||||
// this is for supporting old visualizations (created by vislib plugin)
|
||||
// it seems that there for some aggs, the uiState saved from vislib is
|
||||
// different from how es-charts handles it
|
||||
if (overwriteColors.hasOwnProperty(formattedCategoricalKey)) {
|
||||
if (Object.hasOwn(overwriteColors, formattedCategoricalKey)) {
|
||||
return overwriteColors[formattedCategoricalKey];
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ const overrideColors = (
|
|||
) => {
|
||||
let overwriteColor;
|
||||
|
||||
if (overwriteColors.hasOwnProperty(name)) {
|
||||
if (Object.hasOwn(overwriteColors, name)) {
|
||||
overwriteColor = overwriteColors[name];
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ export function convertMapboxVectorTileToJson(response: VectorTile) {
|
|||
const output: MapboxVectorTileJson = {};
|
||||
|
||||
for (const property in data) {
|
||||
if (data.hasOwnProperty(property)) {
|
||||
if (Object.hasOwn(data, property)) {
|
||||
const propertyObject: VectorTileLayer = data[property];
|
||||
const featuresArray = [];
|
||||
|
||||
|
|
|
@ -53,10 +53,7 @@ function init(window) {
|
|||
let alias = paths[testPath];
|
||||
if ('string' === typeof alias) return alias + tail;
|
||||
if (alias)
|
||||
{return (
|
||||
alias.location.replace(/\/*$/, '/') +
|
||||
(tail || alias.main || alias.name)
|
||||
);}
|
||||
{return (alias.location.replace(/\/*$/, '/') + (tail || alias.main || alias.name));}
|
||||
if (alias === !1) return '';
|
||||
let i = testPath.lastIndexOf('/');
|
||||
if (-1 === i) break;
|
||||
|
|
|
@ -45,7 +45,7 @@ export class CustomIntegrationRegistry {
|
|||
|
||||
const allowedCategories: IntegrationCategory[] = (customIntegration.categories ?? []).filter(
|
||||
(category) => {
|
||||
return INTEGRATION_CATEGORY_DISPLAY.hasOwnProperty(category);
|
||||
return Object.hasOwn(INTEGRATION_CATEGORY_DISPLAY, category);
|
||||
}
|
||||
) as IntegrationCategory[];
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ test('convertSavedDashboardPanelToPanelState does not include undefined id', ()
|
|||
};
|
||||
|
||||
const converted = convertSavedDashboardPanelToPanelState(savedDashboardPanel);
|
||||
expect(converted.hasOwnProperty('savedObjectId')).toBe(false);
|
||||
expect(Object.hasOwn(converted, 'savedObjectId')).toBe(false);
|
||||
});
|
||||
|
||||
test('convertPanelStateToSavedDashboardPanel', () => {
|
||||
|
@ -123,7 +123,7 @@ test('convertPanelStateToSavedDashboardPanel will not add an undefined id when n
|
|||
};
|
||||
|
||||
const converted = convertPanelStateToSavedDashboardPanel(dashboardPanel);
|
||||
expect(converted.hasOwnProperty('id')).toBe(false);
|
||||
expect(Object.hasOwn(converted, 'id')).toBe(false);
|
||||
});
|
||||
|
||||
test('convertPanelStateToSavedDashboardPanel will not leave title as part of embeddable config', () => {
|
||||
|
@ -143,7 +143,7 @@ test('convertPanelStateToSavedDashboardPanel will not leave title as part of emb
|
|||
};
|
||||
|
||||
const converted = convertPanelStateToSavedDashboardPanel(dashboardPanel);
|
||||
expect(converted.embeddableConfig.hasOwnProperty('title')).toBe(false);
|
||||
expect(Object.hasOwn(converted.embeddableConfig, 'title')).toBe(false);
|
||||
expect(converted.title).toBe('title');
|
||||
});
|
||||
|
||||
|
|
|
@ -841,7 +841,7 @@ describe('SearchSource', () => {
|
|||
searchSource.setField('fields', ['*']);
|
||||
|
||||
const request = searchSource.getSearchRequestBody();
|
||||
expect(request.hasOwnProperty('docvalue_fields')).toBe(false);
|
||||
expect(Object.hasOwn(request, 'docvalue_fields')).toBe(false);
|
||||
expect(request.fields).toEqual([
|
||||
{ field: 'foo-bar' },
|
||||
{ field: 'field1' },
|
||||
|
|
|
@ -808,7 +808,7 @@ export class SearchSource {
|
|||
|
||||
// set defaults
|
||||
const _source =
|
||||
index && !body.hasOwnProperty('_source') ? dataView?.getSourceFiltering() : body._source;
|
||||
index && !Object.hasOwn(body, '_source') ? dataView?.getSourceFiltering() : body._source;
|
||||
|
||||
// get filter if data view specified, otherwise null filter
|
||||
const filter = this.getFieldFilter({ bodySourceExcludes: _source?.excludes, metaFields });
|
||||
|
@ -962,7 +962,7 @@ export class SearchSource {
|
|||
private getBuiltEsQuery({ index, query = [], filters = [], getConfig, sort }: SearchRequest) {
|
||||
// If sorting by _score, build queries in the "must" clause instead of "filter" clause to enable scoring
|
||||
const filtersInMustClause = (sort ?? []).some((srt: EsQuerySortValue[]) =>
|
||||
srt.hasOwnProperty('_score')
|
||||
Object.hasOwn(srt, '_score')
|
||||
);
|
||||
const esQueryConfigs = {
|
||||
...getEsQueryConfig({ get: getConfig }),
|
||||
|
|
|
@ -63,7 +63,7 @@ export class TabbedAggResponseWriter {
|
|||
let isPartialRow = false;
|
||||
for (let i = 0; i < this.columns.length; i++) {
|
||||
const column = this.columns[i];
|
||||
if (!rowBuffer.hasOwnProperty(column.id)) {
|
||||
if (!Object.hasOwn(rowBuffer, column.id)) {
|
||||
isPartialRow = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export function shallowEqual(objA: unknown, objB: unknown): boolean {
|
|||
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
|
||||
!Object.hasOwn(objB, keysA[i]) ||
|
||||
// @ts-ignore
|
||||
!Object.is(objA[keysA[i]], objB[keysA[i]])
|
||||
) {
|
||||
|
|
|
@ -400,7 +400,7 @@ export class SearchSessionService implements ISearchSessionService {
|
|||
|
||||
const session = await this.get(deps, user, sessionId);
|
||||
const requestHash = createRequestHash(searchRequest.params);
|
||||
if (!session.attributes.idMapping.hasOwnProperty(requestHash)) {
|
||||
if (!Object.hasOwn(session.attributes.idMapping, requestHash)) {
|
||||
this.logger.error(`SearchSessionService: getId | ${sessionId} | ${requestHash} not found`);
|
||||
this.logger.debug(
|
||||
`SearchSessionService: getId not found search with params: ${JSON.stringify(
|
||||
|
|
|
@ -29,7 +29,7 @@ const OVERRIDES: Record<string, Partial<FieldDescriptor>> = {
|
|||
* @return {FieldDescriptor}
|
||||
*/
|
||||
export function mergeOverrides(field: FieldDescriptor): FieldDescriptor {
|
||||
if (OVERRIDES.hasOwnProperty(field.name)) {
|
||||
if (Object.hasOwn(OVERRIDES, field.name)) {
|
||||
return merge(field, OVERRIDES[field.name]);
|
||||
} else {
|
||||
return field;
|
||||
|
|
|
@ -190,7 +190,7 @@ export function buildExpressionFunction<
|
|||
|
||||
addArgument(key, value) {
|
||||
if (value !== undefined) {
|
||||
if (!args.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(args, key)) {
|
||||
args[key] = [];
|
||||
}
|
||||
args[key].push(value);
|
||||
|
@ -199,14 +199,14 @@ export function buildExpressionFunction<
|
|||
},
|
||||
|
||||
getArgument(key) {
|
||||
if (!args.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(args, key)) {
|
||||
return;
|
||||
}
|
||||
return args[key];
|
||||
},
|
||||
|
||||
replaceArgument(key, values) {
|
||||
if (!args.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(args, key)) {
|
||||
throw new Error('Argument to replace does not exist on this function');
|
||||
}
|
||||
args[key] = values;
|
||||
|
|
|
@ -108,7 +108,7 @@ export class UrlFormat extends FieldFormat {
|
|||
let i = -1;
|
||||
while (++i < parts.length) {
|
||||
if (i % 2) {
|
||||
if (locals.hasOwnProperty(parts[i])) {
|
||||
if (Object.hasOwn(locals, parts[i])) {
|
||||
const local = locals[parts[i]];
|
||||
output += local == null ? '' : local;
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ export class ManagementSectionsService {
|
|||
|
||||
start({ capabilities }: SectionsServiceStartDeps) {
|
||||
this.getAllSections().forEach((section) => {
|
||||
if (capabilities.management.hasOwnProperty(section.id)) {
|
||||
if (Object.hasOwn(capabilities.management, section.id)) {
|
||||
const sectionCapabilities = capabilities.management[section.id];
|
||||
section.apps.forEach((app) => {
|
||||
const capabilitiesId = app.capabilitiesId || app.id;
|
||||
if (
|
||||
sectionCapabilities.hasOwnProperty(capabilitiesId) &&
|
||||
Object.hasOwn(sectionCapabilities, capabilitiesId) &&
|
||||
sectionCapabilities[capabilitiesId] !== true
|
||||
) {
|
||||
app.disable();
|
||||
|
|
|
@ -147,7 +147,7 @@ describe('Table', () => {
|
|||
|
||||
const table = component.find('EuiBasicTable');
|
||||
const columns = table.prop('columns') as any[];
|
||||
const actionColumn = columns.find((x) => x.hasOwnProperty('actions')) as { actions: any[] };
|
||||
const actionColumn = columns.find((x) => Object.hasOwn(x, 'actions')) as { actions: any[] };
|
||||
const someAction = actionColumn.actions.find(
|
||||
(x) => x['data-test-subj'] === 'savedObjectsTableAction-someAction'
|
||||
);
|
||||
|
|
|
@ -62,11 +62,12 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
|
|||
const isVersionFieldType = field?.esTypes?.includes('version');
|
||||
|
||||
return (
|
||||
// suggestions don't work for version fields
|
||||
shouldSuggestValues &&
|
||||
field &&
|
||||
field.aggregatable &&
|
||||
field.type === 'string' &&
|
||||
!isVersionFieldType // suggestions don't work for version fields
|
||||
!isVersionFieldType
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,11 @@ export default class QueryStringInputUI extends PureComponent<QueryStringInputPr
|
|||
QueryStringInputProps['indexPatterns'][number],
|
||||
DataView
|
||||
>(this.props.indexPatterns || [], (indexPattern): indexPattern is DataView => {
|
||||
return indexPattern.hasOwnProperty('fields') && indexPattern.hasOwnProperty('title');
|
||||
return (
|
||||
typeof indexPattern === 'object' &&
|
||||
Object.hasOwn(indexPattern, 'fields') &&
|
||||
Object.hasOwn(indexPattern, 'title')
|
||||
);
|
||||
});
|
||||
const idOrTitlePatterns = stringPatterns.map((sp) =>
|
||||
typeof sp === 'string' ? { type: 'title', value: sp } : sp
|
||||
|
|
|
@ -24,7 +24,7 @@ export function shallowEqual(objA: unknown, objB: unknown): boolean {
|
|||
|
||||
for (let i = 0; i < keysA.length; i++) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
|
||||
!Object.hasOwn(objB, keysA[i]) ||
|
||||
// @ts-ignore
|
||||
!Object.is(objA[keysA[i]], objB[keysA[i]])
|
||||
) {
|
||||
|
|
|
@ -141,8 +141,8 @@ function DefaultEditorAggParams({
|
|||
Object.entries(editorConfig).forEach(([param, paramConfig]) => {
|
||||
const paramOptions = agg.type.params.find((paramOption) => paramOption.name === param);
|
||||
|
||||
const hasFixedValue = paramConfig.hasOwnProperty(FIXED_VALUE_PROP);
|
||||
const hasDefault = paramConfig.hasOwnProperty(DEFAULT_PROP);
|
||||
const hasFixedValue = Object.hasOwn(paramConfig, FIXED_VALUE_PROP);
|
||||
const hasDefault = Object.hasOwn(paramConfig, DEFAULT_PROP);
|
||||
// If the parameter has a fixed value in the config, set this value.
|
||||
// Also for all supported configs we should freeze the editor for this param.
|
||||
if (hasFixedValue || hasDefault) {
|
||||
|
|
|
@ -33,7 +33,7 @@ export function tableVisResponseHandler(input: Datatable, visConfig: TableVisCon
|
|||
input.rows.forEach((row) => {
|
||||
const splitValue: string | number = row[splitColumn.id];
|
||||
|
||||
if (!splitMap.hasOwnProperty(splitValue)) {
|
||||
if (!Object.hasOwn(splitMap, splitValue)) {
|
||||
splitMap[splitValue] = splitIndex++;
|
||||
const tableGroup: TableGroup = {
|
||||
title: `${splitColumnFormatter.convert(splitValue)}: ${splitColumn.name}`,
|
||||
|
|
|
@ -21,7 +21,7 @@ function unflatten(data) {
|
|||
let prop = '';
|
||||
let m;
|
||||
while ((m = regex.exec(p))) {
|
||||
cur = (cur.hasOwnProperty(prop) && cur[prop]) || (cur[prop] = m[2] ? [] : {});
|
||||
cur = (Object.hasOwn(cur, prop) && cur[prop]) || (cur[prop] = m[2] ? [] : {});
|
||||
prop = m[2] || m[1];
|
||||
}
|
||||
cur[prop] = data[p];
|
||||
|
|
|
@ -75,7 +75,7 @@ export const InspectorDataGrid = ({ columns, data, dataGridAriaLabel }: Inspecto
|
|||
// then the row index must be adjusted as `data` has already been pruned to the page size
|
||||
adjustedRowIndex = rowIndex - pagination.pageIndex * pagination.pageSize;
|
||||
|
||||
return gridData.hasOwnProperty(adjustedRowIndex)
|
||||
return Object.hasOwn(gridData, adjustedRowIndex)
|
||||
? gridData[adjustedRowIndex][columnId] || null
|
||||
: null;
|
||||
}) as EuiDataGridProps['renderCellValue'];
|
||||
|
|
|
@ -23,7 +23,7 @@ import { getFormatService } from '../../services';
|
|||
class D3MappableObject {
|
||||
constructor(data) {
|
||||
for (const key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
if (Object.hasOwn(data, key)) {
|
||||
this[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ function tableResponseHandler(table, dimensions) {
|
|||
const splitValue = row[splitColumn.id];
|
||||
const formattedValue = splitColumnFormatter.convert(splitValue);
|
||||
|
||||
if (!splitMap.hasOwnProperty(splitValue)) {
|
||||
if (!Object.hasOwn(splitMap, splitValue)) {
|
||||
splitMap[splitValue] = splitIndex++;
|
||||
const tableGroup = {
|
||||
$parent: converted,
|
||||
|
|
|
@ -45,7 +45,7 @@ function logHeaders(res) {
|
|||
// use `--headers` to print the response headers
|
||||
const headers = res.headers.raw();
|
||||
for (const key in headers) {
|
||||
if (headers.hasOwnProperty(key)) {
|
||||
if (Object.hasOwn(headers, key)) {
|
||||
console.log(`${key}: ${headers[key]}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -368,11 +368,11 @@ export const useRenderCellValue = (
|
|||
}
|
||||
|
||||
function getCellValue(cId: string) {
|
||||
if (tableItems.hasOwnProperty(adjustedRowIndex)) {
|
||||
if (Object.hasOwn(tableItems, adjustedRowIndex)) {
|
||||
const item = tableItems[adjustedRowIndex];
|
||||
|
||||
// Try if the field name is available as is.
|
||||
if (item.hasOwnProperty(cId)) {
|
||||
if (Object.hasOwn(item, cId)) {
|
||||
return item[cId];
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ export const UrlStateProvider: FC<PropsWithChildren<unknown>> = ({ children }) =
|
|||
const urlState = parseUrlState(prevSearchString);
|
||||
const parsedQueryString = parse(prevSearchString, { sort: false });
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(urlState, accessor)) {
|
||||
if (!Object.hasOwn(urlState, accessor)) {
|
||||
urlState[accessor] = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ export const config: PluginConfigDescriptor<ActionsConfig> = {
|
|||
if (
|
||||
customHostSettings.find(
|
||||
(customHostSchema: CustomHostSettings) =>
|
||||
customHostSchema.hasOwnProperty('ssl') &&
|
||||
customHostSchema.ssl?.hasOwnProperty('rejectUnauthorized')
|
||||
Object.hasOwn(customHostSchema, 'ssl') &&
|
||||
Object.hasOwn(customHostSchema.ssl ?? {}, 'rejectUnauthorized')
|
||||
)
|
||||
) {
|
||||
addDeprecation({
|
||||
|
@ -93,7 +93,7 @@ export const config: PluginConfigDescriptor<ActionsConfig> = {
|
|||
},
|
||||
(settings, fromPath, addDeprecation) => {
|
||||
const actions = get(settings, fromPath);
|
||||
if (actions?.hasOwnProperty('rejectUnauthorized')) {
|
||||
if (Object.hasOwn(actions ?? {}, 'rejectUnauthorized')) {
|
||||
addDeprecation({
|
||||
level: 'warning',
|
||||
configPath: `${fromPath}.rejectUnauthorized`,
|
||||
|
@ -121,7 +121,7 @@ export const config: PluginConfigDescriptor<ActionsConfig> = {
|
|||
},
|
||||
(settings, fromPath, addDeprecation) => {
|
||||
const actions = get(settings, fromPath);
|
||||
if (actions?.hasOwnProperty('proxyRejectUnauthorizedCertificates')) {
|
||||
if (Object.hasOwn(actions ?? {}, 'proxyRejectUnauthorizedCertificates')) {
|
||||
addDeprecation({
|
||||
level: 'warning',
|
||||
configPath: `${fromPath}.proxyRejectUnauthorizedCertificates`,
|
||||
|
|
|
@ -104,7 +104,7 @@ function buildObject(key: string, value: unknown) {
|
|||
function addToStringDeep(object: unknown): void {
|
||||
// for objects, add a toString method, and then walk
|
||||
if (isNonNullObject(object)) {
|
||||
if (!object.hasOwnProperty('toString')) {
|
||||
if (!Object.hasOwn(object, 'toString')) {
|
||||
object.toString = () => JSON.stringify(object);
|
||||
}
|
||||
Object.values(object).forEach((value) => addToStringDeep(value));
|
||||
|
|
|
@ -42,7 +42,7 @@ export function getActionsMigrations(
|
|||
const migrationActionsTen = createEsoMigration(
|
||||
encryptedSavedObjects,
|
||||
(doc): doc is SavedObjectUnsanitizedDoc<RawAction> =>
|
||||
doc.attributes.config?.hasOwnProperty('casesConfiguration') ||
|
||||
Object.hasOwn(doc.attributes.config ?? {}, 'casesConfiguration') ||
|
||||
doc.attributes.actionTypeId === '.email',
|
||||
pipeMigrations(renameCasesConfigurationObject, addHasAuthConfigurationObject)
|
||||
);
|
||||
|
@ -50,8 +50,8 @@ export function getActionsMigrations(
|
|||
const migrationActionsEleven = createEsoMigration(
|
||||
encryptedSavedObjects,
|
||||
(doc): doc is SavedObjectUnsanitizedDoc<RawAction> =>
|
||||
doc.attributes.config?.hasOwnProperty('isCaseOwned') ||
|
||||
doc.attributes.config?.hasOwnProperty('incidentConfiguration') ||
|
||||
Object.hasOwn(doc.attributes.config ?? {}, 'isCaseOwned') ||
|
||||
Object.hasOwn(doc.attributes.config ?? {}, 'incidentConfiguration') ||
|
||||
doc.attributes.actionTypeId === '.webhook',
|
||||
pipeMigrations(removeCasesFieldMappings, addHasAuthConfigurationObject)
|
||||
);
|
||||
|
@ -142,8 +142,8 @@ function removeCasesFieldMappings(
|
|||
doc: SavedObjectUnsanitizedDoc<RawAction>
|
||||
): SavedObjectUnsanitizedDoc<RawAction> {
|
||||
if (
|
||||
!doc.attributes.config?.hasOwnProperty('isCaseOwned') &&
|
||||
!doc.attributes.config?.hasOwnProperty('incidentConfiguration')
|
||||
!Object.hasOwn(doc.attributes.config ?? {}, 'isCaseOwned') &&
|
||||
!Object.hasOwn(doc.attributes.config ?? {}, 'incidentConfiguration')
|
||||
) {
|
||||
return doc;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ export function getEsQueryFromSavedSearch({
|
|||
if (Array.isArray(savedQuery.bool.filter) && timeField !== undefined) {
|
||||
savedQuery.bool.filter = savedQuery.bool.filter.filter(
|
||||
(c: QueryDslQueryContainer) =>
|
||||
!(c.hasOwnProperty('range') && c.range?.hasOwnProperty(timeField))
|
||||
!(Object.hasOwn(c, 'range') && Object.hasOwn(c.range ?? {}, timeField))
|
||||
);
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -345,7 +345,7 @@ export const LogRateAnalysisResultsGroupsTable: FC<LogRateAnalysisResultsTablePr
|
|||
) {
|
||||
const itemIdToExpandedRowMapValues = { ...itemIdToExpandedRowMap };
|
||||
for (const itemId in itemIdToExpandedRowMapValues) {
|
||||
if (itemIdToExpandedRowMapValues.hasOwnProperty(itemId)) {
|
||||
if (Object.hasOwn(itemIdToExpandedRowMapValues, itemId)) {
|
||||
const component = itemIdToExpandedRowMapValues[itemId];
|
||||
itemIdToExpandedRowMapValues[itemId] = (
|
||||
<LogRateAnalysisResultsTable {...component.props} skippedColumns={skippedColumns} />
|
||||
|
|
|
@ -596,7 +596,7 @@ export const useColumns = (
|
|||
|
||||
for (const columnName in columnNamesToReturn) {
|
||||
if (
|
||||
columnNamesToReturn.hasOwnProperty(columnName) === false ||
|
||||
Object.hasOwn(columnNamesToReturn, columnName) === false ||
|
||||
skippedColumns.includes(columnNamesToReturn[columnName as ColumnNames] as string) ||
|
||||
((columnName === 'p-value' || columnName === 'Impact') && zeroDocsFallback)
|
||||
)
|
||||
|
|
|
@ -429,7 +429,7 @@ export class AlertsClient<
|
|||
// See if there's an existing active alert document
|
||||
if (!!activeAlerts[id]) {
|
||||
if (
|
||||
this.fetchedAlerts.data.hasOwnProperty(id) &&
|
||||
Object.hasOwn(this.fetchedAlerts.data, id) &&
|
||||
get(this.fetchedAlerts.data[id], ALERT_STATUS) === 'active'
|
||||
) {
|
||||
const isImproving = isAlertImproving<
|
||||
|
@ -491,7 +491,7 @@ export class AlertsClient<
|
|||
for (const id of keys(recoveredAlertsToReturn)) {
|
||||
// See if there's an existing alert document
|
||||
// If there is not, log an error because there should be
|
||||
if (this.fetchedAlerts.data.hasOwnProperty(id)) {
|
||||
if (Object.hasOwn(this.fetchedAlerts.data, id)) {
|
||||
recoveredAlertsToIndex.push(
|
||||
currentRecoveredAlerts[id]
|
||||
? buildRecoveredAlert<
|
||||
|
|
|
@ -229,7 +229,7 @@ export class LegacyAlertsClient<
|
|||
public getProcessedAlerts(
|
||||
type: 'new' | 'active' | 'activeCurrent' | 'recovered' | 'recoveredCurrent'
|
||||
) {
|
||||
if (this.processedAlerts.hasOwnProperty(type)) {
|
||||
if (Object.hasOwn(this.processedAlerts, type)) {
|
||||
return this.processedAlerts[type];
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ function processAlertsHelper<
|
|||
const recoveredAlerts: Record<string, Alert<State, Context, RecoveryActionGroupId>> = {};
|
||||
|
||||
for (const id in alerts) {
|
||||
if (alerts.hasOwnProperty(id)) {
|
||||
if (Object.hasOwn(alerts, id)) {
|
||||
// alerts with scheduled actions are considered "active"
|
||||
if (alerts[id].hasScheduledActions()) {
|
||||
activeAlerts[id] = alerts[id];
|
||||
|
@ -209,8 +209,8 @@ function processAlertsLimitReached<
|
|||
|
||||
// update duration for existing alerts
|
||||
for (const id in activeAlerts) {
|
||||
if (activeAlerts.hasOwnProperty(id)) {
|
||||
if (alerts.hasOwnProperty(id)) {
|
||||
if (Object.hasOwn(activeAlerts, id)) {
|
||||
if (Object.hasOwn(alerts, id)) {
|
||||
activeAlerts[id] = alerts[id];
|
||||
}
|
||||
const state = existingAlerts[id].getState();
|
||||
|
@ -241,7 +241,7 @@ function processAlertsLimitReached<
|
|||
|
||||
// look for new alerts and add until we hit capacity
|
||||
for (const id in alerts) {
|
||||
if (alerts.hasOwnProperty(id) && alerts[id].hasScheduledActions()) {
|
||||
if (Object.hasOwn(alerts, id) && alerts[id].hasScheduledActions()) {
|
||||
// if this alert did not exist in previous run, it is considered "new"
|
||||
if (!existingAlertIds.has(id)) {
|
||||
activeAlerts[id] = alerts[id];
|
||||
|
|
|
@ -72,12 +72,12 @@ export const formatDefaultAggregationResult = (
|
|||
|
||||
// Fill missing keys with zeroes
|
||||
for (const key of RuleExecutionStatusValues) {
|
||||
if (!result.ruleExecutionStatus.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(result.ruleExecutionStatus, key)) {
|
||||
result.ruleExecutionStatus[key] = 0;
|
||||
}
|
||||
}
|
||||
for (const key of RuleLastRunOutcomeValues) {
|
||||
if (!result.ruleLastRunOutcome.hasOwnProperty(key)) {
|
||||
if (!Object.hasOwn(result.ruleLastRunOutcome, key)) {
|
||||
result.ruleLastRunOutcome[key] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export function updateMeta<T extends Partial<RawRule>>(
|
|||
context: RulesClientContext,
|
||||
alertAttributes: T
|
||||
): T {
|
||||
if (alertAttributes.hasOwnProperty('apiKey') || alertAttributes.hasOwnProperty('apiKeyOwner')) {
|
||||
if (Object.hasOwn(alertAttributes, 'apiKey') || Object.hasOwn(alertAttributes, 'apiKeyOwner')) {
|
||||
alertAttributes.meta = alertAttributes.meta ?? {};
|
||||
alertAttributes.meta.versionApiKeyLastmodified = context.kibanaVersion;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export function updateMetaAttributes<T extends Partial<RuleAttributes>>(
|
|||
context: RulesClientContext,
|
||||
alertAttributes: T
|
||||
): T {
|
||||
if (alertAttributes.hasOwnProperty('apiKey') || alertAttributes.hasOwnProperty('apiKeyOwner')) {
|
||||
if (Object.hasOwn(alertAttributes, 'apiKey') || Object.hasOwn(alertAttributes, 'apiKeyOwner')) {
|
||||
return {
|
||||
...alertAttributes,
|
||||
meta: {
|
||||
|
|
|
@ -19,7 +19,7 @@ export const isAnyActionSupportIncidents = (doc: SavedObjectUnsanitizedDoc<RawRu
|
|||
|
||||
function isEmptyObject(obj: {}) {
|
||||
for (const attr in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, attr)) {
|
||||
if (Object.hasOwn(obj, attr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ import { createCommonUpdateUserActionBuilder } from './common';
|
|||
import { statuses } from '../status';
|
||||
import * as i18n from './translations';
|
||||
|
||||
const isStatusValid = (status: string): status is CaseStatuses =>
|
||||
Object.prototype.hasOwnProperty.call(statuses, status);
|
||||
const isStatusValid = (status: string): status is CaseStatuses => Object.hasOwn(statuses, status);
|
||||
|
||||
const getLabelTitle = (userAction: SnakeToCamelCase<StatusUserAction>) => {
|
||||
const status = userAction.payload.status ?? '';
|
||||
|
|
|
@ -91,7 +91,7 @@ function selectorsIncludeConditionsForFIMOperations(
|
|||
!!(
|
||||
selector &&
|
||||
conditions.reduce((p, c) => {
|
||||
return p && selector.hasOwnProperty(c);
|
||||
return p && Object.hasOwn(selector, c);
|
||||
}, true)
|
||||
);
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ const StringArrayCondition = ({
|
|||
label={label}
|
||||
fullWidth={true}
|
||||
key={prop}
|
||||
isInvalid={!!errorMap.hasOwnProperty(prop)}
|
||||
isInvalid={!!Object.hasOwn(errorMap, prop)}
|
||||
>
|
||||
<EuiFlexGroup alignItems="center" gutterSize="m">
|
||||
<EuiFlexItem>
|
||||
|
@ -216,7 +216,7 @@ export const ControlGeneralViewSelector = ({
|
|||
const availableConditions = useMemo(() => getSelectorConditions(selector.type), [selector]);
|
||||
|
||||
const remainingConditions = useMemo(() => {
|
||||
return availableConditions.filter((condition) => !selector.hasOwnProperty(condition));
|
||||
return availableConditions.filter((condition) => !Object.hasOwn(selector, condition));
|
||||
}, [availableConditions, selector]);
|
||||
|
||||
const conditionsAdded = useMemo(() => {
|
||||
|
@ -462,14 +462,14 @@ export const ControlGeneralViewSelector = ({
|
|||
<EuiFormRow
|
||||
label={i18n.name}
|
||||
fullWidth={true}
|
||||
isInvalid={!!errorMap.hasOwnProperty('name')}
|
||||
isInvalid={!!Object.hasOwn(errorMap, 'name')}
|
||||
>
|
||||
<EuiFieldText
|
||||
fullWidth={true}
|
||||
name="name"
|
||||
value={selector.name}
|
||||
onChange={onNameChange}
|
||||
isInvalid={errorMap.hasOwnProperty('name')}
|
||||
isInvalid={Object.hasOwn(errorMap, 'name')}
|
||||
data-test-subj="cloud-defend-selectorcondition-name"
|
||||
maxLength={MAX_SELECTOR_NAME_LENGTH}
|
||||
/>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -152,7 +152,7 @@ type RegistryPolicyTemplateWithInputs = RegistryPolicyTemplate & {
|
|||
export const hasPolicyTemplateInputs = (
|
||||
policyTemplate: RegistryPolicyTemplate
|
||||
): policyTemplate is RegistryPolicyTemplateWithInputs => {
|
||||
return policyTemplate.hasOwnProperty('inputs');
|
||||
return Object.hasOwn(policyTemplate, 'inputs');
|
||||
};
|
||||
|
||||
export const getVulnMgmtCloudFormationDefaultValue = (packageInfo: PackageInfo): string => {
|
||||
|
|
|
@ -107,7 +107,6 @@ class FollowerIndexPauseProviderUi extends PureComponent {
|
|||
)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{!isSingle && (
|
||||
<Fragment>
|
||||
<p>
|
||||
|
|
|
@ -54,11 +54,11 @@ export interface FileBasedUnknownFieldVisConfig {
|
|||
export function isFileBasedFieldVisConfig(
|
||||
field: FieldVisConfig | FileBasedFieldVisConfig
|
||||
): field is FileBasedFieldVisConfig {
|
||||
return !field.hasOwnProperty('existsInDocs');
|
||||
return !Object.hasOwn(field, 'existsInDocs');
|
||||
}
|
||||
|
||||
export function isIndexBasedFieldVisConfig(
|
||||
field: FieldVisConfig | FileBasedFieldVisConfig
|
||||
): field is FieldVisConfig {
|
||||
return field.hasOwnProperty('existsInDocs');
|
||||
return Object.hasOwn(field, 'existsInDocs');
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ export class CombinedFieldsForm extends Component<Props, State> {
|
|||
}
|
||||
|
||||
const mappings = this.parseMappings();
|
||||
return mappings.properties.hasOwnProperty(name);
|
||||
return Object.hasOwn(mappings.properties, name);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
@ -180,7 +180,7 @@ export const ResultsLinks: FC<Props> = ({
|
|||
fieldStats &&
|
||||
typeof fieldStats === 'object' &&
|
||||
timeFieldName !== undefined &&
|
||||
fieldStats.hasOwnProperty(timeFieldName) &&
|
||||
Object.hasOwn(fieldStats, timeFieldName) &&
|
||||
fieldStats[timeFieldName].earliest !== undefined &&
|
||||
fieldStats[timeFieldName].latest !== undefined
|
||||
) {
|
||||
|
|
|
@ -58,7 +58,7 @@ export function readFile(file: File) {
|
|||
export function createUrlOverrides(overrides: InputOverrides, originalSettings: InputOverrides) {
|
||||
const formattedOverrides: InputOverrides = {};
|
||||
for (const o in overrideDefaults) {
|
||||
if (overrideDefaults.hasOwnProperty(o)) {
|
||||
if (Object.hasOwn(overrideDefaults, o)) {
|
||||
let value = overrides[o];
|
||||
if (
|
||||
(Array.isArray(value) && isEqual(value, originalSettings[o])) ||
|
||||
|
|
|
@ -354,7 +354,7 @@ export function useOverallStats<TParams extends OverallStatsSearchStrategyParams
|
|||
if (sampledNonAggregatableFieldsExamples) {
|
||||
sampledNonAggregatableFieldsExamples.forEach((doc) => {
|
||||
nonAggregatableFields.forEach((field, fieldIdx) => {
|
||||
if (doc.hasOwnProperty(field)) {
|
||||
if (Object.hasOwn(doc, field)) {
|
||||
nonAggregatableFieldsCount[fieldIdx] += 1;
|
||||
nonAggregatableFieldsUniqueCount[fieldIdx].add(doc[field]!);
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ const DataVisualizerStateContextProvider: FC<DataVisualizerStateContextProviderP
|
|||
const urlState = parseUrlState(prevSearchString);
|
||||
const parsedQueryString = parse(prevSearchString, { sort: false });
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(urlState, accessor)) {
|
||||
if (!Object.hasOwn(urlState, accessor)) {
|
||||
urlState[accessor] = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ export const checkAggregatableFieldsExistRequest = (
|
|||
|
||||
if (supportedAggs.has('cardinality')) {
|
||||
let cardinalityField: AggCardinality;
|
||||
if (datafeedConfig?.script_fields?.hasOwnProperty(field)) {
|
||||
if (Object.hasOwn(datafeedConfig?.script_fields ?? {}, field)) {
|
||||
cardinalityField = aggs[`${safeFieldName}_cardinality`] = {
|
||||
cardinality: { script: datafeedConfig?.script_fields[field].script },
|
||||
cardinality: { script: datafeedConfig?.script_fields![field].script },
|
||||
};
|
||||
} else {
|
||||
cardinalityField = {
|
||||
|
@ -120,7 +120,7 @@ export function isNonAggregatableSampledDocs(
|
|||
): arg is IKibanaSearchResponse<estypes.SearchResponse<unknown>> {
|
||||
return (
|
||||
isPopulatedObject(arg, ['rawResponse']) &&
|
||||
(arg.rawResponse as estypes.SearchResponse).hasOwnProperty('hits')
|
||||
Object.hasOwn(arg.rawResponse as estypes.SearchResponse, 'hits')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ export const processAggregatableFieldsExistResponse = (
|
|||
});
|
||||
} else {
|
||||
if (
|
||||
datafeedConfig?.script_fields?.hasOwnProperty(field) ||
|
||||
datafeedConfig?.runtime_mappings?.hasOwnProperty(field)
|
||||
Object.hasOwn(datafeedConfig?.script_fields ?? {}, field) ||
|
||||
Object.hasOwn(datafeedConfig?.runtime_mappings ?? {}, field)
|
||||
) {
|
||||
const cardinality = get(aggregations, [
|
||||
...aggsPath,
|
||||
|
|
|
@ -110,7 +110,7 @@ export function getEsQueryFromSavedSearch({
|
|||
if (Array.isArray(savedQuery.bool.filter) && timeField !== undefined) {
|
||||
savedQuery.bool.filter = savedQuery.bool.filter.filter(
|
||||
(c: QueryDslQueryContainer) =>
|
||||
!(c.hasOwnProperty('range') && c.range?.hasOwnProperty(timeField))
|
||||
!(Object.hasOwn(c, 'range') && Object.hasOwn(c.range ?? {}, timeField))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export const convertToResultFormat = (document: CurationResult): SearchResult =>
|
|||
// Convert `key: 'value'` into `key: { raw: 'value' }`
|
||||
const result = Object.entries(document).reduce((acc, [key, value]) => {
|
||||
acc[key] =
|
||||
isNestedObject(value) || Object.prototype.hasOwnProperty.call(value, 'raw')
|
||||
isNestedObject(value) || (typeof value === 'object' && Object.hasOwn(value, 'raw'))
|
||||
? value
|
||||
: { raw: value };
|
||||
return acc;
|
||||
|
|
|
@ -282,7 +282,7 @@ const updateSuggestion = async (
|
|||
}
|
||||
);
|
||||
|
||||
if (response.results[0].hasOwnProperty('error')) {
|
||||
if (Object.hasOwn(response.results[0], 'error')) {
|
||||
throw new Error((response.results[0] as APIResponseError).error);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ export const IgnoredQueriesLogic = kea<MakeLogicType<IgnoredQueriesValues, Ignor
|
|||
]),
|
||||
});
|
||||
|
||||
if (response.results[0].hasOwnProperty('error')) {
|
||||
if (Object.hasOwn(response.results[0], 'error')) {
|
||||
throw (response.results[0] as SuggestionUpdateError).error;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ const toArray = <T>(v: T | T[]): T[] => (Array.isArray(v) ? v : [v]);
|
|||
const toString = <T>(v1: T) => String(v1);
|
||||
|
||||
const normalizeBoostValue = (boost: RawBoost): Boost => {
|
||||
if (!boost.hasOwnProperty('value')) {
|
||||
if (!Object.hasOwn(boost, 'value')) {
|
||||
// Can't simply do `return boost` here as TS can't infer the correct type
|
||||
return omit(boost, 'value');
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ export const ResultSettingsLogic = kea<MakeLogicType<ResultSettingsValues, Resul
|
|||
resetAllFields: (resultFields) => resetAllFields(resultFields),
|
||||
// @ts-expect-error upgrade typescript v5.1.6
|
||||
updateField: (resultFields, { fieldName, settings }) =>
|
||||
resultFields.hasOwnProperty(fieldName)
|
||||
Object.hasOwn(resultFields, fieldName)
|
||||
? { ...resultFields, [fieldName]: settings }
|
||||
: resultFields,
|
||||
},
|
||||
|
|
|
@ -140,7 +140,7 @@ export const SchemaLogic = kea<MakeLogicType<SchemaValues, SchemaActions>>({
|
|||
},
|
||||
listeners: ({ actions, values }) => ({
|
||||
addSchemaField: ({ fieldName, fieldType }) => {
|
||||
if (values.schema.hasOwnProperty(fieldName)) {
|
||||
if (Object.hasOwn(values.schema, fieldName)) {
|
||||
setErrorMessage(ADD_SCHEMA_ERROR(fieldName));
|
||||
actions.closeModal();
|
||||
} else {
|
||||
|
|
|
@ -49,7 +49,7 @@ export const getIndex = (result: SearchResult): string => {
|
|||
|
||||
export const isFieldValue = (value: unknown): value is FieldValue => {
|
||||
if (value === null || typeof value !== 'object') return false;
|
||||
return value.hasOwnProperty('raw') || value.hasOwnProperty('snippet');
|
||||
return Object.hasOwn(value, 'raw') || Object.hasOwn(value, 'snippet');
|
||||
};
|
||||
|
||||
export const flattenObjectPreservingValues = (
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue