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

Buid: Update eslint (finally!!) #25601

Merged
merged 7 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ ember-output
!.eslintrc.js
!.eslintrc-markdown.js
!.storybook

lib/core-common/templates/base-preview-head.html
7 changes: 1 addition & 6 deletions code/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ module.exports = {
},
plugins: ['local-rules'],
rules: {
// remove as shared eslint has jest rules removed
'jest/no-standalone-expect': 'off',
'jest/no-done-callback': 'off',
'jest/no-deprecated-functions': 'off',
'jest/valid-expect': 'off',

'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'eslint-comments/no-unused-disable': 'error',
'react-hooks/rules-of-hooks': 'off',
Expand All @@ -52,6 +46,7 @@ module.exports = {
],
},
],
'@typescript-eslint/default-param-last': 'off',
},
overrides: [
{
Expand Down
1 change: 0 additions & 1 deletion code/addons/a11y/src/components/Report/Elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion code/addons/a11y/src/components/Report/HighlightToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion code/addons/a11y/src/components/Report/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion code/addons/a11y/src/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions code/addons/actions/src/containers/ActionLogger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion code/addons/docs/preview.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line import/export
export * from './dist/preview';
2 changes: 1 addition & 1 deletion code/addons/docs/src/compiler/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
)
Expand Down
2 changes: 0 additions & 2 deletions code/addons/essentials/src/docs/preset.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
1 change: 0 additions & 1 deletion code/addons/essentials/src/docs/preview.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line import/export
export * from '@storybook/addon-docs/dist/preview';
1 change: 0 additions & 1 deletion code/addons/gfm/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { dedent } from 'ts-dedent';
import { deprecate } from '@storybook/node-logger';

Expand Down
2 changes: 0 additions & 2 deletions code/addons/interactions/src/components/InteractionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion code/addons/interactions/src/components/MatcherResult.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down
1 change: 0 additions & 1 deletion code/addons/interactions/src/components/MethodCall.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion code/addons/interactions/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion code/addons/jest/src/components/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion code/addons/links/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] || '');
Expand Down
1 change: 0 additions & 1 deletion code/addons/measure/src/box-model/canvas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { global } from '@storybook/global';
import invariant from 'tiny-invariant';

Expand Down
2 changes: 0 additions & 2 deletions code/addons/measure/src/box-model/labels.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion code/addons/measure/src/box-model/visualizer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable operator-assignment */
/**
* Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7
*/
Expand Down
1 change: 0 additions & 1 deletion code/addons/viewport/src/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
Expand Down
4 changes: 1 addition & 3 deletions code/builders/builder-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-manager/src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 1 addition & 2 deletions code/builders/builder-vite/src/utils/has-vite-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions code/builders/builder-vite/src/utils/without-vite-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion code/builders/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 0 additions & 2 deletions code/builders/builder-webpack5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions code/e2e-tests/addon-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
3 changes: 0 additions & 3 deletions code/e2e-tests/addon-docs.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion code/e2e-tests/addon-interactions.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions code/e2e-tests/framework-nextjs.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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'
);
Expand Down
14 changes: 2 additions & 12 deletions code/e2e-tests/framework-svelte.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions code/e2e-tests/manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down
3 changes: 0 additions & 3 deletions code/e2e-tests/preview-web.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/no-disabled-tests */
import { test, expect } from '@playwright/test';
import process from 'process';
import { SbPage } from './util';
Expand All @@ -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`
);
Expand All @@ -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`
);
Expand Down
1 change: 0 additions & 1 deletion code/e2e-tests/util.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Loading