Skip to content

Commit

Permalink
use-storybook-expect: remove auto fix suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Sep 3, 2024
1 parent eef5e25 commit 4f1306c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 78 deletions.
21 changes: 2 additions & 19 deletions lib/rules/use-storybook-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export = createStorybookRule<TDefaultOptions, string>({
hasSuggestions: true,
schema: [],
docs: {
description: 'Use expect from `@storybook/jest`',
description: 'Use expect from `@storybook/test` or `@storybook/jest`',
categories: [CategoryId.ADDON_INTERACTIONS, CategoryId.RECOMMENDED],
recommended: 'error',
},
messages: {
updateImports: 'Update imports',
useExpectFromStorybook:
'Do not use expect from jest directly in the story. You should use from `@storybook/jest` instead.',
'Do not use global expect directly in the story. You should import it from `@storybook/test` or `@storybook/jest` instead.',
},
},

Expand Down Expand Up @@ -82,23 +82,6 @@ export = createStorybookRule<TDefaultOptions, string>({
context.report({
node,
messageId: 'useExpectFromStorybook',
fix: function (fixer) {
return fixer.insertTextAfterRange(
[0, 0],
"import { expect } from '@storybook/jest';\n"
)
},
suggest: [
{
messageId: 'updateImports',
fix: function (fixer) {
return fixer.insertTextAfterRange(
[0, 0],
"import { expect } from '@storybook/jest';\n"
)
},
},
],
})
})
}
Expand Down
59 changes: 0 additions & 59 deletions tests/lib/rules/use-storybook-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,10 @@ ruleTester.run('use-storybook-expect', rule, {
expect(123).toEqual(123);
}
`,
output: dedent`
import { expect } from '@storybook/jest';
Default.play = () => {
expect(123).toEqual(123);
}
`,
errors: [
{
messageId: 'useExpectFromStorybook',
type: AST_NODE_TYPES.Identifier,
suggestions: [
{
messageId: 'updateImports',
output: dedent`
import { expect } from '@storybook/jest';
Default.play = () => {
expect(123).toEqual(123);
}
`,
},
],
},
],
},
Expand All @@ -93,29 +76,10 @@ ruleTester.run('use-storybook-expect', rule, {
}
Default.play = someInteraction
`,
output: dedent`
import { expect } from '@storybook/jest';
const someInteraction = () => {
expect(123).toEqual(123);
}
Default.play = someInteraction
`,
errors: [
{
messageId: 'useExpectFromStorybook',
type: AST_NODE_TYPES.Identifier,
suggestions: [
{
messageId: 'updateImports',
output: dedent`
import { expect } from '@storybook/jest';
const someInteraction = () => {
expect(123).toEqual(123);
}
Default.play = someInteraction
`,
},
],
},
],
},
Expand All @@ -128,33 +92,10 @@ ruleTester.run('use-storybook-expect', rule, {
},
};
`,
output: dedent`
import { expect } from '@storybook/jest';
export const Basic = {
...Default,
play: async (context) => {
expect(123).toEqual(123);
},
};
`,
errors: [
{
messageId: 'useExpectFromStorybook',
type: AST_NODE_TYPES.Identifier,
suggestions: [
{
messageId: 'updateImports',
output: dedent`
import { expect } from '@storybook/jest';
export const Basic = {
...Default,
play: async (context) => {
expect(123).toEqual(123);
},
};
`,
},
],
},
],
},
Expand Down

0 comments on commit 4f1306c

Please sign in to comment.