Skip to content

Commit

Permalink
fix(angular): generate storybook configuration with proper linter (nr…
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Aug 21, 2020
1 parent 8d835ad commit d796731
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/angular/api-angular/schematics/storybook-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Type: `boolean`

Automatically generate \*.stories.ts files for components declared in this library

### linter

Default: `tslint`

Type: `string`

Possible values: `eslint`, `tslint`

The tool to use for running lint checks.

### name

Type: `string`
Expand Down
10 changes: 10 additions & 0 deletions docs/react/api-angular/schematics/storybook-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Type: `boolean`

Automatically generate \*.stories.ts files for components declared in this library

### linter

Default: `tslint`

Type: `string`

Possible values: `eslint`, `tslint`

The tool to use for running lint checks.

### name

Type: `string`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`schematic:configuration should generate the right files 1`] = `
Array [
"/workspace.json",
"/package.json",
"/nx.json",
"/tsconfig.base.json",
"/tslint.json",
"/jest.config.js",
"/libs/test-ui-lib/README.md",
"/libs/test-ui-lib/tsconfig.lib.json",
"/libs/test-ui-lib/tslint.json",
"/libs/test-ui-lib/tsconfig.json",
"/libs/test-ui-lib/jest.config.js",
"/libs/test-ui-lib/tsconfig.spec.json",
"/libs/test-ui-lib/src/index.ts",
"/libs/test-ui-lib/src/test-setup.ts",
"/libs/test-ui-lib/src/lib/test-ui-lib.module.ts",
"/libs/test-ui-lib/src/lib/test-button/test-button.component.css",
"/libs/test-ui-lib/src/lib/test-button/test-button.component.html",
"/libs/test-ui-lib/src/lib/test-button/test-button.component.spec.ts",
"/libs/test-ui-lib/src/lib/test-button/test-button.component.ts",
"/libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts",
"/libs/test-ui-lib/src/lib/nested/nested.module.ts",
"/libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.css",
"/libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.html",
"/libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.spec.ts",
"/libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.ts",
"/libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts",
"/libs/test-ui-lib/src/lib/test-other/test-other.component.css",
"/libs/test-ui-lib/src/lib/test-other/test-other.component.html",
"/libs/test-ui-lib/src/lib/test-other/test-other.component.spec.ts",
"/libs/test-ui-lib/src/lib/test-other/test-other.component.ts",
"/libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts",
"/libs/test-ui-lib/.storybook/tsconfig.json",
"/libs/test-ui-lib/.storybook/addons.js",
"/libs/test-ui-lib/.storybook/config.js",
"/libs/test-ui-lib/.storybook/webpack.config.js",
"/.storybook/addons.js",
"/.storybook/tsconfig.json",
"/.storybook/webpack.config.js",
"/apps/test-ui-lib-e2e/tslint.json",
"/apps/test-ui-lib-e2e/cypress.json",
"/apps/test-ui-lib-e2e/tsconfig.e2e.json",
"/apps/test-ui-lib-e2e/tsconfig.json",
"/apps/test-ui-lib-e2e/src/fixtures/example.json",
"/apps/test-ui-lib-e2e/src/plugins/index.js",
"/apps/test-ui-lib-e2e/src/support/commands.ts",
"/apps/test-ui-lib-e2e/src/support/index.ts",
"/apps/test-ui-lib-e2e/src/integration/test-button/test-button.component.spec.ts",
"/apps/test-ui-lib-e2e/src/integration/test-other/test-other.component.spec.ts",
"/apps/test-ui-lib-e2e/src/integration/nested-button/nested-button.component.spec.ts",
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,18 @@ describe('schematic:configuration', () => {
)
).toBeTruthy();
});

it('should generate the right files', async () => {
const tree = await runSchematic(
'storybook-configuration',
<StorybookConfigureSchema>{
name: 'test-ui-lib',
configureCypress: true,
generateCypressSpecs: true,
generateStories: true,
},
appTree
);
expect(tree.files).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function (schema: StorybookConfigureSchema): Rule {
name: schema.name,
uiFramework: '@storybook/angular',
configureCypress: schema.configureCypress,
linter: schema.linter,
}),
schema.generateStories ? generateStories(schema) : noop(),
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Linter } from '@nrwl/workspace';

export interface StorybookConfigureSchema {
name: string;
configureCypress: boolean;
generateStories: boolean;
generateCypressSpecs: boolean;
linter: Linter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"type": "boolean",
"description": "Automatically generate *.spec.ts files in the cypress e2e app generated by the cypress-configure schematic",
"x-prompt": "Automatically generate *.spec.ts files in the cypress e2e app generated by the cypress-configure schematic?"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"default": "tslint"
}
},
"required": ["name"]
Expand Down

0 comments on commit d796731

Please sign in to comment.