From 376530fac597c20fa7724a13b9c5bcd40a179133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Gorej?= Date: Mon, 2 Oct 2023 14:50:28 +0200 Subject: [PATCH] refactor: use Array.prototype.at (#3208) --- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- .../src/refractor/plugins/replace-empty-element.ts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts index ca672875db..6eab1f6aba 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts @@ -1044,7 +1044,7 @@ const plugin = () => () => { if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -1069,7 +1069,7 @@ const plugin = () => () => { if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!isArrayElement(ancestor)) return undefined; diff --git a/packages/apidom-ns-json-schema-draft-4/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-json-schema-draft-4/src/refractor/plugins/replace-empty-element.ts index 7f338edf69..023f73d316 100644 --- a/packages/apidom-ns-json-schema-draft-4/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-json-schema-draft-4/src/refractor/plugins/replace-empty-element.ts @@ -192,7 +192,7 @@ const plugin = () => () => { if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -217,7 +217,7 @@ const plugin = () => () => { if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!isArrayElement(ancestor)) return undefined; diff --git a/packages/apidom-ns-json-schema-draft-6/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-json-schema-draft-6/src/refractor/plugins/replace-empty-element.ts index 08d8728365..7f61e4d6cf 100644 --- a/packages/apidom-ns-json-schema-draft-6/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-json-schema-draft-6/src/refractor/plugins/replace-empty-element.ts @@ -206,7 +206,7 @@ const plugin = () => () => { if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -231,7 +231,7 @@ const plugin = () => () => { if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!isArrayElement(ancestor)) return undefined; diff --git a/packages/apidom-ns-json-schema-draft-7/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-json-schema-draft-7/src/refractor/plugins/replace-empty-element.ts index b40cb6f7e1..f91981757c 100644 --- a/packages/apidom-ns-json-schema-draft-7/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-json-schema-draft-7/src/refractor/plugins/replace-empty-element.ts @@ -220,7 +220,7 @@ const plugin = () => () => { if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -245,7 +245,7 @@ const plugin = () => () => { if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!isArrayElement(ancestor)) return undefined; diff --git a/packages/apidom-ns-openapi-3-0/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-openapi-3-0/src/refractor/plugins/replace-empty-element.ts index 91b14931e0..8414966c69 100644 --- a/packages/apidom-ns-openapi-3-0/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-openapi-3-0/src/refractor/plugins/replace-empty-element.ts @@ -618,7 +618,7 @@ const plugin = () => () => { if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -643,7 +643,7 @@ const plugin = () => () => { if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!isArrayElement(ancestor)) return undefined; diff --git a/packages/apidom-ns-openapi-3-1/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-openapi-3-1/src/refractor/plugins/replace-empty-element.ts index 6e6d15ccaf..7615086965 100644 --- a/packages/apidom-ns-openapi-3-1/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-openapi-3-1/src/refractor/plugins/replace-empty-element.ts @@ -687,7 +687,7 @@ const plugin = if (!isEmptyElement(element.value)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore + const ancestor = ancestors.at(-1); const elementFactory = findElementFactory(ancestor, toValue(element.key)); // no element factory found @@ -712,7 +712,7 @@ const plugin = if (!isEmptyElement(element)) return undefined; const [, , , ancestors] = rest; - const ancestor = ancestors[ancestors.length - 1]; + const ancestor = ancestors.at(-1); // we're only interested in empty elements in ArrayElements if (!predicates.isArrayElement(ancestor)) return undefined;