Skip to content

Commit

Permalink
fix fixable linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Jun 30, 2022
1 parent 7eef5f0 commit 56bd91f
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export default {
};

export const Basic = () => <Button label="Click me" />;

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Form } from '@storybook/components';
const { Button } = Form;

export default {
title: 'CustomTitle',
component: Button,
title: 'CustomTitle',
component: Button,
};

export const Basic = () => <Button label="Click me" />;
2 changes: 1 addition & 1 deletion examples/react-ts/src/title/AutoTitle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export default {
component: Button,
};

export const Basic = () => <Button label="Click me" />;
export const Basic = () => <Button label="Click me" />;
4 changes: 2 additions & 2 deletions examples/react-ts/src/title/CustomTitle.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Form } from '@storybook/components';
const { Button } = Form;

export default {
title: 'CustomTitle',
component: Button,
title: 'CustomTitle',
component: Button,
};

export const Basic = () => <Button label="Click me" />;
3 changes: 2 additions & 1 deletion lib/channel-postmessage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export class PostmsgTransport {
private handleEvent(rawEvent: MessageEvent): void {
try {
const { data } = rawEvent;
const { key, event, refId } = typeof data === 'string' && isJSON(data) ? parse(data, global.CHANNEL_OPTIONS || {}) : data;
const { key, event, refId } =
typeof data === 'string' && isJSON(data) ? parse(data, global.CHANNEL_OPTIONS || {}) : data;

if (key === KEY) {
const pageString =
Expand Down
4 changes: 3 additions & 1 deletion lib/codemod/src/transforms/csf-2-to-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const isSimpleCSFStory = (init: t.Expression, annotations: t.ObjectProperty[]) =
annotations.length === 0 && t.isArrowFunctionExpression(init) && init.params.length === 0;

function transform({ source }: { source: string }, api: any, options: { parser?: string }) {
const makeTitle = (userTitle?: string) => { return userTitle || 'FIXME' }
const makeTitle = (userTitle?: string) => {
return userTitle || 'FIXME';
};
const csf = loadCsf(source, { makeTitle });

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class StoryIndexGenerator {
const importPath = slash(normalizeStoryPath(relativePath));
const makeTitle = (userTitle?: string) => {
return userOrAutoTitleFromSpecifier(importPath, specifier, userTitle);
}
};
const csf = (await readCsfOrMdx(absolutePath, { makeTitle })).parse();
csf.stories.forEach(({ id, name }) => {
fileStories[id] = {
Expand Down
37 changes: 30 additions & 7 deletions lib/store/src/autoTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ const winOptions = {
};

describe('userOrAutoTitleFromSpecifier', () => {

describe('user title', () => {
it('no match', () => {
expect(
userOrAuto('./ path / to / file.stories.js', normalizeStoriesEntry({ directory: './ other' }, options), 'title')
userOrAuto(
'./ path / to / file.stories.js',
normalizeStoriesEntry({ directory: './ other' }, options),
'title'
)
).toBeFalsy();
});

describe('no trailing slash', () => {
it('match with no titlePrefix', () => {
expect(
userOrAuto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options), 'title')
userOrAuto(
'./path/to/file.stories.js',
normalizeStoriesEntry({ directory: './path' }, options),
'title'
)
).toMatchInlineSnapshot(`title`);
});

Expand Down Expand Up @@ -77,7 +84,11 @@ describe('userOrAutoTitleFromSpecifier', () => {
describe('trailing slash', () => {
it('match with no titlePrefix', () => {
expect(
userOrAuto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options), 'title')
userOrAuto(
'./path/to/file.stories.js',
normalizeStoriesEntry({ directory: './path/' }, options),
'title'
)
).toMatchInlineSnapshot(`title`);
});

Expand Down Expand Up @@ -126,14 +137,22 @@ describe('userOrAutoTitleFromSpecifier', () => {
describe('auto title', () => {
it('no match', () => {
expect(
userOrAuto('./ path / to / file.stories.js', normalizeStoriesEntry({ directory: './ other' }, options), undefined)
userOrAuto(
'./ path / to / file.stories.js',
normalizeStoriesEntry({ directory: './ other' }, options),
undefined
)
).toBeFalsy();
});

describe('no trailing slash', () => {
it('match with no titlePrefix', () => {
expect(
userOrAuto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options), undefined)
userOrAuto(
'./path/to/file.stories.js',
normalizeStoriesEntry({ directory: './path' }, options),
undefined
)
).toMatchInlineSnapshot(`to/file`);
});

Expand Down Expand Up @@ -201,7 +220,11 @@ describe('userOrAutoTitleFromSpecifier', () => {
describe('trailing slash', () => {
it('match with no titlePrefix', () => {
expect(
userOrAuto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options), undefined)
userOrAuto(
'./path/to/file.stories.js',
normalizeStoriesEntry({ directory: './path/' }, options),
undefined
)
).toMatchInlineSnapshot(`to/file`);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/telemetry/src/get-monorepo-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getMonorepoType = (): MonorepoType => {
if (monorepoType) {
return monorepoType;
}

if (!fs.existsSync(path.join(projectRootPath, 'package.json'))) return undefined;

const packageJson = fs.readJsonSync(path.join(projectRootPath, 'package.json')) as PackageJson;
Expand Down

0 comments on commit 56bd91f

Please sign in to comment.