Skip to content

Commit f5c6132

Browse files
committed
Fix GFM features in mdx
Also turn on linting for mdx files and fix errors
1 parent dc3e5b4 commit f5c6132

File tree

23 files changed

+1907
-44
lines changed

23 files changed

+1907
-44
lines changed

.eslintrc.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const {getGlobals} = require('eslint-plugin-mdx/lib/helpers')
2+
13
module.exports = {
24
root: true,
35
ignorePatterns: ['.cache/', 'public/'],
@@ -10,7 +12,6 @@ module.exports = {
1012
'plugin:github/react',
1113
'plugin:primer-react/recommended',
1214
'plugin:react-hooks/recommended',
13-
'plugin:import/recommended',
1415
'prettier',
1516
],
1617
rules: {
@@ -19,11 +20,32 @@ module.exports = {
1920
'primer-react/no-system-props': ['error', {includeUtilityComponents: true}],
2021
},
2122
overrides: [
23+
{
24+
files: ['*.js'],
25+
extends: ['plugin:import/recommended'],
26+
},
2227
{
2328
files: ['src/shared.js'],
2429
rules: {
2530
'react/no-unescaped-entities': 'off',
2631
},
2732
},
33+
{
34+
files: ['*.mdx'],
35+
plugins: ['mdx', 'prettier'],
36+
extends: ['plugin:mdx/recommended'],
37+
parserOptions: {
38+
sourceType: 'module',
39+
},
40+
globals: getGlobals(['Index', 'Note', 'Prompt', 'PromptReply', 'Screenshot', 'Link', 'YouTube']),
41+
settings: {
42+
'import/resolver': 'webpack',
43+
},
44+
rules: {
45+
'no-irregular-whitespace': 'off',
46+
'jsx-a11y/anchor-has-content': 'off',
47+
'react/jsx-no-target-blank': 'off',
48+
},
49+
},
2850
],
2951
}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
!/content/
2424
!/CONTRIBUTING.md
2525
!/docs/
26-
!/gatsby-*.js
26+
!/gatsby-*
2727
!/jest*.js
2828
!/lib/
2929
!/LICENSE*
@@ -38,4 +38,5 @@
3838
!/static/
3939
!/tap-snapshots/
4040
!/test/
41+
!/webpack.config.js
4142
!/cli/

.reuse/dep5

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Files: content/* static/*
77
Copyright: 2020 GitHub
88
License: CC-BY-4.0
99

10-
Files: scripts/* cli/* theme/* src/* .github/* *.md *.js *.json .*
10+
Files: scripts/* cli/* theme/* src/* .github/* *.md *.js *.mjs *.json .*
1111
Copyright: 2020 GitHub
1212
License: MIT

cli/lib/extract.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const whackAMoleReplace = (s, replacements) => {
1212
// a bit of whack-a-mole but is necessary since markdown in the CLI is
1313
// different from the mdx v2 we parse for the docs site
1414
for (const rep of replacements) {
15-
s = s.replace(rep, rep.replace(/([<>])/g, '\\$1').replace(/([{}])/g, '\\$1'))
15+
s = s.replace(rep, rep.replace(/([<>{}])/g, '\\$1'))
1616
}
1717
return s
1818
}
@@ -29,6 +29,7 @@ const unpackTarball = async ({release, cwd, dir}) => {
2929
return (
3030
whackAMoleReplace(s, [
3131
'{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}',
32+
'node/{process.version} {process.platform} {process.arch}',
3233
'Default: {prefix}/etc/npmrc',
3334
])
3435
// we cant remove all emails since all except this one are in code blocks

content/cli/v6/using-npm/config.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ Folders and executables are given a mode which is `0777` masked against this val
10681068

10691069
#### user-agent
10701070

1071-
- Default: node/{process.version} {process.platform} {process.arch}
1071+
- Default: node/\{process.version\} \{process.platform\} \{process.arch\}
10721072
- Type: String
10731073

10741074
Sets a User-Agent to the request header

content/getting-started/managing-your-npm-user-account/changing-your-npm-username.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: Changing your npm username
33
---
4-
import shared from '~/shared.js'
54

65
It is not currently possible to change your npm username. You'll need to
76
create a new account and migrate the data to the new account manually.

content/getting-started/troubleshooting/generating-and-locating-npm-debug.log-files.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: Generating and locating npm-debug.log files
33
redirect_from:
44
- /generating-and-locating-npm-debug-log-files
55
---
6-
import shared from '~/shared.js'
76

87
When a package fails to install or publish, the npm CLI will generate an `npm-debug.log` file. This log file can help you figure out what went wrong.
98

content/organizations/managing-organization-packages/configuring-your-npm-client-with-your-organization-settings.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: Configuring your npm client with your organization settings
33
redirect_from:
44
- /configuring-your-npm-client-with-your-org-settings
55
---
6-
import shared from '~/shared.js'
76

87
As an organization member, you can configure your npm client to:
98

content/packages-and-modules/contributing-packages-to-the-registry/about-semantic-versioning.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ For more information on semantic versioning syntax, see the [npm semver calculat
4747

4848
## Resources
4949

50-
<iframe src="https://www.youtube.com/embed/kK4Meix58R4" frameborder="0" allowfullscreen></iframe>
50+
<YouTube id="kK4Meix58R4" />
5151

5252

5353
[semver-calc]: https://semver.npmjs.com/

content/packages-and-modules/contributing-packages-to-the-registry/creating-node-js-modules.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ exports.printMsg = function() {
6565

6666
## Resources
6767

68-
<iframe src="https://www.youtube.com/embed/3I78ELjTzlQ" frameborder="0" allowfullscreen></iframe>
68+
<YouTube id="3I78ELjTzlQ" />
6969

7070

7171
[about-pkgs]: about-packages-and-modules

content/packages-and-modules/getting-packages-from-the-registry/downloading-and-installing-packages-locally.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ npm install example-package@beta
6767

6868
## Resources
6969

70-
<iframe src="https://www.youtube.com/embed/JDSfqFFbNYQ" frameborder="0" allowfullscreen></iframe>
70+
<YouTube id="JDSfqFFbNYQ" />
7171

7272

7373
[scoped-public-pkg]: about-scopes

content/packages-and-modules/getting-packages-from-the-registry/uninstalling-packages-and-dependencies.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ npm uninstall -g jshint
8989

9090
### Uninstalling local packages
9191

92-
<iframe src="https://www.youtube.com/embed/Z-BpYj6cSoQ" frameborder="0" allowfullscreen></iframe>
92+
<YouTube id="Z-BpYj6cSoQ" />
9393

9494
### Uninstalling global packages
9595

96-
<iframe src="https://www.youtube.com/embed/XbvjZxUZJGg" frameborder="0" allowfullscreen></iframe>
96+
<YouTube id="XbvjZxUZJGg" />
9797

9898

9999
[cli-uninstall]: /cli/uninstall

content/packages-and-modules/getting-packages-from-the-registry/updating-packages-downloaded-from-the-registry.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ npm update -g
6969

7070
## Resources
7171

72-
<iframe src="https://www.youtube.com/embed/HRudtPGcOt4" frameborder="0" allowfullscreen></iframe>
72+
<YouTube id="HRudtPGcOt4" />
7373

7474
### CLI commands
7575

content/packages-and-modules/introduction-to-packages-and-modules/about-private-packages.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Private packages always have a scope, and scoped packages are private by default
2626

2727
## Resources
2828

29-
<iframe src="https://www.youtube.com/embed/O6JoXGnHK_Y" frameborder="0" allowfullscreen></iframe>
29+
<YouTube id="O6JoXGnHK_Y" />
3030

3131
[paid-acct]: https://www.npmjs.com/pricing
3232
[user-pkg-add]: adding-collaborators-to-private-packages-owned-by-a-user-account

gatsby-config.js renamed to gatsby-config.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
const path = require('path')
2-
const fs = require('fs')
1+
import path from 'path'
2+
import fs from 'fs'
3+
import remarkGfm from 'remark-gfm'
4+
import remarkFm from 'remark-frontmatter'
35

46
const {NODE_ENV, GATSBY_CONTENT_ALLOW, GATSBY_CONTENT_IGNORE, GATSBY_CONTENT_DIR = 'content'} = process.env
57
const DEV = NODE_ENV === 'development'
@@ -50,7 +52,7 @@ const getContentOptions = () => {
5052
}
5153
}
5254

53-
module.exports = {
55+
const config = {
5456
trailingSlash: 'never',
5557
siteMetadata: {
5658
title: 'npm Docs',
@@ -69,7 +71,9 @@ module.exports = {
6971
{
7072
resolve: 'gatsby-plugin-mdx',
7173
options: {
72-
extensions: ['.mdx', '.md'],
74+
mdxOptions: {
75+
remarkPlugins: [remarkGfm, remarkFm],
76+
},
7377
},
7478
},
7579
{
@@ -89,3 +93,5 @@ module.exports = {
8993
'gatsby-plugin-meta-redirect',
9094
],
9195
}
96+
97+
export default config

gatsby-node.js renamed to gatsby-node.mjs

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const {join, relative} = require('path')
2-
const {Octokit: CoreOctokit} = require('@octokit/rest')
3-
const {throttling} = require('@octokit/plugin-throttling')
4-
const {retry} = require('@octokit/plugin-retry')
1+
import {join, relative} from 'path'
2+
import {Octokit as CoreOctokit} from '@octokit/rest'
3+
import {throttling} from '@octokit/plugin-throttling'
4+
import {retry} from '@octokit/plugin-retry'
5+
import webpackConfig from './webpack.config.js'
56

67
const CI = !!process.env.CI
78
const CWD = process.cwd()
@@ -42,7 +43,7 @@ const createOctokit = ({reporter}) => {
4243
})
4344
}
4445

45-
exports.onCreateNode = ({node, actions, getNode}) => {
46+
export const onCreateNode = ({node, actions, getNode}) => {
4647
if (node.internal.type === 'Mdx') {
4748
const {name, relativeDirectory: dir} = getNode(node.parent)
4849

@@ -63,14 +64,9 @@ exports.onCreateNode = ({node, actions, getNode}) => {
6364
}
6465
}
6566

66-
exports.onCreateWebpackConfig = ({stage, actions}) => {
67+
export const onCreateWebpackConfig = ({stage, actions}) => {
6768
actions.setWebpackConfig({
68-
resolve: {
69-
alias: {
70-
'~': SRC,
71-
},
72-
extensions: ['.js'],
73-
},
69+
...webpackConfig,
7470
})
7571

7672
if (stage === `build-javascript`) {
@@ -80,7 +76,7 @@ exports.onCreateWebpackConfig = ({stage, actions}) => {
8076
}
8177
}
8278

83-
exports.createSchemaCustomization = ({actions: {createTypes}}) => {
79+
export const createSchemaCustomization = ({actions: {createTypes}}) => {
8480
createTypes(`
8581
type Mdx implements Node {
8682
frontmatter: MdxFrontmatter
@@ -101,7 +97,7 @@ exports.createSchemaCustomization = ({actions: {createTypes}}) => {
10197
`)
10298
}
10399

104-
exports.createPages = async ({graphql, actions, reporter}) => {
100+
export const createPages = async ({graphql, actions, reporter}) => {
105101
const response = await graphql(`
106102
{
107103
allMdx {

0 commit comments

Comments
 (0)