Skip to content

Commit

Permalink
fix(storybook): fix 6.1.0 migration to prevent wiping out eslintrc (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rathpc committed Jun 26, 2023
1 parent ae698a7 commit b736992
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,37 @@ describe('Ignore @nx/react/plugins/storybook in Storybook eslint plugin', () =>
);

if (!tree.exists('.eslintrc.json')) {
tree.write('.eslintrc.json', '{}');
tree.write('.eslintrc.json', `{}`);
}
updateJson(tree, '.eslintrc.json', (json) => {
json.extends ??= [];
json.extends.push('plugin:storybook/recommended');
return json;
});
});

it('should not ignore the plugin if it is not used', async () => {
await eslintIgnoreReactPlugin(tree);
const eslintConfig = readJson(tree, '.eslintrc.json');
expect(eslintConfig).toEqual({});
expect(eslintConfig.rules).toBeUndefined();
});

it('should not ignore the plugin if "plugin:storybook/recommended" is not included', async () => {
tree.write('apps/main-webpack/tsconfig.json', `{}`);
tree.write(
`apps/main-webpack/.storybook/main.js`,
`
module.exports = {
stories: ['../src/lib/**/*.stories.@(mdx|js|jsx|ts|tsx)'],
addons: ['@storybook/addon-essentials', '@nx/react/plugins/storybook'],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
};
`
);

await eslintIgnoreReactPlugin(tree);

const eslintConfig = readJson(tree, '.eslintrc.json');
expect(eslintConfig).toEqual({});
expect(eslintConfig.rules).toBeUndefined();
});

Expand All @@ -71,6 +90,12 @@ describe('Ignore @nx/react/plugins/storybook in Storybook eslint plugin', () =>
`
);

updateJson(tree, '.eslintrc.json', (json) => {
json.extends ??= [];
json.extends.push('plugin:storybook/recommended');
return json;
});

await eslintIgnoreReactPlugin(tree);

const eslintConfig = readJson(tree, '.eslintrc.json');
Expand Down

1 comment on commit b736992

@vercel
Copy link

@vercel vercel bot commented on b736992 Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.