Skip to content

Commit 98e2416

Browse files
authored
feat(typescript): prevent duplicate exports (#289)
* feat(typescript): prevent duplicate exports * v0.0.0 * feat: preventing duplicate exports * feat: fix package bundle * fix: fix yarn.lock * feat: github workflow for namespace checking
1 parent 7a76cda commit 98e2416

File tree

65 files changed

+3122
-2590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3122
-2590
lines changed

.eslintrc.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@ module.exports = {
1515
"airbnb-typescript",
1616
"plugin:sonarjs/recommended",
1717
"plugin:jest-playwright/recommended",
18-
"plugin:prettier/recommended",
1918
"plugin:storybook/recommended",
19+
"plugin:prettier/recommended",
20+
],
21+
// this is to disable
22+
// no-unused-var, no-extraneous-dependencies and prettier
23+
// rules in all ComponentName.namespace.tsx files
24+
overrides: [
25+
{
26+
files: ["src/core/**/*.namespace-test.tsx"],
27+
rules: {
28+
"@typescript-eslint/no-unused-vars": "off",
29+
"import/no-extraneous-dependencies": "off",
30+
"prettier/prettier": "off",
31+
},
32+
},
2033
],
2134
parser: "@typescript-eslint/parser",
2235
parserOptions: {

.github/workflows/namespace-check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# .github/workflows/namespace-check.yml
2+
3+
name: "Namespace Check"
4+
on: push
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Get yarn cache directory path
10+
id: yarn-cache-dir-path
11+
run: echo "::set-output name=dir::$(yarn cache dir)"
12+
13+
- uses: actions/checkout@v2
14+
- uses: bahmutov/npm-install@v1
15+
16+
- name: Namespace Checking
17+
run: yarn namespace-check

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typings/
6363
.node_repl_history
6464

6565
# Output of 'npm pack'
66-
*.tgz
66+
# *.tgz
6767

6868
# Yarn Integrity file
6969
.yarn-integrity

czifui-v0.0.26.tgz

175 KB
Binary file not shown.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "czifui",
3-
"version": "0.0.0-development",
3+
"version": "0.0.26",
44
"main": "dist/index.cjs.js",
55
"module": "dist/index.esm.js",
66
"repository": {
@@ -48,6 +48,7 @@
4848
"concurrently": "^6.0.0",
4949
"css-font": "^1.2.0",
5050
"cz-conventional-changelog": "^3.3.0",
51+
"czifui": "file:czifui-v0.0.26.tgz",
5152
"eslint": "^7.32.0",
5253
"eslint-config-airbnb-typescript": "^12.3.1",
5354
"eslint-config-prettier": "^8.1.0",
@@ -110,7 +111,11 @@
110111
"ci": "yarn install --frozen-lockfile",
111112
"test": "jest",
112113
"sd-build": "yarn style-dictionary build --config src/common/styles-dictionary/config.js",
113-
"chromatic": "npx chromatic --exit-zero-on-changes --project-token=cad4aacbfeba"
114+
"chromatic": "npx chromatic --exit-zero-on-changes --project-token=cad4aacbfeba",
115+
"build-and-pack-a-new-version": "yarn build && yarn version --no-git-tag-version --patch && yarn pack",
116+
"install-czifui-locally": "yarn add -D file:\"czifui-v$npm_package_version.tgz\"",
117+
"prenamespace-check": "rm czifui-*.tgz && yarn remove czifui && yarn build-and-pack-a-new-version && yarn install-czifui-locally",
118+
"namespace-check": "tsc --p tsconfig-namespace-check.json --noEmit"
114119
},
115120
"lint-staged": {
116121
"*.{js,jsx,ts,tsx,md,html,css,yml}": "npx prettier --write"
@@ -137,6 +142,5 @@
137142
"commitizen": {
138143
"path": "./node_modules/cz-conventional-changelog"
139144
}
140-
},
141-
"dependencies": {}
145+
}
142146
}

src/common/styles-dictionary/css/variables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Do not edit directly
3-
* Generated on Fri, 12 Aug 2022 21:49:52 GMT
3+
* Generated on Thu, 24 Nov 2022 06:48:00 GMT
44
*/
55

66
:root {

src/common/styles-dictionary/scss/_variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
// Do not edit directly
3-
// Generated on Fri, 12 Aug 2022 21:49:52 GMT
3+
// Generated on Thu, 24 Nov 2022 06:48:00 GMT
44

55
$sds-font-letter-spacing-default: 0.3px;
66
$sds-font-letter-spacing-caps: 1px;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Accordion, AccordionProps } from "czifui";
2+
import React from "react";
3+
4+
const AccordionNameSpaceTest = (props: AccordionProps) => {
5+
return (
6+
<Accordion {...props} useDivider togglePosition="right" id="accordion-id" />
7+
);
8+
};

