Skip to content

Commit

Permalink
[docs] Lint next.config.js (#11514)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Dec 31, 2023
1 parent 8885684 commit 7f27f6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// @ts-check
const path = require('path');
// @ts-ignore
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
// const withTM = require('next-transpile-modules')(['@mui/monorepo']);
// @ts-expect-error This expected error should be gone once we update the monorepo
const withDocsInfra = require('@mui/monorepo/docs/nextConfigDocsInfra');
const pkg = require('../package.json');
const dataGridPkg = require('../packages/grid/x-data-grid/package.json');
Expand All @@ -16,18 +19,18 @@ module.exports = withDocsInfra({
// Avoid conflicts with the other Next.js apps hosted under https://mui.com/
assetPrefix: process.env.DEPLOY_ENV === 'development' ? undefined : '/x',
env: {
// docs-infra
LIB_VERSION: pkg.version,
SOURCE_CODE_REPO: 'https://github.com/mui/mui-x',
SOURCE_GITHUB_BRANCH: 'next', // #default-branch-switch
GITHUB_TEMPLATE_DOCS_FEEDBACK: '6.docs-feedback.yml',
// MUI X related
DATA_GRID_VERSION: dataGridPkg.version,
DATE_PICKERS_VERSION: datePickersPkg.version,
CHARTS_VERSION: chartsPkg.version,
TREE_VIEW_VERSION: treeViewPkg.version,
FEEDBACK_URL: process.env.FEEDBACK_URL,
CONTEXT: process.env.CONTEXT,
// #default-branch-switch
SOURCE_GITHUB_BRANCH: 'next',
SOURCE_CODE_REPO: 'https://github.com/mui/mui-x',
GITHUB_TEMPLATE_DOCS_FEEDBACK: '6.docs-feedback.yml',
},
// @ts-ignore
webpack: (config, options) => {
const plugins = config.plugins.slice();

Expand Down Expand Up @@ -111,16 +114,19 @@ module.exports = withDocsInfra({
const pages = findPages();
const map = {};

// @ts-ignore
function traverse(pages2, userLanguage) {
const prefix = userLanguage === 'en' ? '' : `/${userLanguage}`;

// @ts-ignore
pages2.forEach((page) => {
// The experiments pages are only meant for experiments, they shouldn't leak to production.
if (page.pathname.includes('/experiments/') && process.env.DEPLOY_ENV === 'production') {
return;
}

if (!page.children) {
// @ts-ignore
map[`${prefix}${page.pathname.replace(/^\/api-docs\/(.*)/, '/api/$1')}`] = {
page: page.pathname,
query: {
Expand Down
1 change: 1 addition & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"pages/**/*.ts*",
"data/**/*",
"src/modules/components/**/*",
"next.config.js",
"../node_modules/@mui/material/themeCssVarsAugmentation",
"../node_modules/dayjs/plugin/utc.d.ts",
"../node_modules/dayjs/plugin/timezone.d.ts",
Expand Down

0 comments on commit 7f27f6f

Please sign in to comment.