mirror of
https://github.com/lingble/twenty.git
synced 2025-11-02 13:47:55 +00:00
chore: enable no-console eslint rule for tests and stories (#4816)
Re-enables no-console eslint rule in stories and tests files: - In stories, use `action` from '@storybook/addon-actions' or `fn` from '@storybook/test' instead of console. - In tests, console methods can be mocked like this: `global.console.error = jest.fn()`.
This commit is contained in:
@@ -3,17 +3,4 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'no-console': 'error',
|
'no-console': 'error',
|
||||||
},
|
},
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: [
|
|
||||||
'.storybook/**/*',
|
|
||||||
'**/*.stories.tsx',
|
|
||||||
'**/*.test.ts',
|
|
||||||
'**/*.test.tsx',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
'no-console': 'off',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,17 +3,4 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'no-console': 'error',
|
'no-console': 'error',
|
||||||
},
|
},
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: [
|
|
||||||
'.storybook/**/*',
|
|
||||||
'**/*.stories.tsx',
|
|
||||||
'**/*.test.ts',
|
|
||||||
'**/*.test.tsx',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
'no-console': 'off',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { action } from '@storybook/addon-actions';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { expect, userEvent, within } from '@storybook/test';
|
import { expect, userEvent, within } from '@storybook/test';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
@@ -46,8 +47,7 @@ const meta: Meta<typeof CommandMenu> = {
|
|||||||
label: 'Create Task',
|
label: 'Create Task',
|
||||||
type: CommandType.Create,
|
type: CommandType.Create,
|
||||||
Icon: IconCheckbox,
|
Icon: IconCheckbox,
|
||||||
// eslint-disable-next-line no-console
|
onCommandClick: action('create task click'),
|
||||||
onCommandClick: () => console.log('create task click'),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'create-note',
|
id: 'create-note',
|
||||||
@@ -55,8 +55,7 @@ const meta: Meta<typeof CommandMenu> = {
|
|||||||
label: 'Create Note',
|
label: 'Create Note',
|
||||||
type: CommandType.Create,
|
type: CommandType.Create,
|
||||||
Icon: IconNotes,
|
Icon: IconNotes,
|
||||||
// eslint-disable-next-line no-console
|
onCommandClick: action('create note click'),
|
||||||
onCommandClick: () => console.log('create note click'),
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
openCommandMenu();
|
openCommandMenu();
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ describe('useFavorites', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const responderProvided: ResponderProvided = {
|
const responderProvided: ResponderProvided = {
|
||||||
// eslint-disable-next-line no-console
|
announce: () => {},
|
||||||
announce: (message: string) => console.log(message),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
result.current.handleReorderFavorite(
|
result.current.handleReorderFavorite(
|
||||||
|
|||||||
@@ -351,8 +351,7 @@ describe('useFilterDropdown', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle scopeId undefined on initial values', () => {
|
it('should handle scopeId undefined on initial values', () => {
|
||||||
// eslint-disable-next-line no-console
|
global.console.error = jest.fn();
|
||||||
console.error = jest.fn();
|
|
||||||
|
|
||||||
const renderFunction = () => {
|
const renderFunction = () => {
|
||||||
renderHook(() => useFilterDropdown(), renderHookConfig);
|
renderHook(() => useFilterDropdown(), renderHookConfig);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { action } from '@storybook/addon-actions';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { IconBell } from 'twenty-ui';
|
import { IconBell } from 'twenty-ui';
|
||||||
|
|
||||||
@@ -12,8 +13,7 @@ const meta: Meta<typeof DraggableList> = {
|
|||||||
component: DraggableList,
|
component: DraggableList,
|
||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
parameters: {
|
parameters: {
|
||||||
// eslint-disable-next-line no-console
|
onDragEnd: action('dragged'),
|
||||||
onDragEnd: () => console.log('dragged'),
|
|
||||||
},
|
},
|
||||||
argTypes: {
|
argTypes: {
|
||||||
draggableItems: { control: false },
|
draggableItems: { control: false },
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { action } from '@storybook/addon-actions';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { IconBell } from 'twenty-ui';
|
import { IconBell } from 'twenty-ui';
|
||||||
|
|
||||||
@@ -23,10 +24,8 @@ export const Default: Story = {
|
|||||||
LeftIcon: IconBell,
|
LeftIcon: IconBell,
|
||||||
accent: 'default',
|
accent: 'default',
|
||||||
iconButtons: [
|
iconButtons: [
|
||||||
// eslint-disable-next-line no-console
|
{ Icon: IconBell, onClick: action('Clicked') },
|
||||||
{ Icon: IconBell, onClick: () => console.log('Clicked') },
|
{ Icon: IconBell, onClick: action('Clicked') },
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
{ Icon: IconBell, onClick: () => console.log('Clicked') },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
decorators: [ComponentDecorator],
|
decorators: [ComponentDecorator],
|
||||||
@@ -86,15 +85,11 @@ export const Catalog: CatalogStory<Story, typeof MenuItem> = {
|
|||||||
iconButtons: [
|
iconButtons: [
|
||||||
{
|
{
|
||||||
Icon: IconBell,
|
Icon: IconBell,
|
||||||
onClick: () =>
|
onClick: action('Clicked on first icon button'),
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log('Clicked on first icon button'),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Icon: IconBell,
|
Icon: IconBell,
|
||||||
onClick: () =>
|
onClick: action('Clicked on second icon button'),
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log('Clicked on second icon button'),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { action } from '@storybook/addon-actions';
|
||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { IconBell, IconMinus } from 'twenty-ui';
|
import { IconBell, IconMinus } from 'twenty-ui';
|
||||||
|
|
||||||
@@ -24,10 +25,8 @@ export const Default: Story = {
|
|||||||
args: {
|
args: {
|
||||||
LeftIcon: IconBell,
|
LeftIcon: IconBell,
|
||||||
accent: 'default',
|
accent: 'default',
|
||||||
// eslint-disable-next-line no-console
|
iconButtons: [{ Icon: IconMinus, onClick: action('Clicked') }],
|
||||||
iconButtons: [{ Icon: IconMinus, onClick: () => console.log('Clicked') }],
|
onClick: action('Clicked'),
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
onClick: () => console.log('Clicked'),
|
|
||||||
text: 'Menu item draggable',
|
text: 'Menu item draggable',
|
||||||
isDragDisabled: false,
|
isDragDisabled: false,
|
||||||
},
|
},
|
||||||
@@ -87,9 +86,7 @@ export const Catalog: Story = {
|
|||||||
iconButtons: [
|
iconButtons: [
|
||||||
{
|
{
|
||||||
Icon: IconMinus,
|
Icon: IconMinus,
|
||||||
onClick: () =>
|
onClick: action('Clicked on minus icon button'),
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log('Clicked on minus icon button'),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ describe('useAvailableScopeIdOrThrow', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if no scopeId is provided and scopeId is undefined in the context', () => {
|
it('should throw an error if no scopeId is provided and scopeId is undefined in the context', () => {
|
||||||
// eslint-disable-next-line no-console
|
global.console.error = jest.fn();
|
||||||
console.error = jest.fn();
|
|
||||||
|
|
||||||
const renderFunction = () =>
|
const renderFunction = () =>
|
||||||
renderHook(() => ({
|
renderHook(() => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user