Skip to content

Commit

Permalink
chore(gatsby-plugin-mdx): run prettier (#16575)
Browse files Browse the repository at this point in the history
* run prettier on gatsby-plugin-mdx

* Update .prettierignore

* fix lint

* fix lint

* fix lint
  • Loading branch information
mathieudutour authored and GatsbyJS Bot committed Aug 13, 2019
1 parent 17a41ae commit 43f29d9
Show file tree
Hide file tree
Showing 39 changed files with 1,344 additions and 1,346 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ www/public
packages/**/*.js
!packages/gatsby/cache-dir/**/*.js
!packages/*/src/**/*.js
!packages/gatsby-plugin-mdx/**/*.js
packages/gatsby-plugin-mdx/node_modules/**/*.js
packages/gatsby/cache-dir/commonjs/**/*.js

# fixtures
Expand Down
8 changes: 3 additions & 5 deletions packages/gatsby-plugin-mdx/component-with-mdx-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// turn function into a no-op passthrough
// this is so that people don't really have to change their code
module.exports = function componentWithMDXScope(componentPath) {
console.warn(
`componentWithMDXScope is deprecated. You don't need it anymore`
);
return componentPath;
};
console.warn(`componentWithMDXScope is deprecated. You don't need it anymore`)
return componentPath
}
8 changes: 4 additions & 4 deletions packages/gatsby-plugin-mdx/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const MDX_WRAPPERS_LOCATION = "mdx-wrappers-dir";
const MDX_SCOPES_LOCATION = "mdx-scopes-dir";
const MDX_WRAPPERS_LOCATION = `mdx-wrappers-dir`
const MDX_SCOPES_LOCATION = `mdx-scopes-dir`

module.exports = {
MDX_WRAPPERS_LOCATION,
MDX_SCOPES_LOCATION
};
MDX_SCOPES_LOCATION,
}
12 changes: 6 additions & 6 deletions packages/gatsby-plugin-mdx/context.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { createContext, useContext } from "react";
import React, { createContext, useContext } from "react"

const GatsbyMDXScopeContext = createContext({});
const GatsbyMDXScopeContext = createContext({})

export const useMDXScope = scope => {
const contextScope = useContext(GatsbyMDXScopeContext);
return scope || contextScope;
};
const contextScope = useContext(GatsbyMDXScopeContext)
return scope || contextScope
}

export const MDXScopeProvider = ({ __mdxScope, children }) => (
<GatsbyMDXScopeContext.Provider value={__mdxScope}>
{children}
</GatsbyMDXScopeContext.Provider>
);
)
19 changes: 9 additions & 10 deletions packages/gatsby-plugin-mdx/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ module.exports = {
*/
feeds: [
{
serialize: ({ query: { site, allMdx } }) => {
return allMdx.edges.map(edge => {
serialize: ({ query: { site, allMdx } }) =>
allMdx.edges.map(edge => {
return {
...edge.node.frontmatter,
description: edge.node.excerpt,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
custom_elements: [{ "content:encoded": edge.node.html }]
};
});
},
custom_elements: [{ "content:encoded": edge.node.html }],
}
}),
query: `
{
allMdx(
Expand All @@ -61,7 +60,7 @@ module.exports = {
}
}
`,
output: `rss.xml`
}
]
};
output: `rss.xml`,
},
],
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-mdx/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import wrap from "./wrap-root-element";
export const wrapRootElement = wrap;
import wrap from "./wrap-root-element"
export const wrapRootElement = wrap
36 changes: 18 additions & 18 deletions packages/gatsby-plugin-mdx/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
const path = require("path");
const mkdirp = require("mkdirp");
const { MDX_SCOPES_LOCATION } = require("./constants");
const defaultOptions = require("./utils/default-options");
const fs = require("fs");
const path = require(`path`)
const mkdirp = require(`mkdirp`)
const { MDX_SCOPES_LOCATION } = require(`./constants`)
const defaultOptions = require(`./utils/default-options`)
const fs = require(`fs`)

/**
* Create Mdx types and resolvers
*/
exports.sourceNodes = require("./gatsby/source-nodes");
exports.sourceNodes = require(`./gatsby/source-nodes`)

/**
* Create Mdx nodes from MDX files.
*/
exports.onCreateNode = require("./gatsby/on-create-node");
exports.onCreateNode = require(`./gatsby/on-create-node`)

/**
* Add frontmatter as page context for MDX pages
*/
exports.onCreatePage = require("./gatsby/on-create-page");
exports.onCreatePage = require(`./gatsby/on-create-page`)

/**
* Add the webpack config for loading MDX files
*/
exports.onCreateWebpackConfig = require("./gatsby/create-webpack-config");
exports.onCreateWebpackConfig = require(`./gatsby/create-webpack-config`)

