-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby-plugin-mdx): run prettier (#16575)
* run prettier on gatsby-plugin-mdx * Update .prettierignore * fix lint * fix lint * fix lint
- Loading branch information
1 parent
17a41ae
commit 43f29d9
Showing
39 changed files
with
1,344 additions
and
1,346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
) | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
82
packages/gatsby-plugin-mdx/gatsby/create-webpack-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`, | ||
}), | ||
], | ||
}) | ||
} |
Oops, something went wrong.