Skip to content

Commit 3d08d03

Browse files
committed
fix: build and lint
1 parent aa1286b commit 3d08d03

File tree

34 files changed

+181
-136
lines changed

34 files changed

+181
-136
lines changed

fork/json-schema-form-core/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"noImplicitAny": false,
66
"declaration": true,
77
"target": "ES5",
8-
"module": "CommonJs"
8+
"module": "CommonJs",
9+
"moduleResolution": "node"
910
}
1011
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"start-storybook": "yarn workspace @talend/ui-storybook-one run start",
2929
"release": "yarn pre-release && yarn changeset publish",
3030
"lint-staged": "lint-staged",
31-
"lint": "cross-env WORKSPACE_RUN_FAIL=no-bail talend-yarn-workspace run lint",
31+
"lint": "cross-env WORKSPACE_RUN_FAIL=no-bail turbo run lint --continue=always",
3232
"test": "cross-env TZ=UTC talend-yarn-workspace run test",
3333
"test:update": "cross-env TZ=UTC talend-yarn-workspace run test:update",
3434
"test:cov": "cross-env TZ=UTC talend-yarn-workspace run test:cov",

packages/a11y/src/Gesture/withListGesture.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { focusOn } from './focus';
22

3-
function getAllItems(ref: HTMLElement): NodeList {
4-
const closest = ref.closest('[role="list"]');
3+
function getAllItems(ref: HTMLElement): HTMLElement[] {
4+
const closest = ref.closest<HTMLElement>('[role="list"]');
55
if (!closest) {
6-
return new NodeList();
6+
return [];
77
}
8-
return closest.querySelectorAll('[role="listitem"]');
8+
return Array.from(closest.querySelectorAll<HTMLElement>('[role="listitem"]'));
99
}
1010

11-
function getNextItem(ref: HTMLElement, loop: boolean) {
12-
let nextElement;
13-
let currentFound;
14-
let hasNext;
11+
function getNextItem(ref: HTMLElement, loop: boolean): HTMLElement | null {
12+
let nextElement: HTMLElement | null = null;
13+
let currentFound = false;
14+
let hasNext = false;
1515

1616
const nodes = getAllItems(ref);
1717
const iterator = nodes.values();
1818

19-
if (loop && ref === nodes.item(nodes.length - 1)) {
20-
return nodes.item(0);
19+
if (loop && ref === nodes[nodes.length - 1]) {
20+
return nodes[0] ?? null;
2121
}
2222

2323
do {
2424
const { value, done } = iterator.next();
2525

2626
if (currentFound) {
27-
nextElement = value;
27+
nextElement = value ?? null;
2828
hasNext = false;
2929
} else {
3030
currentFound = value === ref;
@@ -35,15 +35,15 @@ function getNextItem(ref: HTMLElement, loop: boolean) {
3535
return nextElement;
3636
}
3737

38-
function getPreviousItem(ref: HTMLElement, loop: boolean) {
39-
let previousElement;
40-
let hasNext;
38+
function getPreviousItem(ref: HTMLElement, loop: boolean): HTMLElement | null {
39+
let previousElement: HTMLElement | null = null;
40+
let hasNext = false;
4141

4242
const nodes = getAllItems(ref);
4343
const iterator = nodes.values();
4444

45-
if (loop && ref === nodes.item(0)) {
46-
return nodes.item(nodes.length - 1);
45+
if (loop && ref === nodes[0]) {
46+
return nodes[nodes.length - 1] ?? null;
4747
}
4848

4949
do {
@@ -53,7 +53,7 @@ function getPreviousItem(ref: HTMLElement, loop: boolean) {
5353
if (currentFound) {
5454
hasNext = false;
5555
} else {
56-
previousElement = value;
56+
previousElement = value ?? null;
5757
hasNext = !done;
5858
}
5959
} while (hasNext);

packages/a11y/src/Gesture/withTreeGesture.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Component, ComponentType, KeyboardEvent } from 'react';
33

44
import { focusOn } from './focus';
55

6-
function getAllItems(ref: HTMLElement) {
6+
function getAllItems(ref: HTMLElement): HTMLElement[] {
77
const nodes = ref.closest('ul[role="tree"]');
88
if (nodes) {
9-
return nodes.querySelectorAll('li[role="treeitem"]');
9+
return Array.from(nodes.querySelectorAll<HTMLElement>('li[role="treeitem"]'));
1010
}
11-
return null;
11+
return [];
1212
}
1313

1414
function getFirstItem(ref: HTMLElement): HTMLElement | null {
@@ -21,8 +21,8 @@ function getFirstItem(ref: HTMLElement): HTMLElement | null {
2121

2222
function getLastItem(ref: HTMLElement): HTMLElement | null {
2323
const nodes = getAllItems(ref);
24-
if (nodes && nodes.length > 0) {
25-
return nodes.item(nodes.length - 1) as HTMLElement;
24+
if (nodes.length > 0) {
25+
return nodes[nodes.length - 1];
2626
}
2727
return null;
2828
}
@@ -36,24 +36,21 @@ function getParentItem(ref: HTMLElement): HTMLElement | null {
3636
}
3737

3838
function getFirstChildItem(ref: HTMLElement): HTMLElement | null {
39-
return ref.querySelector('li[role="treeitem"]');
39+
return ref.querySelector<HTMLElement>('li[role="treeitem"]');
4040
}
4141

4242
function getNextItem(ref: HTMLElement): HTMLElement | null {
4343
let nextElement = null;
44-
let currentFound;
45-
let hasNext;
44+
let currentFound = false;
45+
let hasNext = false;
4646

47-
const nodes = getAllItems(ref)?.values();
48-
if (!nodes) {
49-
return nextElement;
50-
}
47+
const nodes = getAllItems(ref).values();
5148

5249
do {
5350
const { value, done } = nodes.next();
5451

5552
if (currentFound) {
56-
nextElement = value;
53+
nextElement = value ?? null;
5754
hasNext = false;
5855
} else {
5956
currentFound = value === ref;
@@ -64,14 +61,11 @@ function getNextItem(ref: HTMLElement): HTMLElement | null {
6461
return nextElement;
6562
}
6663

67-
function getPreviousItem(ref: HTMLElement) {
64+
function getPreviousItem(ref: HTMLElement): HTMLElement | null {
6865
let previousElement = null;
69-
let hasNext;
66+
let hasNext = false;
7067

71-
const nodes = getAllItems(ref)?.values();
72-
if (!nodes) {
73-
return previousElement;
74-
}
68+
const nodes = getAllItems(ref).values();
7569

7670
do {
7771
const { value, done } = nodes.next();
@@ -80,7 +74,7 @@ function getPreviousItem(ref: HTMLElement) {
8074
if (currentFound) {
8175
hasNext = false;
8276
} else {
83-
previousElement = value;
77+
previousElement = value ?? null;
8478
hasNext = !done;
8579
}
8680
} while (hasNext);

packages/a11y/tsconfig.build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["src/**/*.test.*", "src/test-setup.ts", "src/__mocks__/**"]
4+
}

packages/a11y/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"allowJs": false,
77
"declaration": true,
88
"target": "ES5",
9-
"module": "CommonJs"
9+
"module": "CommonJs",
10+
"moduleResolution": "node"
1011
}
1112
}

packages/dataviz/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"baseUrl": ".",
66
"declaration": true,
77
"module": "CommonJs",
8+
"moduleResolution": "node",
89

910
"rootDirs": ["src"],
1011
"target": "es5",

packages/design-docs/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"compilerOptions": {
1111
"baseUrl": ".",
1212
"module": "CommonJs",
13+
"moduleResolution": "node",
1314
"rootDirs": [".storybook", "src"]
1415
}
1516
}

packages/design-system/src/components/Badge/Badge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, Ref } from 'react';
1+
import { forwardRef } from 'react';
22
import { BadgeVariantType } from './primitive/BadgePrimitive';
33
import BadgeDropdown, { BadgeDropdownProps } from './variants/BadgeDropdown';
44
import BadgePopover, { BadgePopoverProps } from './variants/BadgePopover';
@@ -12,7 +12,7 @@ type BadgePopoverType = BadgeVariantType<'popover', BadgePopoverProps>;
1212

1313
export type BadgeProps = BadgeValueType | BadgeTagType | BadgeDropdownType | BadgePopoverType;
1414

15-
export const Badge = forwardRef((props: BadgeProps, ref: Ref<HTMLSpanElement>) => {
15+
export const Badge = forwardRef<HTMLSpanElement, BadgeProps>((props, ref) => {
1616
switch (props.variant) {
1717
case 'badge': {
1818
const { variant, ...rest } = props;

packages/design-system/src/components/Badge/primitive/BadgePrimitive.tsx

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Children, PropsWithChildren, Ref } from 'react';
1+
import { Children, forwardRef, PropsWithChildren } from 'react';
22

33
import classnames from 'classnames';
44
import { DataAttributes } from 'src/types';
@@ -58,49 +58,54 @@ function BadgeDivider() {
5858
export type BadgePrimitiveProps = {
5959
label: string;
6060
onClose?: () => void;
61-
ref: Ref<HTMLSpanElement>;
6261
semanticIcon?: SemanticIcon;
6362
} & Partial<DataAttributes>;
6463

65-
function BadgePrimitive({
66-
children,
67-
'data-testid': dataTestId,
68-
'data-test': dataTest,
69-
label,
70-
onClose,
71-
ref,
72-
semanticIcon = 'none',
73-
}: PropsWithChildren<BadgePrimitiveProps>) {
74-
// TODO BADGE - handle onClose to manage close button
75-
76-
// TODO BADGE - handle semanticIcon to display semantic icon
77-
78-
// TODO BADGE - implement withOperator props
79-
80-
const defaultTestId = 'badge-label';
81-
82-
return (
83-
<span className={classnames(styles.badge)} ref={ref}>
84-
<StackHorizontal
85-
gap="XXS"
86-
padding={{ top: 0, right: 'XXS', bottom: 0, left: 'XXS' }}
87-
align="center"
88-
display="inline"
89-
>
90-
<span
91-
className={classnames(styles.badge__label)}
92-
data-testid={dataTestId ? `${dataTestId}.${defaultTestId}` : defaultTestId}
93-
data-test={dataTest ? `${dataTest}.${defaultTestId}` : defaultTestId}
64+
const BadgePrimitive = forwardRef<HTMLSpanElement, PropsWithChildren<BadgePrimitiveProps>>(
65+
(
66+
{
67+
children,
68+
'data-testid': dataTestId,
69+
'data-test': dataTest,
70+
label,
71+
onClose,
72+
semanticIcon = 'none',
73+
},
74+
ref,
75+
) => {
76+
// TODO BADGE - handle onClose to manage close button
77+
78+
// TODO BADGE - handle semanticIcon to display semantic icon
79+
80+
// TODO BADGE - implement withOperator props
81+
82+
const defaultTestId = 'badge-label';
83+
84+
return (
85+
<span className={classnames(styles.badge)} ref={ref}>
86+
<StackHorizontal
87+
gap="XXS"
88+
padding={{ top: 0, right: 'XXS', bottom: 0, left: 'XXS' }}
89+
align="center"
90+
display="inline"
9491
>
95-
{label}
96-
</span>
97-
98-
{Children.count(children) > 0 && <BadgeDivider />}
99-
100-
{children}
101-
</StackHorizontal>
102-
</span>
103-
);
104-
}
92+
<span
93+
className={classnames(styles.badge__label)}
94+
data-testid={dataTestId ? `${dataTestId}.${defaultTestId}` : defaultTestId}
95+
data-test={dataTest ? `${dataTest}.${defaultTestId}` : defaultTestId}
96+
>
97+
{label}
98+
</span>
99+
100+
{Children.count(children) > 0 && <BadgeDivider />}
101+
102+
{children}
103+
</StackHorizontal>
104+
</span>
105+
);
106+
},
107+
);
108+
109+
BadgePrimitive.displayName = 'BadgePrimitive';
105110

106111
export default BadgePrimitive;

0 commit comments

Comments
 (0)