From 797293b91ad80a38920c665fd178cd912a45dc60 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Thu, 29 Dec 2022 22:57:53 -0500 Subject: [PATCH 1/3] Build: Add extensions to lodash imports --- .ci/danger/dangerfile.ts | 2 +- code/.eslintrc.js | 1 + code/lib/manager-api/src/lib/merge.ts | 2 +- .../preview-api/src/modules/preview-web/parseArgsParam.ts | 2 +- code/lib/preview-api/src/modules/store/args.ts | 2 +- code/lib/preview-api/src/modules/store/parameters.ts | 2 +- code/lib/router/src/utils.ts | 2 +- .../src/docs/lib/defaultValues/createFromRawDefaultProp.ts | 6 +++--- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.ci/danger/dangerfile.ts b/.ci/danger/dangerfile.ts index 2891982ca1ea..59b89cae49b1 100644 --- a/.ci/danger/dangerfile.ts +++ b/.ci/danger/dangerfile.ts @@ -5,7 +5,7 @@ execSync('npm install lodash'); const flatten = require('lodash/flatten'); const intersection = require('lodash/intersection'); -const isEmpty = require('lodash/isEmpty'); +const isEmpty = require('lodash/isEmpty.js'); const pkg = require('../../code/package.json'); // eslint-disable-line import/newline-after-import const prLogConfig = pkg['pr-log']; diff --git a/code/.eslintrc.js b/code/.eslintrc.js index 90b897bd4148..cc597d89aa4e 100644 --- a/code/.eslintrc.js +++ b/code/.eslintrc.js @@ -12,6 +12,7 @@ module.exports = { rules: { 'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], 'react-hooks/rules-of-hooks': 'off', + 'import/extensions': 'off', // for mjs, we sometimes need extensions 'jest/no-done-callback': 'off', '@typescript-eslint/dot-notation': [ 'error', diff --git a/code/lib/manager-api/src/lib/merge.ts b/code/lib/manager-api/src/lib/merge.ts index 2568e7a3d497..4352cfa91db8 100644 --- a/code/lib/manager-api/src/lib/merge.ts +++ b/code/lib/manager-api/src/lib/merge.ts @@ -1,5 +1,5 @@ import mergeWith from 'lodash/mergeWith'; -import isEqual from 'lodash/isEqual'; +import isEqual from 'lodash/isEqual.js'; import { logger } from '@storybook/client-logger'; diff --git a/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts b/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts index 2e9bff64b2d8..7f16d6c14aed 100644 --- a/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts +++ b/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts @@ -2,7 +2,7 @@ import qs from 'qs'; import { dedent } from 'ts-dedent'; import type { Args } from '@storybook/types'; import { once } from '@storybook/client-logger'; -import isPlainObject from 'lodash/isPlainObject'; +import isPlainObject from 'lodash/isPlainObject.js'; // Keep this in sync with validateArgs in router/src/utils.ts const VALIDATION_REGEXP = /^[a-zA-Z0-9 _-]*$/; diff --git a/code/lib/preview-api/src/modules/store/args.ts b/code/lib/preview-api/src/modules/store/args.ts index f04e0c978dc1..37790234dbad 100644 --- a/code/lib/preview-api/src/modules/store/args.ts +++ b/code/lib/preview-api/src/modules/store/args.ts @@ -1,7 +1,7 @@ import { dequal as deepEqual } from 'dequal'; import type { Renderer, Args, ArgTypes, InputType, SBType, StoryContext } from '@storybook/types'; import { once } from '@storybook/client-logger'; -import isPlainObject from 'lodash/isPlainObject'; +import isPlainObject from 'lodash/isPlainObject.js'; import { dedent } from 'ts-dedent'; const INCOMPATIBLE = Symbol('incompatible'); diff --git a/code/lib/preview-api/src/modules/store/parameters.ts b/code/lib/preview-api/src/modules/store/parameters.ts index b4ac9cb70186..872a0d2bd38d 100644 --- a/code/lib/preview-api/src/modules/store/parameters.ts +++ b/code/lib/preview-api/src/modules/store/parameters.ts @@ -1,6 +1,6 @@ // Utilities for handling parameters import type { Parameters } from '@storybook/types'; -import isPlainObject from 'lodash/isPlainObject'; +import isPlainObject from 'lodash/isPlainObject.js'; /** * Safely combine parameters recursively. Only copy objects when needed. diff --git a/code/lib/router/src/utils.ts b/code/lib/router/src/utils.ts index 0f0389a991bc..dc447668de39 100644 --- a/code/lib/router/src/utils.ts +++ b/code/lib/router/src/utils.ts @@ -1,6 +1,6 @@ import { once } from '@storybook/client-logger'; import { dequal as deepEqual } from 'dequal'; -import isPlainObject from 'lodash/isPlainObject'; +import isPlainObject from 'lodash/isPlainObject.js'; import memoize from 'memoizerific'; import type { IStringifyOptions } from 'qs'; import qs from 'qs'; diff --git a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts index 1283b78769f1..9ccc900a030d 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/ban-types */ -import isPlainObject from 'lodash/isPlainObject'; -import isFunction from 'lodash/isFunction'; -import isString from 'lodash/isString'; +import isPlainObject from 'lodash/isPlainObject.js'; +import isFunction from 'lodash/isFunction.js'; +import isString from 'lodash/isString.js'; import reactElementToJSXString from 'react-element-to-jsx-string'; import { type PropDef, From af349c8b8e1f0a4ef251e5bc16cfcc58e7626719 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 30 Dec 2022 12:15:08 -0500 Subject: [PATCH 2/3] Add extension to all lodash imports --- .ci/danger/dangerfile.ts | 4 ++-- code/lib/codemod/src/lib/utils.ts | 4 ++-- code/lib/core-server/src/utils/stories-json.test.ts | 4 ++-- code/lib/core-server/src/utils/stories-json.ts | 2 +- code/lib/core-server/src/utils/watch-story-specifiers.ts | 2 +- code/lib/docs-tools/src/argTypes/convert/convert.test.ts | 2 +- .../lib/docs-tools/src/argTypes/convert/proptypes/convert.ts | 2 +- code/lib/manager-api/src/index.tsx | 2 +- code/lib/manager-api/src/lib/merge.ts | 2 +- code/lib/manager-api/src/lib/stories.ts | 5 ++--- code/lib/manager-api/src/modules/layout.ts | 2 +- .../preview-api/src/modules/preview-web/PreviewWeb.test.ts | 2 +- code/lib/preview-api/src/modules/store/StoryStore.ts | 4 ++-- .../preview-api/src/modules/store/csf/normalizeInputTypes.ts | 2 +- code/lib/preview-api/src/modules/store/filterArgTypes.ts | 2 +- code/lib/preview-api/src/modules/store/inferArgTypes.ts | 2 +- code/lib/preview-api/src/modules/store/inferControls.ts | 2 +- .../src/abstract-syntax-tree/generate-helpers.js | 2 +- .../renderers/react/template/stories/js-argtypes.stories.jsx | 2 +- .../renderers/react/template/stories/ts-argtypes.stories.tsx | 2 +- code/ui/.storybook/manager.ts | 2 +- code/ui/blocks/src/blocks/ArgsTable.tsx | 2 +- code/ui/blocks/src/components/ArgsTable/ArgValue.tsx | 2 +- code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx | 2 +- code/ui/blocks/src/controls/Color.tsx | 2 +- code/ui/blocks/src/controls/Object.tsx | 2 +- code/ui/manager/src/components/layout/persist.ts | 2 +- code/ui/manager/src/components/sidebar/useExpanded.ts | 2 +- code/ui/manager/src/components/sidebar/useLastViewed.ts | 2 +- .../common/storybook-manager-render-label-stories.js.mdx | 2 +- scripts/utils/options.ts | 2 +- 31 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.ci/danger/dangerfile.ts b/.ci/danger/dangerfile.ts index 59b89cae49b1..a25402f84e4d 100644 --- a/.ci/danger/dangerfile.ts +++ b/.ci/danger/dangerfile.ts @@ -3,8 +3,8 @@ import { execSync } from 'child_process'; execSync('npm install lodash'); -const flatten = require('lodash/flatten'); -const intersection = require('lodash/intersection'); +const flatten = require('lodash/flatten.js'); +const intersection = require('lodash/intersection.js'); const isEmpty = require('lodash/isEmpty.js'); const pkg = require('../../code/package.json'); // eslint-disable-line import/newline-after-import diff --git a/code/lib/codemod/src/lib/utils.ts b/code/lib/codemod/src/lib/utils.ts index ffcd81e59900..529c87efe731 100644 --- a/code/lib/codemod/src/lib/utils.ts +++ b/code/lib/codemod/src/lib/utils.ts @@ -1,5 +1,5 @@ -import camelCase from 'lodash/camelCase'; -import upperFirst from 'lodash/upperFirst'; +import camelCase from 'lodash/camelCase.js'; +import upperFirst from 'lodash/upperFirst.js'; export const sanitizeName = (name: string) => { let key = upperFirst(camelCase(name)); diff --git a/code/lib/core-server/src/utils/stories-json.test.ts b/code/lib/core-server/src/utils/stories-json.test.ts index 5282091e189c..23acb54132e9 100644 --- a/code/lib/core-server/src/utils/stories-json.test.ts +++ b/code/lib/core-server/src/utils/stories-json.test.ts @@ -4,7 +4,7 @@ import fs from 'fs-extra'; import type { Router, Request, Response } from 'express'; import Watchpack from 'watchpack'; import path from 'path'; -import debounce from 'lodash/debounce'; +import debounce from 'lodash/debounce.js'; import { STORY_INDEX_INVALIDATED } from '@storybook/core-events'; import type { StoryIndex, StoryIndexer } from '@storybook/types'; import { loadCsf } from '@storybook/csf-tools'; @@ -899,7 +899,7 @@ describe('useStoriesJson', () => { }); it('debounces invalidation events', async () => { - (debounce as jest.Mock).mockImplementation(jest.requireActual('lodash/debounce') as any); + (debounce as jest.Mock).mockImplementation(jest.requireActual('lodash/debounce.js') as any); const mockServerChannel = { emit: jest.fn() } as any as ServerChannel; useStoriesJson({ diff --git a/code/lib/core-server/src/utils/stories-json.ts b/code/lib/core-server/src/utils/stories-json.ts index a858003397f2..81c53328b6b5 100644 --- a/code/lib/core-server/src/utils/stories-json.ts +++ b/code/lib/core-server/src/utils/stories-json.ts @@ -2,7 +2,7 @@ import type { Router, Request, Response } from 'express'; import { writeJSON } from 'fs-extra'; import type { NormalizedStoriesSpecifier, StoryIndex, StoryIndexV3 } from '@storybook/types'; -import debounce from 'lodash/debounce'; +import debounce from 'lodash/debounce.js'; import { STORY_INDEX_INVALIDATED } from '@storybook/core-events'; import type { StoryIndexGenerator } from './StoryIndexGenerator'; diff --git a/code/lib/core-server/src/utils/watch-story-specifiers.ts b/code/lib/core-server/src/utils/watch-story-specifiers.ts index fb06bdbe10fa..7b074788054c 100644 --- a/code/lib/core-server/src/utils/watch-story-specifiers.ts +++ b/code/lib/core-server/src/utils/watch-story-specifiers.ts @@ -3,7 +3,7 @@ import slash from 'slash'; import fs from 'fs'; import path from 'path'; import glob from 'globby'; -import uniq from 'lodash/uniq'; +import uniq from 'lodash/uniq.js'; import type { NormalizedStoriesSpecifier, Path } from '@storybook/types'; diff --git a/code/lib/docs-tools/src/argTypes/convert/convert.test.ts b/code/lib/docs-tools/src/argTypes/convert/convert.test.ts index c2bdc5995412..5b7b15ec6c63 100644 --- a/code/lib/docs-tools/src/argTypes/convert/convert.test.ts +++ b/code/lib/docs-tools/src/argTypes/convert/convert.test.ts @@ -1,5 +1,5 @@ import 'jest-specific-snapshot'; -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import { transformSync } from '@babel/core'; import requireFromString from 'require-from-string'; import fs from 'fs'; diff --git a/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts b/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts index 1c4b28832c43..6caa89a5d268 100644 --- a/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts +++ b/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts @@ -1,5 +1,5 @@ /* eslint-disable no-case-declarations */ -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import type { SBType } from '@storybook/types'; import type { PTType } from './types'; import { includesQuotes, trimQuotes } from '../utils'; diff --git a/code/lib/manager-api/src/index.tsx b/code/lib/manager-api/src/index.tsx index 7b8933a4b32c..d1c1096e74fc 100644 --- a/code/lib/manager-api/src/index.tsx +++ b/code/lib/manager-api/src/index.tsx @@ -9,7 +9,7 @@ import React, { useMemo, useRef, } from 'react'; -import mergeWith from 'lodash/mergeWith'; +import mergeWith from 'lodash/mergeWith.js'; import type { Args, ArgTypes, diff --git a/code/lib/manager-api/src/lib/merge.ts b/code/lib/manager-api/src/lib/merge.ts index 4352cfa91db8..8ad0c203d7bb 100644 --- a/code/lib/manager-api/src/lib/merge.ts +++ b/code/lib/manager-api/src/lib/merge.ts @@ -1,4 +1,4 @@ -import mergeWith from 'lodash/mergeWith'; +import mergeWith from 'lodash/mergeWith.js'; import isEqual from 'lodash/isEqual.js'; import { logger } from '@storybook/client-logger'; diff --git a/code/lib/manager-api/src/lib/stories.ts b/code/lib/manager-api/src/lib/stories.ts index d2e24bf0c5e0..b0f74450b7e7 100644 --- a/code/lib/manager-api/src/lib/stories.ts +++ b/code/lib/manager-api/src/lib/stories.ts @@ -1,6 +1,7 @@ import memoize from 'memoizerific'; import { dedent } from 'ts-dedent'; -import countBy from 'lodash/countBy'; +import countBy from 'lodash/countBy.js'; +import mapValues from 'lodash/mapValues.js'; import { sanitize } from '@storybook/csf'; import type { StoryId, @@ -20,8 +21,6 @@ import type { API_HashEntry, SetStoriesPayload, } from '@storybook/types'; - -import mapValues from 'lodash/mapValues'; // eslint-disable-next-line import/no-cycle import { type API, combineParameters } from '../index'; import merge from './merge'; diff --git a/code/lib/manager-api/src/modules/layout.ts b/code/lib/manager-api/src/modules/layout.ts index ec1c4394035e..e0d19a427800 100644 --- a/code/lib/manager-api/src/modules/layout.ts +++ b/code/lib/manager-api/src/modules/layout.ts @@ -1,5 +1,5 @@ import { global } from '@storybook/global'; -import pick from 'lodash/pick'; +import pick from 'lodash/pick.js'; import { dequal as deepEqual } from 'dequal'; import { create } from '@storybook/theming/create'; import { SET_CONFIG } from '@storybook/core-events'; diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts index 5fee6c1d0453..520fc07424fc 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts @@ -3,7 +3,7 @@ */ import { global } from '@storybook/global'; -import merge from 'lodash/merge'; +import merge from 'lodash/merge.js'; import { CONFIG_ERROR, CURRENT_STORY_WAS_SET, diff --git a/code/lib/preview-api/src/modules/store/StoryStore.ts b/code/lib/preview-api/src/modules/store/StoryStore.ts index 4c6da2614b15..9c036f700e68 100644 --- a/code/lib/preview-api/src/modules/store/StoryStore.ts +++ b/code/lib/preview-api/src/modules/store/StoryStore.ts @@ -21,8 +21,8 @@ import type { StoryContextForLoaders, StoryId, } from '@storybook/types'; -import mapValues from 'lodash/mapValues'; -import pick from 'lodash/pick'; +import mapValues from 'lodash/mapValues.js'; +import pick from 'lodash/pick.js'; import { SynchronousPromise } from 'synchronous-promise'; import { HooksContext } from '../addons'; diff --git a/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts b/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts index e4ca3ed23fa0..dbca9af300c2 100644 --- a/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts +++ b/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts @@ -1,4 +1,4 @@ -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import type { ArgTypes, GlobalTypes, diff --git a/code/lib/preview-api/src/modules/store/filterArgTypes.ts b/code/lib/preview-api/src/modules/store/filterArgTypes.ts index c28c2f99491f..a9deb2d11e6b 100644 --- a/code/lib/preview-api/src/modules/store/filterArgTypes.ts +++ b/code/lib/preview-api/src/modules/store/filterArgTypes.ts @@ -1,5 +1,5 @@ import type { StrictArgTypes } from '@storybook/types'; -import pickBy from 'lodash/pickBy'; +import pickBy from 'lodash/pickBy.js'; export type PropDescriptor = string[] | RegExp; diff --git a/code/lib/preview-api/src/modules/store/inferArgTypes.ts b/code/lib/preview-api/src/modules/store/inferArgTypes.ts index fab33db45862..46cd93dc9024 100644 --- a/code/lib/preview-api/src/modules/store/inferArgTypes.ts +++ b/code/lib/preview-api/src/modules/store/inferArgTypes.ts @@ -1,4 +1,4 @@ -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import { dedent } from 'ts-dedent'; import { logger } from '@storybook/client-logger'; import type { Renderer, SBType, ArgTypesEnhancer } from '@storybook/types'; diff --git a/code/lib/preview-api/src/modules/store/inferControls.ts b/code/lib/preview-api/src/modules/store/inferControls.ts index 7c645d315495..6deffa912fd7 100644 --- a/code/lib/preview-api/src/modules/store/inferControls.ts +++ b/code/lib/preview-api/src/modules/store/inferControls.ts @@ -1,4 +1,4 @@ -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import { logger } from '@storybook/client-logger'; import type { Renderer, ArgTypesEnhancer, SBEnumType, StrictInputType } from '@storybook/types'; import { filterArgTypes } from './filterArgTypes'; diff --git a/code/lib/source-loader/src/abstract-syntax-tree/generate-helpers.js b/code/lib/source-loader/src/abstract-syntax-tree/generate-helpers.js index 4a2b17ebe482..4113d084bafb 100644 --- a/code/lib/source-loader/src/abstract-syntax-tree/generate-helpers.js +++ b/code/lib/source-loader/src/abstract-syntax-tree/generate-helpers.js @@ -1,5 +1,5 @@ import { storyNameFromExport, sanitize } from '@storybook/csf'; -import mapKeys from 'lodash/mapKeys'; +import mapKeys from 'lodash/mapKeys.js'; import { patchNode } from './parse-helpers'; import getParser from './parsers'; import { diff --git a/code/renderers/react/template/stories/js-argtypes.stories.jsx b/code/renderers/react/template/stories/js-argtypes.stories.jsx index 1fc65b1ecfc0..a72d6771dbeb 100644 --- a/code/renderers/react/template/stories/js-argtypes.stories.jsx +++ b/code/renderers/react/template/stories/js-argtypes.stories.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import { PureArgsTable as ArgsTable } from '@storybook/blocks'; import { inferControls } from '@storybook/preview-api'; import { ThemeProvider, themes, convert } from '@storybook/theming'; diff --git a/code/renderers/react/template/stories/ts-argtypes.stories.tsx b/code/renderers/react/template/stories/ts-argtypes.stories.tsx index 7800e3aa7359..21eb492d30e7 100644 --- a/code/renderers/react/template/stories/ts-argtypes.stories.tsx +++ b/code/renderers/react/template/stories/ts-argtypes.stories.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import { PureArgsTable as ArgsTable } from '@storybook/blocks'; import type { Args, Parameters, StoryContext } from '@storybook/types'; import { inferControls } from '@storybook/preview-api'; diff --git a/code/ui/.storybook/manager.ts b/code/ui/.storybook/manager.ts index 047f4ba86918..1ac61cf4d375 100644 --- a/code/ui/.storybook/manager.ts +++ b/code/ui/.storybook/manager.ts @@ -1,5 +1,5 @@ import { addons } from '@storybook/manager-api'; -import startCase from 'lodash/startCase'; +import startCase from 'lodash/startCase.js'; addons.setConfig({ sidebar: { diff --git a/code/ui/blocks/src/blocks/ArgsTable.tsx b/code/ui/blocks/src/blocks/ArgsTable.tsx index c3b044855dc7..e75396f913f3 100644 --- a/code/ui/blocks/src/blocks/ArgsTable.tsx +++ b/code/ui/blocks/src/blocks/ArgsTable.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import React, { useContext, useEffect, useState, useCallback } from 'react'; -import mapValues from 'lodash/mapValues'; +import mapValues from 'lodash/mapValues.js'; import type { ArgTypesExtractor } from '@storybook/docs-tools'; import type { PropDescriptor } from '@storybook/preview-api'; import { filterArgTypes } from '@storybook/preview-api'; diff --git a/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx b/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx index 2a101f5c71e0..c4f3e3cd4343 100644 --- a/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx +++ b/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx @@ -1,7 +1,7 @@ import type { FC } from 'react'; import React, { useState } from 'react'; import memoize from 'memoizerific'; -import uniq from 'lodash/uniq'; +import uniq from 'lodash/uniq.js'; import { styled } from '@storybook/theming'; import { WithTooltipPure, Icons, SyntaxHighlighter, codeCommon } from '@storybook/components'; import type { PropSummaryValue } from './types'; diff --git a/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx b/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx index d950828b2e74..b0147faff0c4 100644 --- a/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx +++ b/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import React from 'react'; -import pickBy from 'lodash/pickBy'; +import pickBy from 'lodash/pickBy.js'; import { styled } from '@storybook/theming'; import { opacify, transparentize, darken, lighten } from 'polished'; import { includeConditionalArg } from '@storybook/csf'; diff --git a/code/ui/blocks/src/controls/Color.tsx b/code/ui/blocks/src/controls/Color.tsx index 7f63d74adeac..179b8c09e3f7 100644 --- a/code/ui/blocks/src/controls/Color.tsx +++ b/code/ui/blocks/src/controls/Color.tsx @@ -2,7 +2,7 @@ import type { FC, ChangeEvent, FocusEvent } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { HexColorPicker, HslaStringColorPicker, RgbaStringColorPicker } from 'react-colorful'; import convert from 'color-convert'; -import throttle from 'lodash/throttle'; +import throttle from 'lodash/throttle.js'; import { styled } from '@storybook/theming'; import { TooltipNote, WithTooltip, Form, Icons } from '@storybook/components'; diff --git a/code/ui/blocks/src/controls/Object.tsx b/code/ui/blocks/src/controls/Object.tsx index e82dffba166c..d1dbd5525299 100644 --- a/code/ui/blocks/src/controls/Object.tsx +++ b/code/ui/blocks/src/controls/Object.tsx @@ -1,5 +1,5 @@ import { global } from '@storybook/global'; -import cloneDeep from 'lodash/cloneDeep'; +import cloneDeep from 'lodash/cloneDeep.js'; import type { ComponentProps, SyntheticEvent, FC, FocusEvent } from 'react'; import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react'; import { styled, useTheme, type Theme } from '@storybook/theming'; diff --git a/code/ui/manager/src/components/layout/persist.ts b/code/ui/manager/src/components/layout/persist.ts index 1a304438cdfa..0f5b998cc568 100644 --- a/code/ui/manager/src/components/layout/persist.ts +++ b/code/ui/manager/src/components/layout/persist.ts @@ -1,5 +1,5 @@ import store from 'store2'; -import debounce from 'lodash/debounce'; +import debounce from 'lodash/debounce.js'; import memoize from 'memoizerific'; export { store }; diff --git a/code/ui/manager/src/components/sidebar/useExpanded.ts b/code/ui/manager/src/components/sidebar/useExpanded.ts index 1d7bd6d91ad5..854796c317f0 100644 --- a/code/ui/manager/src/components/sidebar/useExpanded.ts +++ b/code/ui/manager/src/components/sidebar/useExpanded.ts @@ -2,7 +2,7 @@ import type { StoriesHash } from '@storybook/manager-api'; import { useStorybookApi } from '@storybook/manager-api'; import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events'; import { global } from '@storybook/global'; -import throttle from 'lodash/throttle'; +import throttle from 'lodash/throttle.js'; import type { Dispatch, MutableRefObject } from 'react'; import type React from 'react'; import { useCallback, useEffect, useReducer } from 'react'; diff --git a/code/ui/manager/src/components/sidebar/useLastViewed.ts b/code/ui/manager/src/components/sidebar/useLastViewed.ts index 1fccc6a93d83..1bc8d679883a 100644 --- a/code/ui/manager/src/components/sidebar/useLastViewed.ts +++ b/code/ui/manager/src/components/sidebar/useLastViewed.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import debounce from 'lodash/debounce.js'; import { useCallback, useEffect, useMemo, useRef } from 'react'; import store from 'store2'; diff --git a/docs/snippets/common/storybook-manager-render-label-stories.js.mdx b/docs/snippets/common/storybook-manager-render-label-stories.js.mdx index cfbc658cfc03..b5ea56ba10af 100644 --- a/docs/snippets/common/storybook-manager-render-label-stories.js.mdx +++ b/docs/snippets/common/storybook-manager-render-label-stories.js.mdx @@ -3,7 +3,7 @@ import { addons } from '@storybook/manager-api'; -import startCase from 'lodash/startCase'; +import startCase from 'lodash/startCase.js'; addons.setConfig({ sidebar: { diff --git a/scripts/utils/options.ts b/scripts/utils/options.ts index 3fd36cdd6e4d..b741d80afcb2 100644 --- a/scripts/utils/options.ts +++ b/scripts/utils/options.ts @@ -7,7 +7,7 @@ import type { PromptObject, Falsy, PrevCaller, PromptType } from 'prompts'; import program from 'commander'; import dedent from 'ts-dedent'; import chalk from 'chalk'; -import kebabCase from 'lodash/kebabCase'; +import kebabCase from 'lodash/kebabCase.js'; // Option types From b8aa8fe0bc3b6bcdf5f0c2122c64adfe06d78072 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Fri, 30 Dec 2022 14:41:04 -0500 Subject: [PATCH 3/3] Remove unneeded eslint ignores --- code/frameworks/nextjs/template/stories/Image.stories.jsx | 2 +- .../nextjs/template/stories_12-js/ImageFuture.stories.jsx | 2 +- .../nextjs/template/stories_default-js/ImageLegacy.stories.jsx | 2 +- code/lib/builder-vite/src/vite-config.ts | 2 +- code/lib/cli/bin/index.js | 1 - code/renderers/web-components/src/docs/sourceDecorator.test.ts | 1 - code/renderers/web-components/src/render.ts | 2 +- code/renderers/web-components/template/components/Pre.js | 2 +- .../web-components/template/stories/demo-wc-card/DemoWcCard.js | 2 +- .../web-components/template/stories/demo-wc-card/index.js | 1 - 10 files changed, 7 insertions(+), 10 deletions(-) diff --git a/code/frameworks/nextjs/template/stories/Image.stories.jsx b/code/frameworks/nextjs/template/stories/Image.stories.jsx index 89ba6ee6eb33..c30778804dfe 100644 --- a/code/frameworks/nextjs/template/stories/Image.stories.jsx +++ b/code/frameworks/nextjs/template/stories/Image.stories.jsx @@ -1,6 +1,6 @@ import React from 'react'; import Image from 'next/image'; -// eslint-disable-next-line import/extensions + import StackAlt from '../../assets/colors.svg'; export default { diff --git a/code/frameworks/nextjs/template/stories_12-js/ImageFuture.stories.jsx b/code/frameworks/nextjs/template/stories_12-js/ImageFuture.stories.jsx index c6decea29d8a..3c65960d585d 100644 --- a/code/frameworks/nextjs/template/stories_12-js/ImageFuture.stories.jsx +++ b/code/frameworks/nextjs/template/stories_12-js/ImageFuture.stories.jsx @@ -1,6 +1,6 @@ import React from 'react'; import Image from 'next/future/image'; -// eslint-disable-next-line import/extensions + import StackAlt from '../../assets/colors.svg'; export default { diff --git a/code/frameworks/nextjs/template/stories_default-js/ImageLegacy.stories.jsx b/code/frameworks/nextjs/template/stories_default-js/ImageLegacy.stories.jsx index f110a96f6504..772536a7a5f6 100644 --- a/code/frameworks/nextjs/template/stories_default-js/ImageLegacy.stories.jsx +++ b/code/frameworks/nextjs/template/stories_default-js/ImageLegacy.stories.jsx @@ -1,6 +1,6 @@ import React from 'react'; import Image from 'next/legacy/image'; -// eslint-disable-next-line import/extensions + import StackAlt from '../../assets/colors.svg'; export default { diff --git a/code/lib/builder-vite/src/vite-config.ts b/code/lib/builder-vite/src/vite-config.ts index d9d38e96f218..0f9d99996913 100644 --- a/code/lib/builder-vite/src/vite-config.ts +++ b/code/lib/builder-vite/src/vite-config.ts @@ -96,7 +96,7 @@ export async function pluginConfig(options: ExtendedOptions) { // TODO: framework doesn't exist, should move into framework when/if built if (frameworkName === '@storybook/glimmerx-vite') { - // eslint-disable-next-line global-require, import/extensions + // eslint-disable-next-line global-require const plugin = require('vite-plugin-glimmerx/index.cjs'); plugins.push(plugin.default()); } diff --git a/code/lib/cli/bin/index.js b/code/lib/cli/bin/index.js index 9cd08c5b265e..fe4936d7d0b5 100755 --- a/code/lib/cli/bin/index.js +++ b/code/lib/cli/bin/index.js @@ -1,4 +1,3 @@ #!/usr/bin/env node -// eslint-disable-next-line import/extensions require('../dist/generate.js'); diff --git a/code/renderers/web-components/src/docs/sourceDecorator.test.ts b/code/renderers/web-components/src/docs/sourceDecorator.test.ts index e659f4f5e223..23b805609acf 100644 --- a/code/renderers/web-components/src/docs/sourceDecorator.test.ts +++ b/code/renderers/web-components/src/docs/sourceDecorator.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/extensions */ import { html } from 'lit-html'; import { styleMap } from 'lit-html/directives/style-map.js'; import { addons, useEffect } from '@storybook/preview-api'; diff --git a/code/renderers/web-components/src/render.ts b/code/renderers/web-components/src/render.ts index 350128dcd8d2..f71fd6c93875 100644 --- a/code/renderers/web-components/src/render.ts +++ b/code/renderers/web-components/src/render.ts @@ -6,7 +6,7 @@ import { global } from '@storybook/global'; import { dedent } from 'ts-dedent'; import { render as litRender } from 'lit-html'; // Keep `.js` extension to avoid issue with Webpack (related to export map?) -// eslint-disable-next-line import/extensions + import { isTemplateResult } from 'lit-html/directive-helpers.js'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-api'; import type { RenderContext, ArgsStoryFn } from '@storybook/types'; diff --git a/code/renderers/web-components/template/components/Pre.js b/code/renderers/web-components/template/components/Pre.js index 9288a551d6dd..63891db25768 100644 --- a/code/renderers/web-components/template/components/Pre.js +++ b/code/renderers/web-components/template/components/Pre.js @@ -1,6 +1,6 @@ import { global as globalThis } from '@storybook/global'; import { html, LitElement } from 'lit'; -// eslint-disable-next-line import/extensions + import { styleMap } from 'lit-html/directives/style-map.js'; const { customElements } = globalThis; diff --git a/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js b/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js index 6be796a5fa4e..89e29d06fc92 100644 --- a/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js +++ b/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js @@ -1,6 +1,6 @@ import { global } from '@storybook/global'; import { LitElement, html } from 'lit'; -// eslint-disable-next-line import/extensions + import { demoWcCardStyle } from './demoWcCardStyle.css.js'; const { CustomEvent } = global; diff --git a/code/renderers/web-components/template/stories/demo-wc-card/index.js b/code/renderers/web-components/template/stories/demo-wc-card/index.js index f7ad73d5da76..2b369f73fd43 100644 --- a/code/renderers/web-components/template/stories/demo-wc-card/index.js +++ b/code/renderers/web-components/template/stories/demo-wc-card/index.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line import/extensions import { DemoWcCard } from './DemoWcCard.js'; // eslint-disable-next-line no-undef