From 4903046aab8c0a596051ad0827c4bb5b9b8a3466 Mon Sep 17 00:00:00 2001 From: atanasster Date: Fri, 24 Dec 2021 22:41:10 -0500 Subject: [PATCH] chore: upgrade eslint, gatsby, next --- .eslintrc.js | 8 +- .prettierrc | 4 +- .vscode/launch.json | 2 +- core/core/src/controls-randomize.ts | 2 +- core/core/src/controls-utils.ts | 4 +- core/core/src/modules.ts | 4 +- core/instrument/README.md | 140 +- core/instrument/package.json | 2 +- .../instrument/src/babel/extract-component.ts | 8 +- core/instrument/src/babel/mdx-stories.ts | 353 +- .../src/babel/transform-ast-tree.ts | 4 +- core/instrument/src/index.ts | 6 +- core/instrument/src/misc/chached-file.ts | 9 +- core/instrument/src/misc/hashStore.ts | 4 +- core/instrument/src/misc/package-info.ts | 9 +- core/instrument/src/misc/prettify.ts | 2 +- .../extract-props-info.test.ts.snap | 14964 +++++++++++++++ .../__snapshots__/jest-tests.test.ts.snap | 476 + .../test/esm-props-info-external.test.ts | 6 +- core/instrument/test/esm-toggle.test.ts | 3 +- .../test/extract-props-info.test.ts | 15746 +--------------- core/instrument/test/jest-tests.test.ts | 361 +- core/instrument/test/package-info.test.ts | 6 +- core/jest-extract/src/run-tests.ts | 10 +- .../run-related/actual-react-story.test.ts | 8 +- .../run/actual-typescript-component.test.ts | 4 +- core/render/src/compose.ts | 4 +- .../src/serialization/store-local-storage.ts | 18 +- core/store/src/state/context/document.tsx | 31 +- core/store/src/state/recoil/categories.ts | 34 +- core/store/src/state/recoil/controls.tsx | 10 +- core/store/src/state/recoil/document.ts | 71 +- core/webpack-compile/tests/draft.test.ts | 6 +- core/webpack-configs/package.json | 31 +- examples/gatsby/.eslintrc.js | 48 - examples/gatsby/package.json | 2 +- examples/nextjs/.eslintrc.js | 48 - examples/nextjs/package.json | 2 +- examples/react-webpack-5/package.json | 2 +- examples/simple/next-env.d.ts | 5 +- examples/simple/package.json | 15 +- examples/starter/.eslintrc.js | 48 - examples/starter/next-env.d.ts | 5 +- examples/starter/package.json | 4 +- .../gatsby-theme-stories/package.json | 7 +- integrations/nextjs-plugin/package.json | 9 +- integrations/nextjs-plugin/src/build.ts | 70 +- .../src/webpack-build.ts | 39 +- misc/follow-imports/src/extract-exports.ts | 5 +- misc/ts-markdown/.eslintignore | 1 - misc/ts-markdown/CHANGELOG.md | 92 - misc/ts-markdown/LICENSE.md | 21 - misc/ts-markdown/README.md | 17 - misc/ts-markdown/bin/index.js | 3 - misc/ts-markdown/package.json | 58 - misc/ts-markdown/rollup.config.js | 5 - misc/ts-markdown/src/blocks/props-table.ts | 85 - misc/ts-markdown/src/common/package-info.ts | 41 - misc/ts-markdown/src/common/types.ts | 28 - misc/ts-markdown/src/common/utils.ts | 143 - misc/ts-markdown/src/index.ts | 42 - .../src/overview-sections/insert-overview.ts | 84 - .../insert-react-docgen-typescript.ts | 123 - misc/ts-markdown/src/tsdoc/extract-tsdoc.ts | 611 - misc/ts-markdown/src/tsdoc/insert-tsdoc.ts | 52 - misc/ts-markdown/tsconfig.json | 15 - package.json | 24 +- .../ComponentsCatalog/ComponentsCatalog.tsx | 32 +- .../src/context/ComponentCatalogContext.tsx | 26 +- plugins/cc-cli/src/cli/save-test-template.ts | 4 +- .../src/jest-templates/document-template.ts | 9 +- .../src/jest-templates/stories-template.ts | 9 +- plugins/cc-cli/src/store.ts | 10 +- plugins/cc-cli/src/utils.ts | 7 +- .../test/__snapshots__/cli-store.test.ts.snap | 3 +- .../data-template-bundle.test.ts.snap | 14 +- .../data-template-import.test.ts.snap | 14 +- .../__snapshots__/store-rtl-ts.test.ts.snap | 3 +- .../__snapshots__/store-rtr-ts.test.ts.snap | 3 +- .../src/stories/FigmaEmbedBlock.stories.tsx | 91 - .../FigmaEmbedBlock.stories.tsx | 9 +- .../test-renderers/test/enzyme-story.test.tsx | 10 +- .../test/__snapshots__/extends.test.ts.snap | 8 +- .../test/__snapshots__/imports.test.ts.snap | 8 +- .../__snapshots__/SidebarsPage.test.ts.snap | 22 +- .../ComponentCommits.stories.tsx | 6 +- .../ComponentContributors.tsx | 5 +- .../ComponentExternalDependencies.tsx | 13 +- .../ComponentLocalDependencies.tsx | 6 +- .../ExternalDependencies.test.ts.snap | 4 +- .../LocalDependencies.test.ts.snap | 4 +- .../__snapshots__/ComponentJSX.test.ts.snap | 4 +- .../ComponentSource.test.ts.snap | 20 +- .../src/ComponentStats/ComponentStats.tsx | 8 +- .../__snapshots__/Playground.test.ts.snap | 9 +- ui/blocks/src/PropsTable/BasePropsTable.tsx | 7 +- .../__snapshots__/PropsTable.test.ts.snap | 16 +- ui/blocks/src/Search/Search.tsx | 7 +- ui/blocks/src/Story/StoryRender.tsx | 3 + ui/blocks/src/StoryConfig/BaseStoryConfig.tsx | 9 +- ui/blocks/src/context/BlockContext.tsx | 9 +- ui/blocks/src/test/storyStore.tsx | 6 +- ui/components/src/ColorMode/ColorMode.tsx | 7 +- ui/components/src/LinkHeading/LinkHeading.tsx | 2 +- ui/components/src/LinkHeading/pageLink.ts | 2 +- .../src/Markdown/MarkdownComponents.tsx | 6 +- .../src/PanelContainer/PanelContainer.tsx | 9 +- .../__snapshots__/PanelContainer.test.ts.snap | 4 +- ui/components/src/Popover/Popover.tsx | 8 +- ui/components/src/Popover/PopoverUtils.tsx | 22 +- ui/components/src/Table/TableFilter.tsx | 21 +- ui/components/src/Table/TableGrouping.tsx | 104 +- ui/components/src/Table/TablePagination.tsx | 10 +- .../src/Tabs/__snapshots__/Tabs.test.ts.snap | 16 +- ui/components/src/TitledImage/TitledImage.tsx | 3 +- .../src/Colors/Alta/AltaColor.tsx | 7 +- .../Colors/AntdHorzColor/AntdHorzColor.tsx | 7 +- .../Colors/AntdVertColor/AntdVertColor.tsx | 7 +- .../src/Colors/AnvilColor/AnvilColor.tsx | 7 +- .../Colors/AtlassianColor/AtlassianColor.tsx | 5 +- .../src/Colors/AudiDSColor/AudiDSColor.tsx | 7 +- .../Colors/BackpackColor/BackpackColor.tsx | 7 +- .../src/Colors/BaseWebColor/BaseWebColor.tsx | 7 +- .../src/Colors/BeelineColor/BeelineColor.tsx | 7 +- .../src/Colors/BoltColor/BoltColor.tsx | 5 +- .../src/Colors/CanvasColor/CanvasColor.tsx | 7 +- .../src/Colors/CedarColor/CedarColor.tsx | 7 +- .../src/Colors/CometColor/CometColor.tsx | 5 +- .../src/Colors/DuetColor/DuetColor.tsx | 5 +- .../src/Colors/ETradeColor/ETradeColor.tsx | 5 +- .../Colors/FinastraColor/FinastraColor.tsx | 7 +- .../Colors/FishTankColor/FishTankColor.tsx | 7 +- .../src/Colors/GovUKColor/GovUKColor.tsx | 7 +- .../Colors/HelpScoutColor/HelpScoutColor.tsx | 7 +- .../src/Colors/IBMDLColor/IBMDLColor.tsx | 7 +- .../Colors/LightningColor/LightningColor.tsx | 7 +- .../src/Colors/LiquidColor/LiquidColor.tsx | 15 +- .../MorningstarColor/MorningstarColor.tsx | 7 +- .../Colors/OPatternColor/OPatternColor.tsx | 7 +- .../src/Colors/PajamasColor/PajamasColor.tsx | 5 +- .../PatternFlyColor/PatternFlyColor.tsx | 7 +- .../src/Colors/PhotonColor/PhotonColor.tsx | 5 +- .../src/Colors/PrimerColor/PrimerColor.tsx | 7 +- .../src/Colors/SeedsColor/SeedsColor.tsx | 7 +- .../src/Colors/SeekColor/SeekColor.tsx | 7 +- .../src/Colors/SkylineColor/SkylineColor.tsx | 10 +- .../src/Colors/SolidColor/SolidColor.tsx | 7 +- .../src/Colors/TableColor/TableColor.tsx | 14 +- .../src/Colors/UniformColor/UniformColor.tsx | 7 +- .../src/Colors/VanillaColor/VanillaColor.tsx | 7 +- ui/design-tokens/src/Colors/XColor/XColor.tsx | 7 +- .../src/Colors/ZendeskColor/ZendeskColor.tsx | 7 +- .../src/Fonts/LightningFont/LightningFont.tsx | 7 +- .../component-controls.test.js.snap | 266 +- ui/editors/src/FilesEditor/FilesEditor.tsx | 6 +- ui/editors/src/types.ts | 2 +- yarn.lock | 7942 ++++---- 157 files changed, 20129 insertions(+), 23093 deletions(-) create mode 100644 core/instrument/test/__snapshots__/extract-props-info.test.ts.snap create mode 100644 core/instrument/test/__snapshots__/jest-tests.test.ts.snap delete mode 100644 examples/gatsby/.eslintrc.js delete mode 100644 examples/nextjs/.eslintrc.js delete mode 100644 examples/starter/.eslintrc.js delete mode 100644 misc/ts-markdown/.eslintignore delete mode 100644 misc/ts-markdown/CHANGELOG.md delete mode 100644 misc/ts-markdown/LICENSE.md delete mode 100644 misc/ts-markdown/README.md delete mode 100755 misc/ts-markdown/bin/index.js delete mode 100644 misc/ts-markdown/package.json delete mode 100644 misc/ts-markdown/rollup.config.js delete mode 100644 misc/ts-markdown/src/blocks/props-table.ts delete mode 100644 misc/ts-markdown/src/common/package-info.ts delete mode 100644 misc/ts-markdown/src/common/types.ts delete mode 100644 misc/ts-markdown/src/common/utils.ts delete mode 100644 misc/ts-markdown/src/index.ts delete mode 100644 misc/ts-markdown/src/overview-sections/insert-overview.ts delete mode 100644 misc/ts-markdown/src/react-docgen-typescript/insert-react-docgen-typescript.ts delete mode 100644 misc/ts-markdown/src/tsdoc/extract-tsdoc.ts delete mode 100644 misc/ts-markdown/src/tsdoc/insert-tsdoc.ts delete mode 100644 misc/ts-markdown/tsconfig.json delete mode 100644 plugins/figma-api/src/stories/FigmaEmbedBlock.stories.tsx diff --git a/.eslintrc.js b/.eslintrc.js index ffb81cab5..2a8933785 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,12 @@ module.exports = { - "root": true, + root: true, extends: [ 'plugin:react/recommended', 'plugin:react-hooks/recommended', 'plugin:prettier/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:mdx/recommended', - 'prettier/@typescript-eslint', + 'prettier', ], rules: { 'comma-dangle': ['error', 'always-multiline'], @@ -31,7 +31,7 @@ module.exports = { '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-object-literal-type-assertion': 'off', '@typescript-eslint/no-parameter-properties': 'off', - "no-restricted-globals":'error', + 'no-restricted-globals': 'error', 'react-hooks/rules-of-hooks': 'off', }, parserOptions: { @@ -46,4 +46,4 @@ module.exports = { version: 'detect', }, }, -} \ No newline at end of file +}; diff --git a/.prettierrc b/.prettierrc index dc5c1e3c8..dda2105d8 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,5 +7,5 @@ "singleQuote": true, "trailingComma": "all", "bracketSpacing": true, - "jsxBracketSameLine": false -} \ No newline at end of file + "arrowParens": "avoid" +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 99db95f59..4736cb0f7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -140,7 +140,7 @@ "name": "jest instrument", "program": "${workspaceFolder}/node_modules/.bin/jest", "cwd": "${workspaceFolder}/core/instrument", - "args": ["extract-props-info"], + "args": ["jest-tests"], "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", "disableOptimisticBPs": true, diff --git a/core/core/src/controls-randomize.ts b/core/core/src/controls-randomize.ts index d385cee5d..7885c9d7a 100644 --- a/core/core/src/controls-randomize.ts +++ b/core/core/src/controls-randomize.ts @@ -116,7 +116,7 @@ export const randomizeData = (controls: ComponentControls): RandomizedData => { return { name, value: { - ...randomizeData(control.value as ComponentControls), + ...randomizeData(control.value as unknown as ComponentControls), }, }; } diff --git a/core/core/src/controls-utils.ts b/core/core/src/controls-utils.ts index 5db0a5b35..dc13697c2 100644 --- a/core/core/src/controls-utils.ts +++ b/core/core/src/controls-utils.ts @@ -219,7 +219,9 @@ export const newControlValues = ( return { name, value: { - ...newControlValues(control.value as ComponentControls), + ...newControlValues( + control.value as unknown as ComponentControls, + ), }, }; } diff --git a/core/core/src/modules.ts b/core/core/src/modules.ts index aa0389f1b..f98e074e1 100644 --- a/core/core/src/modules.ts +++ b/core/core/src/modules.ts @@ -35,9 +35,7 @@ export const dynamicRequire = (filePath: string): any => { if (config) { const tmpFolder = path.resolve( path.dirname(filePath), - createHash('md5') - .update(filePath) - .digest('hex'), + createHash('md5').update(filePath).digest('hex'), ); if (!fs.existsSync(tmpFolder)) { fs.mkdirSync(tmpFolder); diff --git a/core/instrument/README.md b/core/instrument/README.md index 114d549ad..d4620cb88 100644 --- a/core/instrument/README.md +++ b/core/instrument/README.md @@ -1,54 +1,54 @@ # Table of contents -- [Overview](#overview) -- [Installation](#installation) -- [API](#api) - - [Functions](#functions) - - [parseStories](#parsestories) - - [Default options](#default-options) - - [**defaultParserOptions**: _ParserOptions_](#defaultparseroptions-parseroptions) - - [**defaultResolveOptions**: _ResolverOptions_](#defaultresolveoptions-resolveroptions) - - [**defaultComponentOptions**: _ComponentOptions_](#defaultcomponentoptions-componentoptions) - - [**defaultStoriesOptions**: _StoriesOptions_](#defaultstoriesoptions-storiesoptions) -- [Interfaces](#interfaces) - - [InstrumentOptions](#instrumentoptions) - - [Properties](#properties) - - [InstrumentOptionsMDX](#instrumentoptionsmdx) - - [Properties](#properties-1) - - [ComponentOptions](#componentoptions) - - [Properties](#properties-2) - - [StoriesOptions](#storiesoptions) - - [Properties](#properties-3) -- [ParserOptions](#parseroptions) - - - [Properties](#properties-4) -- [PrettierOptions](#prettieroptions) - - - [Properties](#properties-5) -- [ResolvePrettierConfigOptions](#resolveprettierconfigoptions) - - - [Properties](#properties-6) -- [ResolverOptions](#resolveroptions) -- [MDXOptions](#mdxoptions) - - [PackageInfoOptions](#packageinfooptions) - - [Properties](#properties-7) - - [PropsInfoExtractor](#propsinfoextractor) - - [ComponentFileOption](#componentfileoption) - - [Arguments](#arguments) +- [Overview](#overview) +- [Installation](#installation) +- [API](#api) + - [Functions](#functions) + - [parseStories](#parsestories) + - [Default options](#default-options) + - [**defaultParserOptions**: _ParserOptions_](#defaultparseroptions-parseroptions) + - [**defaultResolveOptions**: _ResolverOptions_](#defaultresolveoptions-resolveroptions) + - [**defaultComponentOptions**: _ComponentOptions_](#defaultcomponentoptions-componentoptions) + - [**defaultStoriesOptions**: _StoriesOptions_](#defaultstoriesoptions-storiesoptions) +- [Interfaces](#interfaces) + - [InstrumentOptions](#instrumentoptions) + - [Properties](#properties) + - [InstrumentOptionsMDX](#instrumentoptionsmdx) + - [Properties](#properties-1) + - [ComponentOptions](#componentoptions) + - [Properties](#properties-2) + - [StoriesOptions](#storiesoptions) + - [Properties](#properties-3) +- [ParserOptions](#parseroptions) + - - [Properties](#properties-4) +- [PrettierOptions](#prettieroptions) + - - [Properties](#properties-5) +- [ResolvePrettierConfigOptions](#resolveprettierconfigoptions) + - - [Properties](#properties-6) +- [ResolverOptions](#resolveroptions) +- [MDXOptions](#mdxoptions) + - [PackageInfoOptions](#packageinfooptions) + - [Properties](#properties-7) + - [PropsInfoExtractor](#propsinfoextractor) + - [ComponentFileOption](#componentfileoption) + - [Arguments](#arguments) # Overview Parsing a source file will generate the following information: -- ESM: List of story named exports -- ESM: Default export stories file information -- MDX: List of `` story tags -- MDX: List of Frontammetr or `` stories file information -- Source code extracted for the stories -- Source code of the entire stories file -- List of all attributes(ie parameters) passed to ESM/MDX stories -- List of story function arguments passed to ESM/MDX stories -- Usage location (in the source code) of the function arguments -- Extract 'component' information for stories: import clause, source file, source location -- Extract package.json repository information for the stories file -- Extract package.json repository information for the components file (when the components and the stories and in different packages) +- ESM: List of story named exports +- ESM: Default export stories file information +- MDX: List of `` story tags +- MDX: List of Frontammetr or `` stories file information +- Source code extracted for the stories +- Source code of the entire stories file +- List of all attributes(ie parameters) passed to ESM/MDX stories +- List of story function arguments passed to ESM/MDX stories +- Usage location (in the source code) of the function arguments +- Extract 'component' information for stories: import clause, source file, source location +- Extract package.json repository information for the stories file +- Extract package.json repository information for the components file (when the components and the stories and in different packages) # Installation @@ -80,7 +80,7 @@ Parse and instrument a javascript, typescript or MDX file of stories **Returns:** _Promise‹Store›_ -* * * +--- ## Default options @@ -92,25 +92,25 @@ _Defined in [core/instrument/src/types.ts](https://github.com/atanasster/compone • **sourceType**: _"module"_ = "module" -* * * +--- ### **defaultResolveOptions**: _[ResolverOptions](#resolveroptions)_ • **extensions**: _string\[]_ = ['.js', '.jsx', '.ts', '.tsx', '.vue', '.mjs', '.es', '.es6'] -* * * +--- ### **defaultComponentOptions**: _[ComponentOptions](#componentoptions)_ • **sourceFiles**: _boolean_ = true; -* * * +--- ### **defaultStoriesOptions**: _[StoriesOptions](#storiesoptions)_ • **sourceFiles**: _boolean_ = false; -* * * +--- # Interfaces @@ -132,7 +132,7 @@ Options for extracting component information. • **extractPropsFn**? : _[PropsInfoExtractor](#propsinfoextractor)_ - optional module to extract prop tables information for components +optional module to extract prop tables information for components • **parser**? : _[ParserOptions](#parseroptions)_ @@ -148,7 +148,7 @@ passing a value of false as prettier option will disabled prettifying Options to control resolving filenames. -* * * +--- ## InstrumentOptionsMDX @@ -160,7 +160,7 @@ extends [InstrumentOptions](#instrumentoptions)) and adds options for `mdx-js`. Options for mdx-js compiling -* * * +--- ## ComponentOptions @@ -172,7 +172,7 @@ _Defined in [core/instrument/src/types.ts](https://github.com/atanasster/compone • **resolveFile**? : _undefined | `(componentName: string, filePath: string) => string | undefined;`_ -Callback function to resolve the source file name of a component. +Callback function to resolve the source file name of a component. Return false if this file should not be processed. • **sourceFiles**? : _boolean_ @@ -183,7 +183,7 @@ If set to false, will not save the component's source file. Otions for extracting repository information from the component's package,json file. -* * * +--- ## StoriesOptions @@ -201,7 +201,7 @@ If set to false, will not save the stories's source file, only the source of eac Options for extracting repository information from the component's package,json file. -* * * +--- # ParserOptions @@ -276,7 +276,7 @@ Defaults to true if sourceType === 'module'. Otherwise, false. Adds all parsed tokens to a tokens property on the File node. -* * * +--- # PrettierOptions @@ -313,10 +313,6 @@ the file has been formatted with prettier. This works well when used in tandem w the --require-pragma option. If there is already a docblock at the top of the file then this option will add a newline to it with the @format marker. -• **jsxBracketSameLine**? : _undefined | false | true_ - -Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line. - • **jsxSingleQuote**? : _undefined | false | true_ Use single quotes in JSX. @@ -383,7 +379,7 @@ Whether or not to indent the code inside