Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix generate Proptypes script skipping unstable items #38198

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/mui-system/src/Unstable_Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,29 @@ Grid.propTypes /* remove-proptypes */ = {
PropTypes.func,
PropTypes.object,
]),
/**
* @internal
* The level of the grid starts from `0`
* and increases when the grid nests inside another grid regardless of container or item.
*
* ```js
* <Grid> // level 0
* <Grid> // level 1
* <Grid> // level 2
* <Grid> // level 1
* ```
*
* Only consecutive grid is considered nesting.
* A grid container will start at `0` if there are non-Grid element above it.
*
* ```js
* <Grid> // level 0
* <div>
* <Grid> // level 0
* <Grid> // level 1
* ```
*/
unstable_level: PropTypes.number,
/**
* Defines the `flex-wrap` style property.
* It's applied for all screen sizes.
Expand Down
16 changes: 10 additions & 6 deletions scripts/generateProptypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,18 @@ async function run(argv: HandlerArgv) {

const files = _.flatten(allFiles)
.filter((filePath) => {
const folderName = path.basename(path.dirname(filePath));
// Filter out files where the directory name and filename doesn't match
// Example: Modal/ModalManager.d.ts
let folderName = path.basename(path.dirname(filePath));
const fileName = path.basename(filePath).replace(/(\.d\.ts|\.tsx|\.ts)/g, '');

return (
// Filter out files where the directory name and filename doesn't match
// Example: Modal/ModalManager.d.ts
fileName === folderName
);
// An exception is if the folder name starts with Unstable_/unstable_
// Example: Unstable_Grid2/Grid2.tsx
if (/(u|U)nstable_/g.test(folderName)) {
folderName = folderName.slice(9);
}

return fileName === folderName;
})
.filter((filePath) => {
return filePattern.test(filePath);
Expand Down