diff --git a/docs/scripts/api/buildApi.ts b/docs/scripts/api/buildApi.ts index 8de8ebb379aa6..6a0fa5a20f463 100644 --- a/docs/scripts/api/buildApi.ts +++ b/docs/scripts/api/buildApi.ts @@ -1,5 +1,6 @@ /* eslint-disable no-await-in-loop */ -import * as yargs from 'yargs'; +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import path from 'path'; import fs from 'fs'; import * as prettier from 'prettier'; @@ -143,7 +144,7 @@ async function run() { }); } -yargs +yargs(hideBin(process.argv)) .command({ command: '$0', describe: 'generates API docs', diff --git a/docs/scripts/api/buildGridEventsDocumentation.ts b/docs/scripts/api/buildGridEventsDocumentation.ts index c793d16488e28..429be08348335 100644 --- a/docs/scripts/api/buildGridEventsDocumentation.ts +++ b/docs/scripts/api/buildGridEventsDocumentation.ts @@ -1,6 +1,6 @@ import * as ts from 'typescript'; import path from 'path'; -import { renderMarkdown } from '@mui/monorepo/packages/markdown'; +import { renderMarkdown } from '@mui/internal-markdown'; import { DocumentedInterfaces, getSymbolDescription, diff --git a/docs/scripts/api/buildInterfacesDocumentation.ts b/docs/scripts/api/buildInterfacesDocumentation.ts index 9846d1828bd70..91b9a814a355c 100644 --- a/docs/scripts/api/buildInterfacesDocumentation.ts +++ b/docs/scripts/api/buildInterfacesDocumentation.ts @@ -2,7 +2,7 @@ import * as ts from 'typescript'; import { EOL } from 'os'; import kebabCase from 'lodash/kebabCase'; import path from 'path'; -import { renderMarkdown } from '@mui/monorepo/packages/markdown'; +import { renderMarkdown } from '@mui/internal-markdown'; import { getSymbolDescription, getSymbolJSDocTags, diff --git a/docs/scripts/generateProptypes.ts b/docs/scripts/generateProptypes.ts index b43a78c8c0b3a..5d7f3c8ec5537 100644 --- a/docs/scripts/generateProptypes.ts +++ b/docs/scripts/generateProptypes.ts @@ -1,4 +1,5 @@ -import * as yargs from 'yargs'; +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import * as path from 'path'; import * as fse from 'fs-extra'; import * as prettier from 'prettier'; @@ -199,7 +200,7 @@ async function run() { } } -yargs +yargs(hideBin(process.argv)) .command({ command: '$0', describe: 'Generates Component.propTypes from TypeScript declarations', diff --git a/docs/scripts/tsconfig.json b/docs/scripts/tsconfig.json index b520e8217b3ff..8d881a3158a43 100644 --- a/docs/scripts/tsconfig.json +++ b/docs/scripts/tsconfig.json @@ -1,10 +1,6 @@ { "extends": "../../tsconfig.json", - "include": [ - "../../node_modules/@mui/monorepo/packages/api-docs-builder/react-docgen.d.ts", - "api/buildApi.ts", - "i18n.js" - ], + "include": ["api/buildApi.ts", "i18n.js"], "compilerOptions": { "allowJs": true, "isolatedModules": true, diff --git a/package.json b/package.json index 66efa03aa0ad1..f52f84ebe4f38 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "@octokit/rest": "^20.1.1", "@playwright/test": "^1.44.1", "@testing-library/react": "^15.0.7", + "@types/babel__traverse": "^7.20.6", "@types/babel__core": "^7.20.5", "@types/chai": "^4.3.16", "@types/chai-dom": "^1.11.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69974a9d75e63..9ec103ab9feba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -116,6 +116,9 @@ importers: '@types/babel__core': specifier: ^7.20.5 version: 7.20.5 + '@types/babel__traverse': + specifier: ^7.20.6 + version: 7.20.6 '@types/chai': specifier: ^4.3.16 version: 4.3.16 @@ -3560,8 +3563,8 @@ packages: '@types/babel__template@7.4.4': resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} - '@types/babel__traverse@7.20.5': - resolution: {integrity: sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==} + '@types/babel__traverse@7.20.6': + resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} '@types/body-parser@1.19.5': resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} @@ -12424,7 +12427,7 @@ snapshots: '@babel/types': 7.24.7 '@types/babel__generator': 7.6.8 '@types/babel__template': 7.4.4 - '@types/babel__traverse': 7.20.5 + '@types/babel__traverse': 7.20.6 '@types/babel__generator@7.6.8': dependencies: @@ -12435,7 +12438,7 @@ snapshots: '@babel/parser': 7.24.7 '@babel/types': 7.24.7 - '@types/babel__traverse@7.20.5': + '@types/babel__traverse@7.20.6': dependencies: '@babel/types': 7.24.7 diff --git a/prettier.config.js b/prettier.config.js index 7193b2e61f63f..acacfecf7465b 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,14 +1 @@ -const baseline = require('@mui/monorepo/prettier.config'); - -module.exports = { - ...baseline, - overrides: [ - ...baseline.overrides, - { - files: ['**/*.json'], - options: { - trailingComma: 'none', - }, - }, - ], -}; +module.exports = require('@mui/monorepo/prettier.config'); diff --git a/scripts/build.mjs b/scripts/build.mjs index be84e43de6a7c..d7260f8ec0daf 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -4,6 +4,7 @@ import glob from 'fast-glob'; import path from 'path'; import { promisify } from 'util'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { getWorkspaceRoot } from './utils.mjs'; const exec = promisify(childProcess.exec); @@ -102,7 +103,7 @@ async function run(argv) { } } -yargs(process.argv.slice(2)) +yargs(hideBin(process.argv)) .command({ command: '$0 ', description: 'build package', diff --git a/scripts/buildApiDocs/index.ts b/scripts/buildApiDocs/index.ts index 18de84d57543e..7be8e1fb4cab2 100644 --- a/scripts/buildApiDocs/index.ts +++ b/scripts/buildApiDocs/index.ts @@ -1,4 +1,5 @@ import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { ProjectSettings, buildApi } from '@mui-internal/api-docs-builder'; import { projectPickersSettings } from './pickersSettings'; import { projectChartsSettings } from './chartsSettings'; @@ -19,7 +20,7 @@ async function run(argv: yargs.ArgumentsCamelCase) { return buildApi(projectSettings, grep); } -yargs(process.argv.slice(2)) +yargs(hideBin(process.argv)) .command({ command: '$0', describe: 'Generates API documentation for the MUI packages.', diff --git a/scripts/l10n.ts b/scripts/l10n.ts index 87c0d94af9596..9c584b69229a3 100644 --- a/scripts/l10n.ts +++ b/scripts/l10n.ts @@ -5,7 +5,8 @@ import traverse from '@babel/traverse'; import * as prettier from 'prettier'; import * as babel from '@babel/core'; import * as babelTypes from '@babel/types'; -import * as yargs from 'yargs'; +import yargs, { ArgumentsCamelCase } from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { Octokit } from '@octokit/rest'; import { retry } from '@octokit/plugin-retry'; import localeNames from './localeNames'; @@ -14,6 +15,7 @@ import { SOURCE_GITHUB_BRANCH as DOCS_SOURCE_GITHUB_BRANCH, } from '../docs/constants'; +// @ts-ignore const MyOctokit = Octokit.plugin(retry); const GIT_ORGANIZATION = 'mui'; @@ -190,7 +192,7 @@ function findLocales(localesDirectory: string, constantsPath: string) { } function extractAndReplaceTranslations(localePath: string) { - const translations = {}; + const translations: Translations = {}; const file = fse.readFileSync(localePath, { encoding: 'utf-8' }); const { code } = babel.transformSync(file, { plugins: [...BABEL_PLUGINS, plugin(translations)], @@ -315,7 +317,7 @@ type DocumentationReportItem = { }; const generateDocReport = async ( missingTranslations: MissingTranslations, - baseTranslationsNumber, + baseTranslationsNumber: TranslationsNumber, ) => { const workspaceRoot = path.resolve(__dirname, '../'); @@ -331,7 +333,7 @@ const generateDocReport = async ( importName.length > 2 ? `${importName.slice(0, 2).toLowerCase()}-${importName.slice(2).toUpperCase()}` : importName; - const localeName = localeNames[languageTag]; + const localeName = localeNames[languageTag as keyof typeof localeNames]; if (localeName === undefined) { throw new Error( @@ -362,7 +364,7 @@ const generateDocReport = async ( }); }; -async function updateIssue(githubToken, newMessage) { +async function updateIssue(githubToken: string, newMessage: string) { // Initialize the API client const octokit = new MyOctokit({ auth: githubToken, @@ -394,12 +396,14 @@ interface HandlerArgv { githubToken?: string; } -async function run(argv: yargs.ArgumentsCamelCase) { +type TranslationsNumber = Record; + +async function run(argv: ArgumentsCamelCase) { const { report, githubToken } = argv; const workspaceRoot = path.resolve(__dirname, '../'); - const missingTranslations: Record = {}; - const baseTranslationsNumber: Record = {}; + const missingTranslations: MissingTranslations = {}; + const baseTranslationsNumber: TranslationsNumber = {}; await Promise.all( packagesWithL10n.map(async (packageInfo) => { @@ -491,7 +495,7 @@ async function run(argv: yargs.ArgumentsCamelCase) { process.exit(0); } -yargs +yargs(hideBin(process.argv)) .command({ command: '$0', describe: 'Syncs translation files.', diff --git a/scripts/prettier.mjs b/scripts/prettier.mjs deleted file mode 100644 index e3a1574594982..0000000000000 --- a/scripts/prettier.mjs +++ /dev/null @@ -1 +0,0 @@ -import '@mui/monorepo/scripts/prettier.mjs'; diff --git a/scripts/releaseChangelog.mjs b/scripts/releaseChangelog.mjs index 25d39443f38bd..6e4b0f22c2342 100644 --- a/scripts/releaseChangelog.mjs +++ b/scripts/releaseChangelog.mjs @@ -1,6 +1,7 @@ /* eslint-disable no-restricted-syntax */ import { Octokit } from '@octokit/rest'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; const GIT_ORGANIZATION = 'mui'; const GIT_REPO = 'mui-x'; @@ -43,7 +44,7 @@ async function findLatestTaggedVersion(octokit) { } function resolvePackagesByLabels(labels) { - let resolvedPackages = []; + const resolvedPackages = []; labels.forEach((label) => { switch (label.name) { case 'component: data grid': @@ -323,7 +324,7 @@ ${logChangelogSection(otherCommits, '')} console.log(changelog); } -yargs(process.argv.slice(2)) +yargs(hideBin(process.argv)) .command({ command: '$0', description: 'Creates a changelog', diff --git a/scripts/releaseTag.mjs b/scripts/releaseTag.mjs index 8900370390a2e..e1a009c958ab5 100644 --- a/scripts/releaseTag.mjs +++ b/scripts/releaseTag.mjs @@ -3,6 +3,7 @@ import fse from 'fs-extra'; import path from 'path'; import { promisify } from 'util'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { getWorkspaceRoot } from './utils.mjs'; /** @@ -75,7 +76,7 @@ async function main(argv) { ); } -yargs(process.argv.slice(2)) +yargs(hideBin(process.argv)) .command({ command: '$0', description: 'Tags the current release and pushes these changes to mui/mui-x.', diff --git a/scripts/treeDataFromFileTree.ts b/scripts/treeDataFromFileTree.ts index 8a67221fcc6de..cfeb841f7f5b9 100644 --- a/scripts/treeDataFromFileTree.ts +++ b/scripts/treeDataFromFileTree.ts @@ -1,6 +1,7 @@ import { promises as fs, Stats } from 'fs'; import path from 'path'; -import * as yargs from 'yargs'; +import yargs, { ArgumentsCamelCase } from 'yargs'; +import { hideBin } from 'yargs/helpers'; interface Node { hierarchy: string[]; @@ -49,7 +50,7 @@ const getSubTree = async (nodePath: string, parentHierarchy: string[] = []) => { return nodes; }; -const run = async (argv: yargs.ArgumentsCamelCase<{ path: string }>) => { +const run = async (argv: ArgumentsCamelCase<{ path: string }>) => { const children = await fs.readdir(argv.path); const nodes: Node[] = []; @@ -68,7 +69,7 @@ const run = async (argv: yargs.ArgumentsCamelCase<{ path: string }>) => { ); }; -yargs +yargs(hideBin(process.argv)) .command({ command: '$0', describe: 'Generate tree data rows from a folder.',