Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: align tsconfigs #2132

Merged
merged 11 commits into from
May 21, 2024
Merged
15 changes: 14 additions & 1 deletion packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const commonRules = {
"no-underscore-dangle": "off",
"import/prefer-default-export": "off",
"no-plusplus": "off",
"react/react-in-jsx-scope": 0,
"react/react-in-jsx-scope": "error",
"react/no-danger": "error",
"react/jsx-one-expression-per-line": "off",
"react/prop-types": 0,
Expand Down Expand Up @@ -110,6 +110,19 @@ module.exports = {
"react-hooks/rules-of-hooks": "off",
"react/jsx-key": "off"
}
},
// TODO This entire block should be removed and fixed, unless we move to React 17+
{
files: [
YossiSaadi marked this conversation as resolved.
Show resolved Hide resolved
"**/__stories__/**/*.{js,jsx,ts,tsx}",
"src/storybook/stand-alone-documentaion/**/*.{js,jsx,ts,tsx}",
"src/storybook/patterns/**/*.{js,jsx,ts,tsx}",
"src/storybook/components/**/*.{js,jsx,ts,tsx}",
"src/storybook/decorators/**/*.{js,jsx,ts,tsx}"
],
rules: {
"react/react-in-jsx-scope": "off"
}
}
],
env: {
Expand Down
5 changes: 0 additions & 5 deletions packages/core/.storybook/preview.d.ts

This file was deleted.

7 changes: 3 additions & 4 deletions packages/core/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import * as VibeComponents from "../src/components/index";
import * as VibeComponents from "../src/components";
import * as VibeComponentsNext from "../src/next";
import * as VibeIcons from "../src/components/Icon/Icons/index";
import * as VibeIcons from "../src/components/Icon/Icons";
import { Preview } from "@storybook/react";
import isChromatic from "chromatic/isChromatic";
import { DocsContainer, DocsPage, Unstyled } from "@storybook/blocks";
Expand All @@ -25,7 +25,6 @@ import {
UsageGuidelines,
withMemoryStats,
RelatedComponent,
MultipleStoryElementsWrapper,
StorybookLink
} from "vibe-storybook-components";
import CanvasWrapper from "../src/storybook/components/canvas-wrapper/CanvasWrapper";
Expand Down Expand Up @@ -147,7 +146,7 @@ const preview: Preview = {
}
}
},

loaders: isChromatic() && document.fonts ? [fontLoader] : []
};