/**
* Add the MDX extensions as resolvable. This is how the page creator
* determines which files in the pages/ directory get built as pages.
*/
exports.resolvableExtensions = (data, pluginOptions) =>
defaultOptions(pluginOptions).extensions;
defaultOptions(pluginOptions).extensions

/**
* Convert MDX to JSX so that Gatsby can extract the GraphQL queries.
*/
exports.preprocessSource = require("./gatsby/preprocess-source");
exports.preprocessSource = require(`./gatsby/preprocess-source`)

/**
* Required config for mdx to function
*/
exports.onCreateBabelConfig = ({ actions }) => {
actions.setBabelPlugin({
name: `@babel/plugin-proposal-object-rest-spread`
});
};
name: `@babel/plugin-proposal-object-rest-spread`,
})
}

exports.onPreBootstrap = ({ cache }) => {
mkdirp.sync(path.join(cache.directory, MDX_SCOPES_LOCATION));
};
mkdirp.sync(path.join(cache.directory, MDX_SCOPES_LOCATION))
}

exports.onPostBootstrap = ({ cache }, pluginOptions) => {
if (pluginOptions.globalScope) {
fs.writeFileSync(
path.join(cache.directory, MDX_SCOPES_LOCATION, `global-scope.js`),
pluginOptions.globalScope
);
)
}
};
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-mdx/gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import wrap from "./wrap-root-element";
export const wrapRootElement = wrap;
import wrap from "./wrap-root-element"
export const wrapRootElement = wrap
82 changes: 41 additions & 41 deletions packages/gatsby-plugin-mdx/gatsby/create-webpack-config.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
const path = require("path");
const escapeStringRegexp = require("escape-string-regexp");
const defaultOptions = require("../utils/default-options");
const path = require(`path`)
const escapeStringRegexp = require(`escape-string-regexp`)
const defaultOptions = require(`../utils/default-options`)

module.exports = (
{ stage, loaders, actions, plugins, cache, ...other },
pluginOptions
) => {
const options = defaultOptions(pluginOptions);
const options = defaultOptions(pluginOptions)
const testPattern = new RegExp(
options.extensions.map(ext => `${escapeStringRegexp(ext)}$`).join("|")
);
options.extensions.map(ext => `${escapeStringRegexp(ext)}$`).join(`|`)
)
actions.setWebpackConfig({
module: {
rules: [
{
test: /\.js$/,
include: cache.directory,
use: [loaders.js()]
use: [loaders.js()],
},
{
test: /\.js$/,
include: path.dirname(require.resolve("gatsby-plugin-mdx")),
use: [loaders.js()]
include: path.dirname(require.resolve(`gatsby-plugin-mdx`)),
use: [loaders.js()],
},

{
test: /mdx-components\.js$/,
include: path.dirname(require.resolve("gatsby-plugin-mdx")),
include: path.dirname(require.resolve(`gatsby-plugin-mdx`)),
use: [
loaders.js(),
{
loader: path.join(
"gatsby-plugin-mdx",
"loaders",
"mdx-components"
`gatsby-plugin-mdx`,
`loaders`,
`mdx-components`
),
options: {
plugins: options.mdxPlugins
}
}
]
plugins: options.mdxPlugins,
},
},
],
},
{
test: /mdx-scopes\.js$/,
include: path.dirname(require.resolve("gatsby-plugin-mdx")),
include: path.dirname(require.resolve(`gatsby-plugin-mdx`)),
use: [
loaders.js(),
{
loader: path.join("gatsby-plugin-mdx", "loaders", "mdx-scopes"),
loader: path.join(`gatsby-plugin-mdx`, `loaders`, `mdx-scopes`),
options: {
cache: cache
}
}
]
cache: cache,
},
},
],
},
{
test: /mdx-wrappers\.js$/,
include: path.dirname(require.resolve("gatsby-plugin-mdx")),
include: path.dirname(require.resolve(`gatsby-plugin-mdx`)),
use: [
loaders.js(),
{
loader: path.join("gatsby-plugin-mdx", "loaders", "mdx-wrappers"),
loader: path.join(`gatsby-plugin-mdx`, `loaders`, `mdx-wrappers`),
options: {
store: other.store
}
}
]
store: other.store,
},
},
],
},
{
test: testPattern,
use: [
loaders.js(),
{
loader: path.join("gatsby-plugin-mdx", "loaders", "mdx-loader"),
loader: path.join(`gatsby-plugin-mdx`, `loaders`, `mdx-loader`),
options: {
cache: cache,
...other,
pluginOptions: options
}
}
]
}
]
pluginOptions: options,
},
},
],
},
],
},
plugins: [
plugins.define({
__DEVELOPMENT__: stage === `develop` || stage === `develop-html`
})
]
});
};
__DEVELOPMENT__: stage === `develop` || stage === `develop-html`,
}),
],
})
}
Loading

0 comments on commit 43f29d9

Please sign in to comment.