src/core/Accordion/index.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ function LivePreviewDemo(props: Args): JSX.Element {
9191
);
9292
}
9393

94-
const LivePreviewTemplate: Story = (args) => <LivePreviewDemo {...args} />;
94+
const LivePreviewTemplate: Story = (args: Args) => (
95+
<LivePreviewDemo {...args} />
96+
);
9597

9698
export const LivePreview = LivePreviewTemplate.bind({});
9799

src/core/Accordion/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { AccordionProps as RawAccordionProps } from "@mui/material";
22
import React from "react";
3+
import AccordionDetails from "./components/AccordionDetails";
4+
import AccordionHeader from "./components/AccordionHeader";
35
import { AccordionExtraProps, StyledAccordion } from "./style";
46

7+
export { AccordionHeader, AccordionDetails };
8+
59
export type AccordionProps = RawAccordionProps & AccordionExtraProps;
610

711
/**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Banner, BannerProps } from "czifui";
2+
import React from "react";
3+
4+
const BannerNameSpaceTest = (props: BannerProps) => {
5+
return (
6+
<Banner {...props} dismissible sdsType="primary">
7+
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nesciunt aliquid
8+
maxime soluta voluptas expedita molestias neque saepe aperiam amet enim
9+
natus placeat, tempore doloribus odio reiciendis repellat? Dolorem,
10+
voluptatem tempore.
11+
</Banner>
12+
);
13+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Button, ButtonProps } from "czifui";
2+
import React from "react";
3+
4+
const ButtonNameSpaceTest = (props: ButtonProps) => {
5+
return (
6+
<Button sdsType="primary" sdsStyle="rounded" {...props}>
7+
Button
8+
</Button>
9+
);
10+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ButtonDropdown, ButtonDropdownProps, Icon } from "czifui";
2+
import React from "react";
3+
4+
const ButtonDropdownNameSpaceTest = (props: ButtonDropdownProps) => {
5+
return (
6+
<ButtonDropdown
7+
sdsType="primary"
8+
sdsStyle="rounded"
9+
icon={<Icon sdsIcon="download" sdsSize="l" sdsType="button" />}
10+
{...props}
11+
>
12+
Button Dropdown
13+
</ButtonDropdown>
14+
);
15+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ButtonIcon, ButtonIconProps, Icon } from "czifui";
2+
import React from "react";
3+
4+
const ButtonIconNameSpaceTest = (props: ButtonIconProps) => {
5+
return (
6+
<ButtonIcon active size="large" sdsType="primary" {...props}>
7+
<Icon sdsIcon="download" sdsSize="l" sdsType="button" />
8+
</ButtonIcon>
9+
);
10+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Callout, CalloutProps, CalloutTitle } from "czifui";
2+
import React from "react";
3+
4+
const CalloutNameSpaceTest = (props: CalloutProps) => {
5+
return (
6+
<Callout {...props} autoDismiss intent="info" dismissed>
7+
<CalloutTitle>Title</CalloutTitle>
8+
This is a callout!
9+
</Callout>
10+
);
11+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { CellBasic, CellBasicProps, Icon } from "czifui";
2+
import React from "react";
3+
4+
const CellBasicNameSpaceTest = (props: CellBasicProps) => {
5+
return (
6+
<table>
7+
<tbody>
8+
<tr>
9+
<CellBasic
10+
horizontalAlign="center"
11+
verticalAlign="center"
12+
icon={<Icon sdsIcon="download" sdsSize="l" sdsType="button" />}
13+
iconVerticalAlign="center"
14+
primaryText="Primary Text"
15+
primaryTextWrapLineCount={2}
16+
secondaryText="Secondary Text"
17+
secondaryTextWrapLineCount={1}
18+
tertiaryText="Tertiary Text"
19+
tertiaryTextWrapLineCount={1}
20+
shouldShowTooltipOnHover
21+
tooltipProps={{ sdsStyle: "light" }}
22+
shouldTextWrap
23+
/>
24+
</tr>
25+
</tbody>
26+
</table>
27+
);
28+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { CellComponent, CellComponentProps, Icon } from "czifui";
2+
import React from "react";
3+
4+
const CellBasicNameSpaceTest = (props: CellComponentProps) => {
5+
return (
6+
<table>
7+
<tbody>
8+
<tr>
9+
<CellComponent horizontalAlign="center" verticalAlign="center">
10+
<Icon sdsIcon="download" sdsSize="l" sdsType="button" />
11+
</CellComponent>
12+
</tr>
13+
</tbody>
14+
</table>
15+
);
16+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { CellHeader, CellHeaderProps } from "czifui";
2+
import React from "react";
3+
import { noop } from "src/common/utils";
4+
5+
const CellBasicNameSpaceTest = (props: CellHeaderProps) => {
6+
return (
7+
<table>
8+
<tbody>
9+
<tr>
10+
<CellHeader
11+
onClick={noop}
12+
direction="asc"
13+
active
14+
hideSortIcon
15+
horizontalAlign="center"
16+
shouldShowTooltipOnHover
17+
tooltipProps={{ sdsStyle: "light" }}
18+
tooltipText="Tooltip"
19+
>
20+
Header
21+
</CellHeader>
22+
</tr>
23+
</tbody>
24+
</table>
25+
);
26+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ComplexFilter, ComplexFilterProps } from "czifui";
2+
import React from "react";
3+
import { noop } from "src/common/utils";
4+
5+
const OPTIONS = [
6+
{
7+
color: "#7057ff",
8+
description: "Good for newcomers",
9+
name: "good first issue",
10+
},
11+
{
12+
color: "#008672",
13+
description: "Extra attention is needed",
14+
name: "help wanted",
15+
},
16+
];
17+
18+
const ComplexFilterNameSpaceTest = (props: ComplexFilterProps<true>) => {
19+
return (
20+
<ComplexFilter
21+
label="Click Target"
22+
onChange={noop}
23+
multiple
24+
search
25+
options={OPTIONS}
26+
isTriggerChangeOnOptionClick
27+
/>
28+
);
29+
};

src/core/ComplexFilter/components/Chips/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ interface Props {
88
onDelete: (option: DefaultDropdownMenuOption) => void;
99
}
1010

11-
export default function Chips({
11+
const Chips = ({
1212
value,
1313
multiple = false,
1414
onDelete,
15-
}: Props): JSX.Element | null {
15+
}: Props): JSX.Element | null => {
1616
if (!value) return null;
1717

1818
if (!multiple) {
@@ -32,4 +32,6 @@ export default function Chips({
3232
})}
3333
</>
3434
);
35-
}
35+
};
36+
37+
export default Chips;

src/core/ComplexFilter/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export {
1717
StyledPopper as ComplexFilterPopper,
1818
InputDropdown as ComplexFilterInputDropdown,
1919
};
20-
interface ComplexFilterProps<Multiple> {
20+
export interface ComplexFilterProps<Multiple> {
2121
label: string;
2222
options: DefaultDropdownMenuOption[];
2323
multiple?: Multiple;
@@ -34,9 +34,7 @@ interface ComplexFilterProps<Multiple> {
3434
}
3535

3636
// eslint-disable-next-line sonarjs/cognitive-complexity
37-
export default function ComplexFilter<
38-
Multiple extends boolean | undefined = false
39-
>({
37+
const ComplexFilter = <Multiple extends boolean | undefined = false>({
4038
options,
4139
label = "",
4240
multiple = false,
@@ -49,7 +47,7 @@ export default function ComplexFilter<
4947
InputDropdownComponent = InputDropdown,
5048
isTriggerChangeOnOptionClick = false,
5149
...rest
52-
}: ComplexFilterProps<Multiple>): JSX.Element {
50+
}: ComplexFilterProps<Multiple>): JSX.Element => {
5351
const isControlled = propValue !== undefined;
5452

5553
const [open, setOpen] = useState(false);
@@ -207,4 +205,6 @@ export default function ComplexFilter<
207205
? ([] as unknown as Value<DefaultDropdownMenuOption, Multiple>)
208206
: null;
209207
}
210-
}
208+
};
209+
210+
export default ComplexFilter;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
Button,
3+
Dialog,
4+
DialogActions,
5+
DialogContent,
6+
DialogProps,
7+
DialogTitle,
8+
} from "czifui";
9+
import React from "react";
10+
import { noop } from "src/common/utils";
11+
12+
const CellBasicNameSpaceTest = (props: DialogProps) => {
13+
return (
14+
<Dialog onClose={noop} open canClickOutsideClose sdsSize="s">
15+
<DialogTitle
16+
title="Title"
17+
subtitle="Optional subtitle"
18+
onClose={noop}
19+
data-testid="dialog-title"
20+
/>
21+
<DialogContent data-testid="dialog-content">Content Module</DialogContent>
22+
<DialogActions data-testid="dialog-actions" buttonPosition="left">
23+
<Button sdsStyle="square" sdsType="primary" onClick={noop}>
24+
Primary Action
25+
</Button>
26+
<Button sdsStyle="square" sdsType="secondary" onClick={noop}>
27+
Secondary Action
28+
</Button>
29+
</DialogActions>
30+
</Dialog>
31+
);
32+
};

0 commit comments

Comments
 (0)