From 4e815924edee34f7e9661219283f8fa076ca32c5 Mon Sep 17 00:00:00 2001 From: Ricardo Ambrogi Date: Tue, 25 Apr 2017 11:31:47 +0200 Subject: [PATCH] Fix: Add .jsx extension to default components and ignore patterns (#404) --- docs/Components.md | 2 +- docs/Configuration.md | 4 ++-- scripts/schemas/config.js | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/Components.md b/docs/Components.md index 90e32621a..d363d4d0c 100644 --- a/docs/Components.md +++ b/docs/Components.md @@ -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): diff --git a/docs/Configuration.md b/docs/Configuration.md index f58f4eb7d..4691ad342 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -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. @@ -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. diff --git a/scripts/schemas/config.js b/scripts/schemas/config.js index c8d59230f..60e0e3673 100644 --- a/scripts/schemas/config.js +++ b/scripts/schemas/config.js @@ -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'); @@ -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', @@ -85,6 +85,8 @@ module.exports = { '**/__tests__/**', '**/*.test.js', '**/*.spec.js', + '**/*.test.jsx', + '**/*.spec.jsx' ], }, highlightTheme: {