Apply updated eslint rules

This commit is contained in:
Kasper Peulen 2024-01-15 13:33:41 +01:00
parent 4997513d63
commit 021c101faf
226 changed files with 121 additions and 372 deletions

View File

@ -63,7 +63,6 @@ interface ElementsProps {
export const Elements: FC<ElementsProps> = ({ elements, type }) => (
<ol>
{elements.map((element, index) => (
// eslint-disable-next-line react/no-array-index-key
<Element element={element} key={index} type={type} />
))}
</ol>

View File

@ -27,7 +27,6 @@ function areAllRequiredElementsHighlighted(
highlighted.includes(item.target[0] as any)
).length;
// eslint-disable-next-line no-nested-ternary
return highlightedCount === 0
? CheckBoxStates.UNCHECKED
: highlightedCount === elementsToHighlight.length

View File

@ -91,7 +91,6 @@ export const Rules: FC<RulesProps> = ({ rules }) => {
return (
<List>
{rules.map((rule, index) => (
// eslint-disable-next-line react/no-array-index-key
<Rule rule={rule} key={index} />
))}
</List>

View File

@ -121,7 +121,6 @@ export const Tabs: React.FC<TabsProps> = ({ tabs }) => {
<TabsWrapper>
{tabs.map((tab, index) => (
<Item
/* eslint-disable-next-line react/no-array-index-key */
key={index}
data-index={index}
active={activeTab === index}

View File

@ -65,10 +65,8 @@ export default class ActionLogger extends Component<ActionLoggerProps, ActionLog
const actions = [...prevState.actions];
const previous = actions.length && actions[0];
if (previous && safeDeepEqual(previous.data, action.data)) {
// eslint-disable-next-line no-plusplus
previous.count++;
} else {
// eslint-disable-next-line no-param-reassign
action.count = 1;
actions.unshift(action);
}

View File

@ -71,7 +71,6 @@ export function action(name: string, options: ActionOptions = {}): HandlerFuncti
if (storyRenderer) {
const deprecated = !window?.FEATURES?.disallowImplicitActionsInRenderV8;
const error = new ImplicitActionsDuringRendering({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
phase: storyRenderer.phase!,
name,
deprecated,

View File

@ -1,2 +1 @@
// eslint-disable-next-line import/export
export * from './dist/preview';

View File

@ -523,7 +523,7 @@ describe('docs-mdx-compiler-plugin', () => {
"import { Meta, Story } from '@storybook/addon-docs';",
"import { titleFunction } from '../title-generators';",
'',
// eslint-disable-next-line no-template-curly-in-string
"<Meta title={`${titleFunction('template')}`} />",
].join('\n')
)

View File

@ -1,13 +1,16 @@
import type { PreparedStory } from '@storybook/types';
import { global } from '@storybook/global';
const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce((acc, entry) => {
const [tag, option] = entry;
if ((option as any).excludeFromDocsStories) {
acc[tag] = true;
}
return acc;
}, {} as Record<string, boolean>);
const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce(
(acc, entry) => {
const [tag, option] = entry;
if ((option as any).excludeFromDocsStories) {
acc[tag] = true;
}
return acc;
},
{} as Record<string, boolean>
);
export const parameters: any = {
docs: {

View File

@ -1,10 +1,8 @@
import { dirname, join } from 'path';
// eslint-disable-next-line import/export
export * from '@storybook/addon-docs/dist/preset';
export const mdxLoaderOptions = async (config: any) => {
// eslint-disable-next-line no-param-reassign
config.mdxCompileOptions.providerImportSource = join(
dirname(require.resolve('@storybook/addon-docs/package.json')),
'/dist/shims/mdx-react-shim'

View File

@ -1,2 +1 @@
// eslint-disable-next-line import/export
export * from '@storybook/addon-docs/dist/preview';

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { dedent } from 'ts-dedent';
import { deprecate } from '@storybook/node-logger';

View File

@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import * as React from 'react';
import { Link, Placeholder } from '@storybook/components';
import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter';
@ -103,7 +102,6 @@ export const InteractionsPanel: React.FC<InteractionsPanelProps> = React.memo(
controls={controls}
controlStates={controlStates}
status={
// eslint-disable-next-line no-nested-ternary
isPlaying ? CallStates.ACTIVE : hasException ? CallStates.ERROR : CallStates.DONE
}
storyFileName={fileName}

View File

@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import React from 'react';
import { styled, typography } from '@storybook/theming';
import { Node } from './MethodCall';

View File

@ -34,7 +34,7 @@ export const Args = () => (
<Node value="Hello world" />
<Node value="https://github.com/storybookjs/storybook/blob/next/README.md" />
<Node value="012345678901234567890123456789012345678901234567890123456789" />
{/* eslint-disable-next-line react/jsx-boolean-value */}
{}
<Node value={true} />
<Node value={false} />
<Node value={12345} />

View File

@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import { ObjectInspector } from '@devtools-ds/object-inspector';
import type { Call, CallRef, ElementRef } from '@storybook/instrumenter';
import { useTheme } from '@storybook/theming';

View File

@ -29,7 +29,7 @@ const instrumentSpies: LoaderFunction = ({ initialArgs }) => {
const instrumented = instrument({ [key]: () => value }, { retain: true })[key];
acc[key] = instrumented();
// this enhancer is being called multiple times
// eslint-disable-next-line no-param-reassign
value._instrumented = true;
return acc;
}, {} as Args);

View File

@ -79,7 +79,6 @@ export function Result(props: ResultProps) {
{isOpen ? (
<Fragment>
{failureMessages.map((msg: string, i: number) => (
// eslint-disable-next-line react/no-array-index-key
<Message msg={msg} key={i} />
))}
</Fragment>

View File

@ -23,7 +23,6 @@ function parseQuery(queryString: string) {
.split('&')
.filter(Boolean);
// eslint-disable-next-line no-plusplus
for (let i = 0; i < pairs.length; i++) {
const pair = pairs[i].split('=');
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { global } from '@storybook/global';
import invariant from 'tiny-invariant';

View File

@ -1,5 +1,3 @@
/* eslint-disable operator-assignment */
/* eslint-disable no-param-reassign */
type LabelType = 'margin' | 'padding' | 'border' | 'content';
type LabelPosition = 'top' | 'right' | 'bottom' | 'left' | 'center';
type Direction = 'top' | 'right' | 'bottom' | 'left';

View File

@ -1,4 +1,3 @@
/* eslint-disable operator-assignment */
/**
* Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7
*/

View File

@ -129,7 +129,6 @@ export const ViewportTool: FC = memo(
const [isTooltipVisible, setIsTooltipVisible] = useState(false);
if (defaultViewport && !list.find((i) => i.id === defaultViewport)) {
// eslint-disable-next-line no-console
console.warn(
`Cannot find "defaultViewport" of "${defaultViewport}" in addon-viewport configs, please check the "viewports" setting in the configuration.`
);

View File

@ -20,7 +20,7 @@ import type {
ManagerBuilder,
StarterFunction,
} from './types';
// eslint-disable-next-line import/no-cycle
import { getData } from './utils/data';
import { safeResolve } from './utils/safeResolve';
import { readOrderedFiles } from './utils/files';
@ -298,7 +298,6 @@ export const start: ManagerBuilder['start'] = async (options) => {
let result;
do {
// eslint-disable-next-line no-await-in-loop
result = await asyncIterator.next();
} while (!result.done);
@ -310,7 +309,6 @@ export const build: ManagerBuilder['build'] = async (options) => {
let result;
do {
// eslint-disable-next-line no-await-in-loop
result = await asyncIterator.next();
} while (!result.done);

View File

@ -3,7 +3,7 @@ import type { Options } from '@storybook/types';
import { getRefs } from '@storybook/core-common';
import { readTemplate } from './template';
// eslint-disable-next-line import/no-cycle
import { executor, getConfig } from '../index';
export const getData = async (options: Options) => {

View File

@ -1,5 +1,3 @@
/* eslint-disable no-param-reassign */
import * as fs from 'fs';
import type { Plugin } from 'vite';
import type { Options } from '@storybook/types';

View File

@ -12,9 +12,8 @@ function checkName(plugin: PluginOption, names: string[]) {
*/
export async function hasVitePlugins(plugins: PluginOption[], names: string[]) {
const resolvedPlugins = await Promise.all(plugins);
// eslint-disable-next-line no-restricted-syntax -- we need to await in the loop
for (const plugin of resolvedPlugins) {
// eslint-disable-next-line no-await-in-loop -- we need to await in the loop
if (Array.isArray(plugin) && Boolean(await hasVitePlugins(plugin, names))) {
return true;
}

View File

@ -10,10 +10,9 @@ export const withoutVitePlugins = async (
): Promise<PluginOption[]> => {
const result = [];
const resolvedPlugins = await Promise.all(plugins);
// eslint-disable-next-line no-restricted-syntax -- we need to await in the loop
for (const plugin of resolvedPlugins) {
if (Array.isArray(plugin)) {
// eslint-disable-next-line no-await-in-loop
result.push(await withoutVitePlugins(plugin, namesToRemove));
}
if (plugin && 'name' in plugin && !namesToRemove.includes(plugin.name)) {

View File

@ -116,7 +116,6 @@ export async function pluginConfig(options: Options) {
// TODO: framework doesn't exist, should move into framework when/if built
if (frameworkName === '@storybook/glimmerx-vite') {
// eslint-disable-next-line global-require
const plugin = require('vite-plugin-glimmerx/index.cjs');
plugins.push(plugin.default());
}

View File

@ -312,7 +312,6 @@ export const start = async (options: BuilderStartOptions) => {
let result;
do {
// eslint-disable-next-line no-await-in-loop
result = await asyncIterator.next();
} while (!result.done);
@ -324,7 +323,6 @@ export const build = async (options: BuilderStartOptions) => {
let result;
do {
// eslint-disable-next-line no-await-in-loop
result = await asyncIterator.next();
} while (!result.done);

View File

@ -7,9 +7,7 @@ const templateName = process.env.STORYBOOK_TEMPLATE_NAME || '';
test.describe('addon-actions', () => {
test('should trigger an action', async ({ page }) => {
// eslint-disable-next-line jest/no-disabled-tests
test.skip(
// eslint-disable-next-line jest/valid-title
templateName.includes('svelte') && templateName.includes('prerelease'),
'Svelte 5 prerelase does not support automatic actions with our current example components yet'
);

View File

@ -1,6 +1,3 @@
/* eslint-disable jest/valid-title */
/* eslint-disable jest/no-disabled-tests */
/* eslint-disable no-await-in-loop */
import { test, expect } from '@playwright/test';
import process from 'process';
import dedent from 'ts-dedent';

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests,jest/valid-title */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import type { Locator } from '@playwright/test';
import { test, expect } from '@playwright/test';
import process from 'process';
@ -11,7 +10,6 @@ test.describe('Next.js', () => {
// TODO: improve these E2E tests given that we have more version of Next.js to test
// and this only tests nextjs/default-js
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName?.includes('nextjs/default-js'),
'Only run this test for the Frameworks that support next/navigation'
);

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
@ -12,11 +11,7 @@ test.beforeEach(async ({ page }) => {
});
test.describe('Svelte', () => {
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName?.includes('svelte'),
'Only run this test on Svelte'
);
test.skip(!templateName?.includes('svelte'), 'Only run this test on Svelte');
test('JS story has auto-generated args table', async ({ page }) => {
const sbPage = new SbPage(page);
@ -28,7 +23,6 @@ test.describe('Svelte', () => {
});
test('TS story has auto-generated args table', async ({ page }) => {
// eslint-disable-next-line jest/valid-title
test.skip(!templateName?.endsWith('ts') || false, 'Only test TS story in TS templates');
const sbPage = new SbPage(page);
@ -66,11 +60,7 @@ test.describe('Svelte', () => {
});
test.describe('SvelteKit', () => {
test.skip(
// eslint-disable-next-line jest/valid-title
!templateName?.includes('svelte-kit'),
'Only run this test on SvelteKit'
);
test.skip(!templateName?.includes('svelte-kit'), 'Only run this test on SvelteKit');
test('Links are logged in Actions panel', async ({ page }) => {
const sbPage = new SbPage(page);

View File

@ -192,12 +192,7 @@ test.describe('Manager UI', () => {
// TODO: remove this when SSV6 templates have been removed
// Some assertions in these tests are not compatible with SSV6
// GIven that SSV6 will be removed before the new mobile UI released, it doesn't make sense to fix them
// eslint-disable-next-line jest/no-disabled-tests
test.skip(
// eslint-disable-next-line jest/valid-title
templateName?.includes('ssv6') || false,
'Skip mobile UI tests for SSV6'
);
test.skip(templateName?.includes('ssv6') || false, 'Skip mobile UI tests for SSV6');
// standard iPhone viewport size
test.use({ viewport: { width: 390, height: 844 } });

View File

@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
@ -15,7 +14,6 @@ test.describe('preview-web', () => {
test('should pass over shortcuts, but not from play functions, story', async ({ page }) => {
test.skip(
// eslint-disable-next-line jest/valid-title
/^(lit)/i.test(`${templateName}`),
`Skipping ${templateName}, which does not support addon-interactions`
);
@ -40,7 +38,6 @@ test.describe('preview-web', () => {
test('should pass over shortcuts, but not from play functions, docs', async ({ page }) => {
test.skip(
// eslint-disable-next-line jest/valid-title
/^(lit)/i.test(`${templateName}`),
`Skipping ${templateName}, which does not support addon-interactions`
);

View File

@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { toId } from '@storybook/csf';

View File

@ -35,7 +35,6 @@ vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
const mockRunScript = vi.fn();
// Randomly fails on CI. TODO: investigate why
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Build Storybook Builder', () => {
let architect: Architect;
let architectHost: TestingArchitectHost;
@ -181,7 +180,6 @@ describe.skip('Build Storybook Builder', () => {
expect(false).toEqual('Throw expected');
} catch (error) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
expect(error).toEqual(
'Broken build, fix the error above.\nYou may need to refresh the browser.'
);

View File

@ -34,7 +34,6 @@ vi.mock('@storybook/cli', () => ({
}));
// Randomly fails on CI. TODO: investigate why
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Start Storybook Builder', () => {
let architect: Architect;
let architectHost: TestingArchitectHost;
@ -161,7 +160,6 @@ describe.skip('Start Storybook Builder', () => {
expect(false).toEqual('Throw expected');
} catch (error) {
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
expect(error).toEqual(
'Broken build, fix the error above.\nYou may need to refresh the browser.'
);

View File

@ -86,7 +86,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
configDir: 'SBCONFIG_CONFIG_DIR',
ci: 'CI',
});
// eslint-disable-next-line no-param-reassign
options.port = parseInt(`${options.port}`, 10);
const {

View File

@ -70,7 +70,6 @@ export abstract class AbstractRenderer {
// platform should be set after enableProdMode()
enableProdMode();
} catch (e) {
// eslint-disable-next-line no-console
console.debug(e);
}
}
@ -181,7 +180,6 @@ export abstract class AbstractRenderer {
* Adds DOM element that angular will use as bootstrap component.
*/
protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string) {
// eslint-disable-next-line no-param-reassign
targetDOMNode.innerHTML = '';
targetDOMNode.appendChild(document.createElement(targetSelector));
}

View File

@ -379,9 +379,9 @@ describe('angular source decorator', () => {
'a single quoted string with escaped \'single quotes\'',
// eslint-disable-next-line prettier/prettier
"a double quoted string with escaped \"double quotes\"",
// eslint-disable-next-line no-useless-escape
`a string literal with \'escaped single quotes\'`,
// eslint-disable-next-line no-useless-escape
`a string literal with \"escaped double quotes\"`,
],
};

View File

@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { CommonModule } from '@angular/common';
import {
Component,

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { Type } from '@angular/core';
import { ApplicationConfig } from '@angular/platform-browser';
import { DecoratorFunction, StoryContext } from '@storybook/types';

View File

@ -1,6 +1,6 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/* eslint-disable no-console */
/* eslint-disable no-underscore-dangle */
import {
Component,

View File

@ -1,4 +1,3 @@
/* eslint-disable global-require */
// Private angular devkit stuff
const {
generateI18nBrowserWebpackConfigFromContext,

View File

@ -33,7 +33,6 @@ function loadEsmModule<T>(modulePath: string): Promise<T> {
export const runNgcc = async () => {
let ngcc: any;
try {
// eslint-disable-next-line global-require
ngcc = require('@angular/compiler-cli/ngcc');
} catch (error) {
ngcc = await loadEsmModule('@angular/compiler-cli/ngcc');

View File

@ -1,4 +1,3 @@
/* eslint-disable no-console */
/* eslint-disable no-underscore-dangle */
import {
Component,

View File

@ -20,7 +20,6 @@ export const babel: PresetPropertyFn<'babel'> = (config: TransformOptions, optio
if (e.preset && e.preset.emberOptions) {
emberOptions = e.preset.emberOptions;
if (options.presetsList) {
// eslint-disable-next-line no-param-reassign
delete options.presetsList[index].preset.emberOptions;
}
}

View File

@ -45,6 +45,6 @@ export type StorybookConfig = Omit<
StorybookConfigFramework;
declare global {
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention, no-var, vars-on-top
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention, no-var
var __EMBER_GENERATED_DOC_JSON__: any;
}

View File

@ -1,6 +1,3 @@
/* eslint-disable no-continue */
/* eslint-disable no-restricted-syntax */
import type { NodePath, PluginObj, types } from '@babel/core';
/**

View File

@ -1,6 +1,3 @@
/* eslint-disable no-nested-ternary */
/* eslint-disable no-restricted-syntax */
/**
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/babel/plugins/jsx-pragma.ts
*/

View File

@ -1,6 +1,3 @@
/* eslint-disable no-continue */
/* eslint-disable no-restricted-syntax */
/**
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/babel/plugins/next-page-config.ts
*/

View File

@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/no-loop-func */
/* eslint-disable no-plusplus */
/* eslint-disable func-names */
/* eslint-disable no-nested-ternary */
/**
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/babel/plugins/next-ssg-transform.ts
*/

View File

@ -1,7 +1,6 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable no-underscore-dangle */
/* eslint-disable func-names */
/**
* Source: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/babel/plugins/react-loadable-plugin.ts
*/

View File

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { it, expect } from 'vitest';
import { transform } from '@babel/core';
import TransformFontImports from '.';

View File

@ -2,7 +2,6 @@
// we use our own patch because we need to remove tracing from the original code
// which is not possible otherwise
/* eslint-disable no-restricted-syntax */
/*
Copyright (c) 2017 The swc Project Developers
Permission is hereby granted, free of charge, to any

View File

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import { expect } from '@storybook/jest';
import Head from 'next/head';
import React from 'react';

View File

@ -56,7 +56,6 @@ export function reactDocgen({
}
});
// eslint-disable-next-line consistent-return
return {
code: s.toString(),
map: s.generateMap(),

View File

@ -1,4 +1,3 @@
/* eslint-disable global-require */
import type { PresetProperty } from '@storybook/types';
import { dirname, join } from 'path';
import type { StorybookConfig } from './types';

View File

@ -1,5 +1,3 @@
/* eslint-disable no-param-reassign */
import { dirname, join } from 'path';
import type { PresetProperty, Options } from '@storybook/types';
import type { FrameworkOptions, StorybookConfig } from './types';

View File

@ -10,7 +10,7 @@ export default {
export const DefaultActions = {
async play({ canvasElement }) {
const canvas = within(canvasElement);
// eslint-disable-next-line no-undef
const initialUrl = window.location.toString();
const basicHref = canvas.getByText('/basic-href');
@ -21,7 +21,6 @@ export const DefaultActions = {
);
complexHref.click();
// eslint-disable-next-line no-undef
const finalUrl = window.location.toString();
expect(finalUrl).toBe(initialUrl);
},

View File

@ -10,7 +10,7 @@ export default {
export const DefaultActions = {
async play({ canvasElement }) {
const canvas = within(canvasElement);
// eslint-disable-next-line no-undef
const initialUrl = window.location.toString();
const basicHref = canvas.getByText('/basic-href');
@ -21,7 +21,6 @@ export const DefaultActions = {
);
complexHref.click();
// eslint-disable-next-line no-undef
const finalUrl = window.location.toString();
expect(finalUrl).toBe(initialUrl);
},

View File

@ -10,7 +10,7 @@ export default {
export const DefaultActions = {
async play({ canvasElement }) {
const canvas = within(canvasElement);
// eslint-disable-next-line no-undef
const initialUrl = window.location.toString();
const basicHref = canvas.getByText('/basic-href');
@ -21,7 +21,6 @@ export const DefaultActions = {
);
complexHref.click();
// eslint-disable-next-line no-undef
const finalUrl = window.location.toString();
expect(finalUrl).toBe(initialUrl);
},

View File

@ -107,7 +107,6 @@ describe('Channel', () => {
const sendSpy = vi.fn();
// @ts-expect-error (access private property for testing purposes)
channel.transports.forEach((t) => {
// eslint-disable-next-line no-param-reassign
t.send = sendSpy;
});
channel.emit(eventName, ...listenerInputData);
@ -146,7 +145,7 @@ describe('Channel', () => {
events.forEach((event) => {
event.listeners.forEach((listener) => {
channel.addListener(event.eventName, listener);
// eslint-disable-next-line no-plusplus, no-param-reassign
event.listenerCount++;
});
});

View File

@ -16,7 +16,7 @@ interface PostinstallOptions {
const postinstallAddon = async (addonName: string, options: PostinstallOptions) => {
try {
const modulePath = require.resolve(`${addonName}/postinstall`, { paths: [process.cwd()] });
// eslint-disable-next-line import/no-dynamic-require, global-require
const postinstall = require(modulePath);
try {

View File

@ -6,7 +6,6 @@ import { isNxProject } from '../../helpers';
import { AngularJSON } from '../../generators/ANGULAR/helpers';
import { getFrameworkPackageName } from '../helpers/mainConfigFile';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AngularBuildersMultiprojectRunOptions {}
export const angularBuildersMultiproject: Fix<AngularBuildersMultiprojectRunOptions> = {

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import * as t from '@babel/types';
import type { ConfigFile } from '@storybook/csf-tools';
@ -42,14 +41,15 @@ function getReferenceToRequireWrapper(config: ConfigFile, value: string) {
* @returns Name of the require wrapper function.
*/
export function getRequireWrapperName(config: ConfigFile) {
const declarationName = config.getBodyDeclarations().flatMap((node) =>
// eslint-disable-next-line no-nested-ternary
doesVariableOrFunctionDeclarationExist(node, 'wrapForPnp')
? ['wrapForPnp']
: doesVariableOrFunctionDeclarationExist(node, defaultRequireWrapperName)
? [defaultRequireWrapperName]
: []
);
const declarationName = config
.getBodyDeclarations()
.flatMap((node) =>
doesVariableOrFunctionDeclarationExist(node, 'wrapForPnp')
? ['wrapForPnp']
: doesVariableOrFunctionDeclarationExist(node, defaultRequireWrapperName)
? [defaultRequireWrapperName]
: []
);
if (declarationName.length) {
return declarationName[0];

View File

@ -4,7 +4,6 @@ import { FixStatus } from '../types';
import type { InstallationMetadata } from '../../js-package-manager/types';
vi.mock('boxen', () => ({
// eslint-disable-next-line no-control-regex
default: vi.fn((str, { title = '' }) => `${title}\n\n${str.replace(/\x1b\[[0-9;]*[mG]/g, '')}`),
}));

View File

@ -88,7 +88,6 @@ export function getMigrationSummary({
(r) => r === FixStatus.FAILED || r === FixStatus.CHECK_FAILED
);
// eslint-disable-next-line no-nested-ternary
const title = hasNoFixes
? 'No migrations were applicable to your project'
: hasFailures

View File

@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import prompts from 'prompts';
import chalk from 'chalk';
import boxen from 'boxen';

View File

@ -134,7 +134,6 @@ export async function detectBuilder(packageManager: JsPackageManager, projectTyp
case ProjectType.EMBER:
return CoreBuilder.Webpack5;
default:
// eslint-disable-next-line no-case-declarations
const { builder } = await prompts(
{
type: 'select',

View File

@ -239,7 +239,6 @@ command('dev')
});
if (parseInt(`${options.port}`, 10)) {
// eslint-disable-next-line no-param-reassign
options.port = parseInt(`${options.port}`, 10);
}

View File

@ -178,7 +178,6 @@ export async function baseGenerator(
const shouldApplyRequireWrapperOnPackageNames = isStorybookInMonorepository || pnp;
if (!builder) {
// eslint-disable-next-line no-param-reassign
builder = await detectBuilder(packageManager, projectType);
}

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import chalk from 'chalk';
import fs from 'fs';
import fse from 'fs-extra';

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { PackageJson } from 'read-pkg-up';
import chalk from 'chalk';
import prompts from 'prompts';
@ -189,7 +188,6 @@ const installStorybook = async <Project extends ProjectType>(
const projectTypeInquirer = async (
options: CommandOptions & { yes?: boolean },
packageManager: JsPackageManager
// eslint-disable-next-line consistent-return
) => {
const manualAnswer = options.yes
? true

View File

@ -84,7 +84,6 @@ export abstract class JsPackageManager {
public isStorybookInMonorepo() {
let cwd = process.cwd();
// eslint-disable-next-line no-constant-condition
while (true) {
try {
const turboJsonPath = `${cwd}/turbo.json`;

View File

@ -122,7 +122,6 @@ export class PNPMProxy extends JsPackageManager {
if (pnpapiPath) {
try {
// eslint-disable-next-line import/no-dynamic-require, global-require
const pnpApi = require(pnpapiPath);
const resolvedPath = await pnpApi.resolveToUnqualified(packageName, basePath, {

View File

@ -131,7 +131,6 @@ export class Yarn2Proxy extends JsPackageManager {
if (pnpapiPath) {
try {
// eslint-disable-next-line import/no-dynamic-require, global-require
const pnpApi = require(pnpapiPath);
const resolvedPath = await pnpApi.resolveToUnqualified(packageName, basePath, {

View File

@ -11,10 +11,13 @@ vi.mock('@storybook/telemetry');
vi.mock('./versions', async (importOriginal) => {
const originalVersions = ((await importOriginal()) as { default: typeof versions }).default;
return {
default: Object.keys(originalVersions).reduce((acc, key) => {
acc[key] = '8.0.0';
return acc;
}, {} as Record<string, string>),
default: Object.keys(originalVersions).reduce(
(acc, key) => {
acc[key] = '8.0.0';
return acc;
},
{} as Record<string, string>
),
};
});

View File

@ -30,7 +30,6 @@ export function getEnvConfig(program: Record<string, any>, configEnv: Record<str
const envVarName = configEnv[fieldName];
const envVarValue = process.env[envVarName];
if (envVarValue) {
// eslint-disable-next-line no-param-reassign
program[fieldName] = envVarValue;
}
});

View File

@ -83,14 +83,14 @@ export const pretty =
let reResultArray;
argArray.push(args[0].replace(startTagRe, '%c').replace(endTagRe, '%c'));
// eslint-disable-next-line no-cond-assign
while ((reResultArray = startTagRe.exec(args[0]))) {
argArray.push(reResultArray[2]);
argArray.push('');
}
// pass through subsequent args since chrome dev tools does not (yet) support console.log styling of the following form: console.log('%cBlue!', 'color: blue;', '%cRed!', 'color: red;');
// eslint-disable-next-line no-plusplus
for (let j = 1; j < args.length; j++) {
argArray.push(args[j]);
}

View File

@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
/* eslint import/prefer-default-export: "off" */
import fs from 'fs';
import path from 'path';

View File

@ -20,12 +20,10 @@ fs.readdirSync(fixturesDir).forEach((transformName) => {
const inputPath = path.join(transformFixturesDir, fileName);
it(`transforms correctly using "${fileName}" data`, () =>
expect(
applyTransform(
// eslint-disable-next-line global-require,import/no-dynamic-require
require(path.join(__dirname, '..', transformName)),
null,
{ path: inputPath, source: fs.readFileSync(inputPath, 'utf8') }
)
applyTransform(require(path.join(__dirname, '..', transformName)), null, {
path: inputPath,
source: fs.readFileSync(inputPath, 'utf8'),
})
).toMatchFileSnapshot(inputPath.replace(inputRegExp, '.output.snapshot')));
});
});

View File

@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/ban-ts-comment,no-param-reassign,@typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/ban-ts-comment,@typescript-eslint/no-shadow */
import type { FileInfo } from 'jscodeshift';
import { babelParse, babelParseExpression } from '@storybook/csf-tools';
import { remark } from 'remark';

View File

@ -58,7 +58,6 @@ export default function transformer(file, api) {
* @returns {ImportDeclaration.Node} the import declaration node
*/
const updatePackageName = (declaration) => {
// eslint-disable-next-line no-param-reassign
declaration.node.source.value = getNewPackageName(declaration.node.source.value);
return declaration.node;

View File

@ -28,7 +28,6 @@ export default function transformer(file, api, options) {
if (def.node.declaration && def.node.declaration.properties) {
def.node.declaration.properties.forEach((p) => {
if (p.key.name === 'title') {
// eslint-disable-next-line no-param-reassign
p.value.value = upgradeSeparator(p.value.value);
}
});

View File

@ -3,11 +3,10 @@ import { getInterpretedFileWithExt } from './interpret-files';
let registered = false;
export function interopRequireDefault(filePath: string) {
// eslint-disable-next-line no-underscore-dangle, global-require
// eslint-disable-next-line no-underscore-dangle
const hasEsbuildBeenRegistered = !!require('module')._extensions['.ts'];
if (registered === false && !hasEsbuildBeenRegistered) {
// eslint-disable-next-line global-require
const { register } = require('esbuild-register/dist/node');
registered = true;
register({
@ -26,7 +25,6 @@ export function interopRequireDefault(filePath: string) {
});
}
// eslint-disable-next-line import/no-dynamic-require,global-require
const result = require(filePath);
const isES6DefaultExported =

View File

@ -1,4 +1,3 @@
/* eslint-disable no-console */
import chalk from 'chalk';
export function logConfig(caption: unknown, config: unknown) {

View File

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import 'vitest';
interface CustomMatchers<R = unknown> {

View File

@ -198,7 +198,6 @@ export class WebpackInvocationError extends StorybookError {
}
function removeAnsiEscapeCodes(input = '') {
// eslint-disable-next-line no-control-regex
return input.replace(/\u001B\[[0-9;]*m/g, '');
}

View File

@ -65,7 +65,6 @@ export async function buildDevStandalone(
outputDir = cacheOutputDir;
}
/* eslint-disable no-param-reassign */
options.port = port;
options.versionCheck = versionCheck;
options.configType = 'DEVELOPMENT';
@ -73,7 +72,6 @@ export async function buildDevStandalone(
options.cacheKey = cacheKey;
options.outputDir = outputDir;
options.serverChannelUrl = getServerChannelUrl(port, options);
/* eslint-enable no-param-reassign */
const config = await loadMainConfig(options);
const { framework } = config;
@ -196,7 +194,6 @@ export async function buildDevStandalone(
(warning) => !warning.message.includes(`Conflicting values for 'process.env.NODE_ENV'`)
);
// eslint-disable-next-line no-console
console.log(problems.map((p) => p.stack));
process.exit(problems.length > 0 ? 1 : 0);
} else {

View File

@ -27,7 +27,6 @@ export type BuildStaticStandaloneOptions = CLIOptions &
BuilderOptions & { outputDir: string };
export async function buildStaticStandalone(options: BuildStaticStandaloneOptions) {
/* eslint-disable no-param-reassign */
options.configType = 'PRODUCTION';
if (options.outputDir === '') {
@ -36,7 +35,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
options.outputDir = resolve(options.outputDir);
options.configDir = resolve(options.configDir);
/* eslint-enable no-param-reassign */
logger.info(chalk`=> Cleaning outputDir: {cyan ${relative(process.cwd(), options.outputDir)}}`);
if (options.outputDir === '/') {

View File

@ -6,13 +6,16 @@ const STATIC_FILTER = 'static-filter';
addons.register(STATIC_FILTER, (api) => {
// FIXME: this ensures the filter is applied after the first render
// to avoid a strange race condition in Webkit only.
const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce((acc, entry) => {
const [tag, option] = entry;
if ((option as any).excludeFromSidebar) {
acc[tag] = true;
}
return acc;
}, {} as Record<string, boolean>);
const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce(
(acc, entry) => {
const [tag, option] = entry;
if ((option as any).excludeFromSidebar) {
acc[tag] = true;
}
return acc;
},
{} as Record<string, boolean>
);
api.experimental_setFilter(STATIC_FILTER, (item) => {
const tags = item.tags || [];

View File

@ -603,7 +603,7 @@ export class StoryIndexGenerator {
dependents.forEach((dep) => {
if (otherCache[dep]) {
invalidated.add(dep);
// eslint-disable-next-line no-param-reassign
otherCache[dep] = false;
}
});

View File

@ -10,7 +10,6 @@ const fileExists = (basename: string) =>
export function getMiddleware(configDir: string) {
const middlewarePath = fileExists(path.resolve(configDir, 'middleware'));
if (middlewarePath) {
// eslint-disable-next-line global-require, import/no-dynamic-require
let middlewareModule = require(middlewarePath);
// eslint-disable-next-line no-underscore-dangle
if (middlewareModule.__esModule) {

View File

@ -58,7 +58,6 @@ export function outputStartupInformation(options: {
.filter(Boolean)
.join(' and ');
// eslint-disable-next-line no-console
console.log(
boxen(
dedent`

View File

@ -295,7 +295,6 @@ export class ConfigFile {
if (node) {
const { code } = generate.default(node, {});
// eslint-disable-next-line no-eval
const value = (0, eval)(`(() => (${code}))()`);
return value;
}

View File

@ -844,7 +844,6 @@ describe('CsfFile', () => {
- ./Check
`);
});
// eslint-disable-next-line jest/no-disabled-tests
it.skip('dynamic imports', () => {
const input = dedent`
const Button = await import('./Button');
@ -853,7 +852,6 @@ describe('CsfFile', () => {
const csf = loadCsf(input, { makeTitle }).parse();
expect(csf.imports).toMatchInlineSnapshot();
});
// eslint-disable-next-line jest/no-disabled-tests
it.skip('requires', () => {
const input = dedent`
const Button = require('./Button');

Some files were not shown because too many files have changed in this diff Show More