diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e7be2fc71..54d00be4f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,7 +5,8 @@ # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. -* @lob/growth-and-core-experience +* @lob/growth-and-core-experience +* @lob/self-serve-growth # Order is important; the last matching pattern takes the most # precedence. When someone opens a pull request that only diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 867c4061f..f21422011 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: 'CodeQL' +name: '🕵️ CodeQL' on: push: @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - language: ['javascript'] + language: ['javascript', 'typescript'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 8ecf3267b..1c1790fae 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -1,4 +1,4 @@ -name: Lint and Test +name: 🧪 Lint and Test on: push: @@ -22,7 +22,7 @@ jobs: uses: './.github/actions/install-node-and-npm' - name: Install dependencies - run: npm ci --legacy-peer-deps + run: npm ci - name: Run lint run: npm run format-check diff --git a/CHANGELOG.md b/CHANGELOG.md index 58405b0d9..353f6bf40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## v2.0.98 + +- Dependency upgrades +- Code cleanup + ## v2.0.97 - Storybook upgrade diff --git a/package-lock.json b/package-lock.json index 8823c9ef8..2f307685d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lob/ui-components", - "version": "2.0.97", + "version": "2.0.98", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lob/ui-components", - "version": "2.0.97", + "version": "2.0.98", "dependencies": { "date-fns": "^2.29.3", "date-fns-holiday-us": "^0.3.1", diff --git a/package.json b/package.json index bf09a02c2..665e54189 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lob/ui-components", - "version": "2.0.97", + "version": "2.0.98", "engines": { "node": ">=20.2.0", "npm": ">=10.2.0" diff --git a/src/components/ColorPicker/__tests__/ColorPicker.spec.ts b/src/components/ColorPicker/__tests__/ColorPicker.spec.ts index 1db9f9153..0fba98191 100644 --- a/src/components/ColorPicker/__tests__/ColorPicker.spec.ts +++ b/src/components/ColorPicker/__tests__/ColorPicker.spec.ts @@ -26,7 +26,7 @@ const renderComponent = (options: RenderOptions = {}) => describe('ColorPicker', () => { it('should render correctly', async () => { - const { baseElement, getByTestId } = renderComponent({ + const { getByTestId } = renderComponent({ props: initialProps }); diff --git a/src/components/Dropdown/Dropdown.vue b/src/components/Dropdown/Dropdown.vue index 94f25bc24..26a1a731a 100644 --- a/src/components/Dropdown/Dropdown.vue +++ b/src/components/Dropdown/Dropdown.vue @@ -135,14 +135,10 @@ import { ChevronDown } from '@/components/Icons'; import DropdownItemGroup from './DropdownItemGroup'; import DropdownItem from './DropdownItem'; -import { findLastIndex, shallowEquals } from '@/utils'; +import { shallowEquals } from '@/utils'; import LobLabel from '../Label/Label.vue'; import ConfirmChangeModal from './ConfirmChangeModal'; -if (!Array.prototype.findLastIndex) { - Array.prototype.findLastIndex = findLastIndex; //eslint-disable-line -} - const Keys = { Backspace: 'Backspace', Clear: 'Clear', diff --git a/src/components/Dropdown/__tests__/DropdownItem.spec.js b/src/components/Dropdown/__tests__/DropdownItem.spec.js index 995490f88..1dd228319 100644 --- a/src/components/Dropdown/__tests__/DropdownItem.spec.js +++ b/src/components/Dropdown/__tests__/DropdownItem.spec.js @@ -74,7 +74,7 @@ describe('DropdownItem', () => { expect(emittedEvents).toHaveProperty('click'); // eslint-disable-next-line no-unused-vars - const [event, index] = emittedEvents.click[0]; + const [_, index] = emittedEvents.click[0]; expect(index).toEqual(0); }); @@ -90,7 +90,7 @@ describe('DropdownItem', () => { expect(emittedEvents).toHaveProperty('mouseenter'); // eslint-disable-next-line no-unused-vars - const [event, index] = emittedEvents.mouseenter[0]; + const [_, index] = emittedEvents.mouseenter[0]; expect(index).toEqual(0); }); }); diff --git a/src/components/Dropdown/__tests__/DropdownItemGroup.spec.js b/src/components/Dropdown/__tests__/DropdownItemGroup.spec.js index 6166f9a82..519cc14dc 100644 --- a/src/components/Dropdown/__tests__/DropdownItemGroup.spec.js +++ b/src/components/Dropdown/__tests__/DropdownItemGroup.spec.js @@ -55,7 +55,7 @@ describe('DropdownItemGroup', () => { expect(emittedEvents).toHaveProperty('click'); // eslint-disable-next-line no-unused-vars - const [event, index] = emittedEvents.click[0]; + const [_, index] = emittedEvents.click[0]; expect(index).toEqual(0); }); @@ -71,7 +71,7 @@ describe('DropdownItemGroup', () => { expect(emittedEvents).toHaveProperty('mouseenter'); // eslint-disable-next-line no-unused-vars - const [event, index] = emittedEvents.mouseenter[0]; + const [_, index] = emittedEvents.mouseenter[0]; expect(index).toEqual(0); }); }); diff --git a/src/components/ImageFileUpload/__tests__/ImageFileUpload.spec.ts b/src/components/ImageFileUpload/__tests__/ImageFileUpload.spec.ts index 8f753e328..e4323e0be 100644 --- a/src/components/ImageFileUpload/__tests__/ImageFileUpload.spec.ts +++ b/src/components/ImageFileUpload/__tests__/ImageFileUpload.spec.ts @@ -24,7 +24,7 @@ const renderComponent = (options: RenderOptions = {}) => describe('ImageFileUpload', () => { it('should render correctly', async () => { - const { baseElement, getByTestId } = renderComponent({ + const { getByTestId } = renderComponent({ props: initialProps }); @@ -135,7 +135,7 @@ describe('ImageFileUpload', () => { }); it('should display an error when the file size exceeds the maxFileSize prop', async () => { - const { baseElement, getByRole, container, emitted } = renderComponent({ + const { getByRole, container, emitted } = renderComponent({ props: { ...initialProps, maxFileSize: 1 } }); diff --git a/src/components/TextInput/__tests__/TextInput.spec.ts b/src/components/TextInput/__tests__/TextInput.spec.ts index 6d2300c3a..e4d643484 100644 --- a/src/components/TextInput/__tests__/TextInput.spec.ts +++ b/src/components/TextInput/__tests__/TextInput.spec.ts @@ -187,7 +187,7 @@ describe('Text input', () => { }; it('the label is correctly associated with the input when the tooltip is trailing', async () => { - const { getByLabelText, getByTestId } = render(TextInput, { + const { getByLabelText } = render(TextInput, { ...DEFAULT_RENDER_OPTIONS, props: propsTooltip }); @@ -198,7 +198,7 @@ describe('Text input', () => { }); it('the label is correctly associated with the input when the tooltip is leading', () => { - const { getByLabelText, getByTestId } = render(TextInput, { + const { getByLabelText } = render(TextInput, { ...DEFAULT_RENDER_OPTIONS, props: propsTooltipLeading }); diff --git a/src/utils/__tests__/array.spec.js b/src/utils/__tests__/array.spec.js deleted file mode 100644 index ef813c2f8..000000000 --- a/src/utils/__tests__/array.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -import { findLastIndex } from '../array'; - -beforeAll(() => { - if (!Array.prototype.findLastIndex) { - Array.prototype.findLastIndex = findLastIndex; //eslint-disable-line - } -}); - -afterAll(() => { - Array.prototype.findLastIndex = undefined; //eslint-disable-line -}); - -describe('array utils', () => { - describe('findLastIndex', () => { - it("throws an error when 'this' is undefined", () => { - const subject = null; - expect(() => { - subject.findLastIndex((el) => el === 'a'); - }).toThrow(); - }); - - it('throws an error when the predicate is not a function', () => { - const subject = ['a', 'b', 'a']; - expect(() => { - subject.findLastIndex('a'); - }).toThrow(); - }); - - it('returns the index of the only element that satisfies the predicate', () => { - const subject = ['a', 'b', 'c']; - const index = subject.findLastIndex((el) => el === 'a'); - expect(index).toEqual(0); - }); - - it('returns the last index of an element that satisfies the predicate', () => { - const subject = ['a', 'b', 'a']; - const index = subject.findLastIndex((el) => el === 'a'); - expect(index).toEqual(2); - }); - - it('returns -1 if no element can be found that satisfies the predicate', () => { - const subject = ['a', 'b', 'a']; - const index = subject.findLastIndex((el) => el === 'c'); - expect(index).toEqual(-1); - }); - }); -}); diff --git a/src/utils/array.js b/src/utils/array.js index 9c690bfc1..dc661f8e2 100644 --- a/src/utils/array.js +++ b/src/utils/array.js @@ -1,36 +1,3 @@ -/** - * A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found. - * - * @callback callbackFn - * @param {Object} element The current element being processed in the array. - * @param {number} index The index of the current element being processed in the array. (optional) - * @param {Object[]} array The array findLastIndex() was called upon. - */ - -/** - * Returns the index of the last element in the array where predicate is true, and -1 - * otherwise. - * @param {callbackFn} predicate findLastIndex calls predicate once for each element of the array, in descending - * order, until it finds one where predicate returns true. If such an element is found, - * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1. - * @param {Object[]} thisArg Value to use as this when executing callbackFn. (optional) - * @return {number} The index - */ -export function findLastIndex(predicate, thisArg) { - // The callback must be a function. - if (typeof predicate !== 'function') { - throw new TypeError(); - } - - let l = this.length; - while (l--) { - if (predicate(this[l], l, thisArg)) { - return l; - } - } - return -1; -} - /** * A function that 'filters' a base array by the secondary array and returns the different elements in the base array * @param {Array} baseArray The base array