Skip to content

Commit

Permalink
Fix: Add .jsx extension to default components and ignore patterns (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
KadoBOT authored and sapegin committed Apr 25, 2017
1 parent f1defbb commit 4e81592
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Components

By default Styleguidist will search components using this [glob pattern](https://github.com/isaacs/node-glob#glob-primer): `src/components/**/*.js`. It will pick up paths like `src/components/Button.js`, `src/components/Button/Button.js` or `src/components/Button/index.js`. It will also ignore test files (`__tests__` folder and file names containing `.test.js` or `.spec.js`). If it doesn’t work for you, create a `styleguide.config.js` file in your project’s root folder and configure the patterns to fit your project structure.
By default Styleguidist will search components using this [glob pattern](https://github.com/isaacs/node-glob#glob-primer): `src/components/**/*.jsx?`. It will pick up paths like `src/components/Button.js`, `src/components/Button/Button.js` or `src/components/Button/index.js`. It will also ignore test files (`__tests__` folder and file names containing `.test.js`, `.test.jsx`, `.spec.js` and `.spec.jsx`). If it doesn’t work for you, create a `styleguide.config.js` file in your project’s root folder and configure the patterns to fit your project structure.

For example, if your components look like `components/Button/Button.js` + `components/Button/index.js` (meaning you need to skip `index.js`, otherwise the component will be loaded twice):

Expand Down
4 changes: 2 additions & 2 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Styleguidist uses [Bublé](https://buble.surge.sh/guide/) to run ES6 code on the

#### `components`

Type: `String` or `Function`, default: `src/components/**/*.js`
Type: `String` or `Function`, default: `src/components/**/*.jsx?`

- when `String`: a [glob pattern](https://github.com/isaacs/node-glob#glob-primer) that matches all your component modules.
- when `Function`: a function that returns an array of module paths.
Expand Down Expand Up @@ -187,7 +187,7 @@ Type: `String`, default: `base16-light`

#### `ignore`

Type: `String[]`, default: `['**/__tests__/**', '**/*.test.js', '**/*.spec.js']`
Type: `String[]`, default: `['**/__tests__/**', '**/*.test.js', '**/*.test.jsx', '**/*.spec.js', '**/*.spec.jsx']`

Array of [glob pattern](https://github.com/isaacs/node-glob#glob-primer) or files of components that should not be included in the style guide.

Expand Down
6 changes: 4 additions & 2 deletions scripts/schemas/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-disable no-console */

const DEFAULT_COMPONENTS_PATTERN = 'src/@(components|Components)/**/*.js';
const DEFAULT_COMPONENTS_PATTERN = 'src/@(components|Components)/**/*.jsx?';

const fs = require('fs');
const path = require('path');
Expand All @@ -30,7 +30,7 @@ module.exports = {
// `components` is a shortcut for { sections: [{ components }] }, see `sections` below
components: {
type: ['string', 'function'],
example: 'components/**/[A-Z]*.js',
example: 'components/**/[A-Z]*.jsx?',
},
context: {
type: 'object',
Expand Down Expand Up @@ -85,6 +85,8 @@ module.exports = {
'**/__tests__/**',
'**/*.test.js',
'**/*.spec.js',
'**/*.test.jsx',
'**/*.spec.jsx'
],
},
highlightTheme: {
Expand Down

0 comments on commit 4e81592

Please sign in to comment.