Expand Down
7 changes: 7 additions & 0 deletions packages/core/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"resolveJsonModule": true
},
"include": ["**/*.ts", "**/*.tsx", "**/*.json"]
}
2 changes: 1 addition & 1 deletion packages/core/plop/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = plop => {
},
{
type: "append",
path: "src/components/index.js",
path: "src/components/index.ts",
pattern: /(\n$)/gm,
separator: "",
template:
Expand Down
3 changes: 1 addition & 2 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ export default {
extensions: [...EXTENSIONS, ".json", ".css"]
}),
typescript({
tsconfig: path.join(ROOT_PATH, "tsconfig.esm.json"),
tsconfigOverride: {
exclude: ["**/__tests__", "**/__stories__"]
exclude: ["**/__tests__", "**/__stories__", path.join(SRC_PATH, "storybook")]
}
}),
babel({
Expand Down
2 changes: 1 addition & 1 deletion packages/core/scripts/build-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function buildComponentsTypesIndexFile() {
function buildStorybookComponentsIndexFile() {
const imports = ["import 'vibe-storybook-components/index.css';"];
const exports = ["export * from 'vibe-storybook-components'"];
convertExportsToFile(imports.concat(exports), "storybook/index.js");
convertExportsToFile(imports.concat(exports), "storybook/index.ts");
}

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import Accordion from "../../Accordion/Accordion";
import AccordionItem from "../AccordionItem";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from "react";
import React from "react";
import styles from "./AttentionBoxLink.module.scss";
import Link, { LinkProps } from "../../Link/Link";
import cx from "classnames";

const AttentionBoxLink: FC<LinkProps> = ({
const AttentionBoxLink: React.FC<LinkProps> = ({
href,
text,
// TODO: use Link's target default in next major
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import cx from "classnames";
import styles from "./StickyCategoryHeader.module.scss";
import comboboxStyles from "../../Combobox.module.scss";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import renderer from "react-test-renderer";
import Counter from "../Counter";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { render } from "@testing-library/react";
import Counter from "../Counter";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import Button from "../../Button/Button";
import styles from "./YearPicker.module.scss";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import userEvent from "@testing-library/user-event";
import { render, screen } from "@testing-library/react";
import Dialog from "../Dialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback } from "react";
import Avatar from "../../../Avatar/Avatar";
import Icon from "../../../Icon/Icon";
import { useCallback } from "react";
import styles from "./ChildrenContent.module.scss";
import { getTestId } from "../../../../tests/test-ids-utils";
import { ComponentDefaultTestId } from "../../../../tests/constants";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { act, cleanup, renderHook } from "@testing-library/react-hooks";
import userEvent from "@testing-library/user-event";
import { NavDirections } from "../../../hooks/useFullKeyboardListeners";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("All icons", () => {
});
// Make sure all icons are also exported in allIcons
if (missingIcons.length > 0) {
console.error("Missing exported icons in components/Icon/Icons/index.js", missingIcons);
console.error("Missing exported icons in components/Icon/Icons/index.ts", missingIcons);
}
expect(missingIcons).toEqual([]);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/Label/Leg.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from "react";

const Leg = () => (
<svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import Label from "../Label";
import { getTestId } from "../../../tests/test-ids-utils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from "react";
import renderer from "react-test-renderer";
import Link from "../Link";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import Link from "../Link";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { ComponentDefaultTestId, getTestId } from "../../../tests/test-ids-utils";
import cx from "classnames";
import Divider from "../../Divider/Divider";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { fireEvent, render } from "@testing-library/react";
import { act } from "@testing-library/react-hooks";
import MultiStepIndicator, { Step } from "../MultiStepIndicator";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import renderer from "react-test-renderer";
import RadioButton from "../RadioButton";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { fireEvent, render, cleanup, screen } from "@testing-library/react";
import RadioButton from "../RadioButton";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { cleanup } from "@testing-library/react-hooks";
import { fireEvent, render } from "@testing-library/react";
import { Refable } from "../Refable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from "react";
import React from "react";
import cx from "classnames";
import TipseenTitle from "./TipseenTitle";
import { VibeComponentProps } from "../../types";
Expand All @@ -13,7 +13,7 @@ export interface TipseenBasicContentProps extends VibeComponentProps {
children?: ElementContent | ElementContent[];
}

const TipseenBasicContent: FC<TipseenBasicContentProps> = ({
const TipseenBasicContent: React.FC<TipseenBasicContentProps> = ({
title,
children = null,
titleClassName,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Tipseen/TipseenImage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cx from "classnames";
import { FC } from "react";
import React from "react";
import styles from "./TipseenImage.module.scss";
import TipseenMedia from "./TipseenMedia/TipseenMedia";

Expand All @@ -12,7 +12,7 @@ export interface TipseenImageProps {
tipseenMediaClassName?: string;
}

const TipseenImage: FC<TipseenImageProps> = ({ src, alt, className, tipseenMediaClassName }) => {
const TipseenImage: React.FC<TipseenImageProps> = ({ src, alt, className, tipseenMediaClassName }) => {
return (
// TODO future breaking change where we remove the TipseenMedia component and we remove TipseenImage?
<TipseenMedia className={tipseenMediaClassName}>
Expand Down
12 changes: 12 additions & 0 deletions packages/core/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"lib": ["esnext", "dom"],
"target": "es6",
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "react",
"skipLibCheck": true,
"noImplicitAny": true,
"baseUrl": "."
}
}
6 changes: 6 additions & 0 deletions packages/core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS"
}
}
7 changes: 0 additions & 7 deletions packages/core/tsconfig.esm.json

This file was deleted.

28 changes: 9 additions & 19 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
{
"include": ["src/**/*", "types/**/*"],
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDirs": ["./src", "./.storybook"],
"lib": ["esnext", "dom"],
"allowJs": true,
"target": "es6",
"module": "CommonJS",
"sourceMap": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"declarationDir": "dist/types",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "ESNext",
"declaration": true,
"skipLibCheck": true,
"noImplicitAny": true,
"baseUrl": ".",
"declarationDir": "dist/types",
"sourceMap": true,
"allowJs": true,
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"jsx": "react-jsx",
"plugins": [{ "name": "typescript-plugin-css-modules" }],
"esModuleInterop": true
}
"plugins": [{ "name": "typescript-plugin-css-modules" }]
},
"include": ["src/**/*", "types/**/*"]
}
1 change: 1 addition & 0 deletions packages/core/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = () => {
{
loader: "ts-loader",
options: {
configFile: "tsconfig.cjs.json",
onlyCompileBundledFiles: true
}
}
Expand Down