Skip to content

Commit dffd57a

Browse files
Bump eslint-plugin-sonarjs from 4.0.3 to 4.2.2 in /spiffworkflow-frontend (#3085)
Bumps [eslint-plugin-sonarjs](https://github.com/SonarSource/SonarJS) from 4.0.3 to 4.2.2. <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/SonarSource/SonarJS/commits">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=eslint-plugin-sonarjs&package-manager=npm_and_yarn&previous-version=4.0.3&new-version=4.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jasquat <jasquat@users.noreply.github.com>
1 parent e81488f commit dffd57a

17 files changed

Lines changed: 206 additions & 61 deletions

‎docs/how_to_guides/building_diagrams/use_user_tasks_and_forms.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ UI Schema example:
802802
```
803803

804804
The `category` option selects the typeahead data source.
805-
The `itemFormat` option controls display text using keys from returned records.
805+
The `itemFormat` option controls display text using `{key}` placeholders from returned records; a key can appear more than once.
806+
If `itemFormat` is omitted or contains no placeholders, the display text is the record serialized as JSON.
806807
The stored value is the selected record serialized as JSON.
807808
If `category` is missing, the form displays an error for that field.
808809

@@ -841,7 +842,9 @@ Below is an example JSON schema that includes the numeric range field:
841842
```
842843

843844
The object must use `min` and `max` property names.
844-
The top-level `minimum` and `maximum` values define the allowed bounds.
845+
Numbers display comma grouping in the integer part while preserving decimal digits.
846+
The top-level `minimum` and `maximum` values are displayed as helper text.
847+
To enforce bounds, set `minimum` and `maximum` on the individual `min` and `max` property schemas.
845848

846849
##### UI Schema Example
847850

@@ -855,7 +858,8 @@ The top-level `minimum` and `maximum` values define the allowed bounds.
855858

856859
##### Validation
857860

858-
This will automatically validate that the max value cannot be less than the min value.
861+
The field does not automatically validate that `max` is greater than or equal to `min`.
862+
If this comparison is required, add validation in your process before using the submitted range.
859863

860864
#### Repeating Sections in Forms
861865

‎spiffworkflow-frontend/package-lock.json‎

Lines changed: 32 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎spiffworkflow-frontend/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"eslint-plugin-prettier": "^5.5.6",
120120
"eslint-plugin-react": "^7.37.5",
121121
"eslint-plugin-react-hooks": "^7.1.1",
122-
"eslint-plugin-sonarjs": "^4.0.3",
122+
"eslint-plugin-sonarjs": "^4.2.2",
123123
"eslint-plugin-unused-imports": "^4.1.4",
124124
"jsdom": "^26.1.0",
125125
"prettier": "^3.8.3",

‎spiffworkflow-frontend/src/__tests__/ProcessBreadcrumb.test.tsx‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { render, screen } from '@testing-library/react';
22
import { BrowserRouter } from 'react-router-dom';
33
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
44

5-
test('renders home link', () => {
6-
// render(
7-
// <BrowserRouter>
8-
// <ProcessBreadcrumb />
9-
// </BrowserRouter>
10-
// );
11-
// const homeElement = screen.getByText(/Process Groups/);
12-
// expect(homeElement).toBeInTheDocument();
5+
test('renders no breadcrumbs when hotCrumbs are omitted', () => {
6+
const { container } = render(
7+
<BrowserRouter>
8+
<ProcessBreadcrumb />
9+
</BrowserRouter>,
10+
);
11+
expect(container).toBeEmptyDOMElement();
1312
});
1413

1514
test('renders hotCrumbs', () => {

‎spiffworkflow-frontend/src/components/DataStoreForm.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ export default function DataStoreForm({
142142
.trim()
143143
.replace(/[^\w\s-]/g, '')
144144
.replace(/[\s-]+/g, '_')
145-
.replace(/^[-\d]+/g, '')
146-
.replace(/-+$/g, '');
145+
.replace(/^[-\d]+/g, '');
147146
};
148147

149148
const onNameChanged = (newName: any) => {

‎spiffworkflow-frontend/src/components/messages/MessageHelper.test.tsx‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import { describe, expect, it } from 'vitest';
22

3-
import { findNearestAncestorLocation } from './MessageHelper';
3+
import {
4+
findNearestAncestorLocation,
5+
trimLocationSlashes,
6+
} from './MessageHelper';
7+
8+
describe('trimLocationSlashes', () => {
9+
it.each([
10+
['', ''],
11+
['////', ''],
12+
['parent/child', 'parent/child'],
13+
['///order//residential///', 'order//residential'],
14+
[`order${'/'.repeat(10000)}`, 'order'],
15+
])('trims only surrounding slashes', (location, expected) => {
16+
expect(trimLocationSlashes(location)).toBe(expected);
17+
});
18+
});
419

520
describe('findNearestAncestorLocation', () => {
621
it('returns the nearest matching ancestor location', () => {
@@ -22,6 +37,16 @@ describe('findNearestAncestorLocation', () => {
2237
expect(nearestLocation).toBe('order/residential');
2338
});
2439

40+
it('ignores surrounding slashes and preserves the original candidate', () => {
41+
expect(
42+
findNearestAncestorLocation('///order/residential///', [
43+
'/order/',
44+
'/order/residential/',
45+
'orders',
46+
]),
47+
).toBe('/order/residential/');
48+
});
49+
2550
it('returns null when no ancestor location exists', () => {
2651
const nearestLocation = findNearestAncestorLocation('order/residential', [
2752
'shared/order',

‎spiffworkflow-frontend/src/components/messages/MessageHelper.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import { ProcessGroup } from '../../interfaces';
22

3+
export const trimLocationSlashes = (location: string) => {
4+
let start = 0;
5+
let end = location.length;
6+
while (start < end && location[start] === '/') {
7+
start += 1;
8+
}
9+
while (end > start && location[end - 1] === '/') {
10+
end -= 1;
11+
}
12+
return location.slice(start, end);
13+
};
14+
315
export const findNearestAncestorLocation = (
416
currentLocation: string,
517
candidateLocations: string[],
618
) => {
7-
const normalizedCurrentLocation = currentLocation.replace(/(^\/+|\/+$)/g, '');
19+
const normalizedCurrentLocation = trimLocationSlashes(currentLocation);
820

921
const matchingLocations = candidateLocations.filter((candidateLocation) => {
10-
const normalizedCandidate = candidateLocation.replace(/(^\/+|\/+$)/g, '');
22+
const normalizedCandidate = trimLocationSlashes(candidateLocation);
1123
return (
1224
normalizedCurrentLocation === normalizedCandidate ||
1325
normalizedCurrentLocation.startsWith(`${normalizedCandidate}/`)

‎spiffworkflow-frontend/src/components/messages/MessageModelList.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ import {
3939
import { PaginationObject, ProcessGroup } from '../../interfaces';
4040
import PaginationForTable from '../PaginationForTable';
4141
import { MessageEditor } from './MessageEditor';
42-
import { findNearestAncestorLocation } from './MessageHelper';
42+
import {
43+
findNearestAncestorLocation,
44+
trimLocationSlashes,
45+
} from './MessageHelper';
4346
import ConfirmButton from '../ConfirmButton';
4447
import useProcessGroups from '../../hooks/useProcessGroups';
4548
import { usePermissionFetcher } from '../../hooks/PermissionService';
@@ -148,7 +151,7 @@ const messageModelExists = (
148151
};
149152

150153
const processGroupLocationForSource = (sourceLocation: string) => {
151-
const normalizedSourceLocation = sourceLocation.replace(/(^\/+|\/+$)/g, '');
154+
const normalizedSourceLocation = trimLocationSlashes(sourceLocation);
152155
const pathParts = normalizedSourceLocation.split('/');
153156
if (pathParts.length <= 1) {
154157
return normalizedSourceLocation;

‎spiffworkflow-frontend/src/helpers.test.tsx‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ test('it can slugify a string', () => {
1414
);
1515
});
1616

17+
test.each([
18+
['', ''],
19+
['---', ''],
20+
['__Hello---', 'hello'],
21+
['---Hello...world___', 'hello...world'],
22+
[`${'-'.repeat(10000)}hello${'-'.repeat(10000)}`, 'hello'],
23+
])('slugifies without surrounding separators', (input, expected) => {
24+
expect(slugifyString(input)).toBe(expected);
25+
});
26+
1727
test('it can underscorize a string', () => {
1828
expect(underscorizeString('hello---world_ and then Some such-')).toEqual(
1929
'hello_world_and_then_some_such',
@@ -55,11 +65,11 @@ test('it can replace undefined values in object with null', () => {
5565
undefined,
5666
};
5767

58-
expect((sampleData.items[1] as any).contacts.zoom).toEqual(undefined);
68+
expect((sampleData.items[1] as any).contacts.zoom).toBeUndefined();
5969

6070
const result = recursivelyChangeNullAndUndefined(sampleData, null);
6171
expect(result).toEqual(sampleData);
62-
expect(result.items[1].contacts.zoom).toEqual(null);
72+
expect(result.items[1].contacts.zoom).toBeNull();
6373
expect(result.items[2]).toEqual('HEY');
6474
expect(result.contacts.awesome).toEqual(false);
6575
expect(result.contacts.info).toEqual('');
@@ -89,11 +99,11 @@ test('it can replace null values in object with undefined', () => {
8999
],
90100
};
91101

92-
expect((sampleData.items[1] as any).contacts.zoom).toEqual(null);
102+
expect((sampleData.items[1] as any).contacts.zoom).toBeNull();
93103

94104
const result = recursivelyChangeNullAndUndefined(sampleData, undefined);
95105
expect(result).toEqual(sampleData);
96-
expect(result.items[1].contacts.zoom).toEqual(undefined);
106+
expect(result.items[1].contacts.zoom).toBeUndefined();
97107
expect(result.items[2]).toEqual('HEY');
98108
expect(result.contacts.awesome).toEqual(false);
99109
expect(result.contacts.info).toEqual('');

‎spiffworkflow-frontend/src/helpers.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const slugifyString = (str: string) => {
2424
.replace(/[^\w\s.-]/g, '')
2525
.replace(/[\s_-]+/g, '-')
2626
.replace(/^-+/g, '')
27-
.replace(/-+$/g, '');
27+
.replace(/-$/, '');
2828
};
2929

3030
export const HUMAN_TASK_TYPES = [

0 commit comments

Comments
 (0)