Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ef68514

Browse files
authoredNov 25, 2024··
[core-infra] Add no-relative-packages (#44489)
1 parent 6fa088c commit ef68514

15 files changed

+67
-46
lines changed
 

‎.eslintrc.js

+31-32
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ module.exports = /** @type {Config} */ ({
242242

243243
// We re-export default in many places, remove when https://github.com/airbnb/javascript/issues/2500 gets resolved
244244
'no-restricted-exports': 'off',
245-
// Some of these occurences are deliberate and fixing them will break things in repos that use @monorepo dependency
246-
'import/no-relative-packages': 'off',
247245
// Avoid accidental auto-"fixes" https://github.com/jsx-eslint/eslint-plugin-react/issues/3458
248246
'react/no-invalid-html-attribute': 'off',
249247

@@ -304,15 +302,6 @@ module.exports = /** @type {Config} */ ({
304302
'react/no-unused-prop-types': 'off',
305303
},
306304
},
307-
{
308-
files: ['docs/src/modules/components/**/*.js'],
309-
rules: {
310-
'material-ui/no-hardcoded-labels': [
311-
'error',
312-
{ allow: ['MUI', 'X', 'GitHub', 'Stack Overflow'] },
313-
],
314-
},
315-
},
316305
// Next.js plugin
317306
{
318307
files: ['docs/**/*'],
@@ -325,18 +314,27 @@ module.exports = /** @type {Config} */ ({
325314
rules: {
326315
// We're not using the Image component at the moment
327316
'@next/next/no-img-element': 'off',
317+
'no-restricted-imports': [
318+
'error',
319+
{
320+
paths: NO_RESTRICTED_IMPORTS_PATHS_TOP_LEVEL_PACKAGES,
321+
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
322+
},
323+
],
328324
},
329325
},
330-
// Next.js entry points pages
331326
{
332-
files: ['docs/pages/**/*.?(c|m)[jt]s?(x)'],
327+
files: ['docs/src/modules/components/**/*'],
333328
rules: {
334-
'react/prop-types': 'off',
329+
'material-ui/no-hardcoded-labels': [
330+
'error',
331+
{ allow: ['MUI', 'X', 'GitHub', 'Stack Overflow'] },
332+
],
335333
},
336334
},
337335
// demos
338336
{
339-
files: ['docs/src/pages/**/*.?(c|m)[jt]s?(x)', 'docs/data/**/*.?(c|m)[jt]s?(x)'],
337+
files: ['docs/src/pages/**/*', 'docs/data/**/*'],
340338
rules: {
341339
// This most often reports data that is defined after the component definition.
342340
// This is safe to do and helps readability of the demo code since the data is mostly irrelevant.
@@ -346,8 +344,15 @@ module.exports = /** @type {Config} */ ({
346344
'no-console': 'off',
347345
},
348346
},
347+
// Next.js entry points pages
348+
{
349+
files: ['docs/pages/**/*'],
350+
rules: {
351+
'react/prop-types': 'off',
352+
},
353+
},
349354
{
350-
files: ['docs/data/**/*.?(c|m)[jt]s?(x)'],
355+
files: ['docs/data/**/*'],
351356
excludedFiles: [
352357
// filenames/match-exported sees filename as 'file-name.d'
353358
// Plugin looks unmaintain, find alternative? (e.g. eslint-plugin-project-structure)
@@ -359,6 +364,14 @@ module.exports = /** @type {Config} */ ({
359364
'filenames/match-exported': ['error'],
360365
},
361366
},
367+
{
368+
files: ['docs/data/material/getting-started/templates/**/*'],
369+
rules: {
370+
// So we can use # to improve the page UX
371+
// and so developer get eslint warning to remind them to fix the links
372+
'jsx-a11y/anchor-is-valid': 'off',
373+
},
374+
},
362375
{
363376
files: ['*.d.ts'],
364377
rules: {
@@ -442,18 +455,6 @@ module.exports = /** @type {Config} */ ({
442455
'no-bitwise': 'off',
443456
},
444457
},
445-
{
446-
files: ['docs/**/*.?(c|m)[jt]s?(x)'],
447-
rules: {
448-
'no-restricted-imports': [
449-
'error',
450-
{
451-
paths: NO_RESTRICTED_IMPORTS_PATHS_TOP_LEVEL_PACKAGES,
452-
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
453-
},
454-
],
455-
},
456-
},
457458
{
458459
files: ['packages/*/src/**/*.?(c|m)[jt]s?(x)'],
459460
excludedFiles: ['*.d.ts', '*.spec.*'],
@@ -530,11 +531,9 @@ module.exports = /** @type {Config} */ ({
530531
},
531532
},
532533
{
533-
files: ['docs/data/material/getting-started/templates/**/*'],
534+
files: ['apps/**/*'],
534535
rules: {
535-
// So we can use # to improve the page UX
536-
// and so developer get eslint warning to remind them to fix the links
537-
'jsx-a11y/anchor-is-valid': 'off',
536+
'import/no-relative-packages': 'off',
538537
},
539538
},
540539
],

‎dangerFileContent.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { exec } from 'child_process';
22
import type * as dangerModule from 'danger';
3+
import replaceUrl from '@mui-internal/api-docs-builder/utils/replaceUrl';
4+
// eslint-disable-next-line import/no-relative-packages
35
import { loadComparison } from './scripts/sizeSnapshot';
4-
import replaceUrl from './packages/api-docs-builder/utils/replaceUrl';
56

67
declare const danger: (typeof dangerModule)['danger'];
78
declare const markdown: (typeof dangerModule)['markdown'];

‎docs/scripts/updateIconSynonyms.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fetch from 'cross-fetch';
44
import fse from 'fs-extra';
55
import * as mui from '@mui/icons-material';
66
import synonyms from 'docs/data/material/components/material-icons/synonyms';
7+
// eslint-disable-next-line import/no-relative-packages
78
import myDestRewriter from '../../packages/mui-icons-material/renameFilters/material-design-icons';
89

910
function not(a, b) {

‎docs/src/modules/components/ApiPage/list/ClassesList.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default function ClassesList(props: ClassesListProps) {
8787
{description && <p dangerouslySetInnerHTML={{ __html: description }} />}
8888
{displayClassKeys && !isGlobal && (
8989
<p className="prop-list-class">
90+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
9091
<span className="prop-list-title">{'Rule name'}:</span>
9192
<code className="Api-code">{key}</code>
9293
</p>

‎docs/src/modules/components/ApiPage/list/PropertiesList.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ export default function PropertiesList(props: PropertiesListProps) {
157157
<React.Fragment>
158158
{propName}
159159
{isProPlan && (
160+
// eslint-disable-next-line material-ui/no-hardcoded-labels
160161
<a href="/x/introduction/licensing/#pro-plan" aria-label="Pro plan">
161162
<span className="plan-pro" />
162163
</a>
163164
)}
164165
{isPremiumPlan && (
166+
// eslint-disable-next-line material-ui/no-hardcoded-labels
165167
<a href="/x/introduction/licensing/#premium-plan" aria-label="Premium plan">
166168
<span className="plan-premium" />
167169
</a>

‎docs/src/modules/components/ApiPage/sections/ToggleDisplayOption.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export default function ToggleDisplayOption(props: ToggleDisplayOptionProps) {
117117
sx={{ height: '1.875rem', p: '6px 4px 6px 8px', textTransform: 'capitalize' }}
118118
>
119119
<Box component="span" sx={{ fontWeight: 'medium', mr: 0.5 }}>
120-
View:
120+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
121+
{'View:'}
121122
</Box>
122123
{displayOption}
123124
</Button>
@@ -136,7 +137,8 @@ export default function ToggleDisplayOption(props: ToggleDisplayOptionProps) {
136137
data-ga-event-action={sectionType}
137138
data-ga-event-label="table"
138139
>
139-
Table
140+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
141+
{'Table'}
140142
<CheckIcon
141143
sx={{ fontSize: '0.85rem', ml: 'auto', opacity: displayOption === 'table' ? 1 : 0 }}
142144
/>
@@ -149,7 +151,8 @@ export default function ToggleDisplayOption(props: ToggleDisplayOptionProps) {
149151
data-ga-event-action={sectionType}
150152
data-ga-event-label="expanded"
151153
>
152-
Expanded list
154+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
155+
{'Expanded list'}
153156
<CheckIcon
154157
sx={{ fontSize: '0.85rem', ml: 'auto', opacity: displayOption === 'expanded' ? 1 : 0 }}
155158
/>
@@ -162,7 +165,8 @@ export default function ToggleDisplayOption(props: ToggleDisplayOptionProps) {
162165
data-ga-event-action={sectionType}
163166
data-ga-event-label="collapsed"
164167
>
165-
Collapsed list
168+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
169+
{'Collapsed list'}
166170
<CheckIcon
167171
sx={{ fontSize: '0.85rem', ml: 'auto', opacity: displayOption === 'collapsed' ? 1 : 0 }}
168172
/>

‎docs/src/modules/components/ApiPage/table/ClassesTable.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ export default function ClassesTable(props: ClassesTableProps) {
6565
<StyledTable>
6666
<thead>
6767
<tr>
68-
<th>Class name</th>
69-
{displayClassKeys && <th>Rule name</th>}
70-
<th>Description</th>
68+
{/* eslint-disable material-ui/no-hardcoded-labels */}
69+
<th>{'Class name'}</th>
70+
{displayClassKeys && <th>{'Rule name'}</th>}
71+
<th>{'Description'}</th>
72+
{/* eslint-enable material-ui/no-hardcoded-labels */}
7173
</tr>
7274
</thead>
7375
<tbody>

‎docs/src/modules/components/ApiPage/table/PropertiesTable.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ export default function PropertiesTable(props: PropertiesTableProps) {
133133
<StyledTable>
134134
<thead>
135135
<tr>
136-
<th>Name</th>
137-
<th>Type</th>
138-
{hasDefaultColumn && <th>Default</th>}
139-
<th>Description</th>
136+
{/* eslint-disable material-ui/no-hardcoded-labels */}
137+
<th>{'Name'}</th>
138+
<th>{'Type'}</th>
139+
{hasDefaultColumn && <th>{'Default'}</th>}
140+
<th>{'Description'}</th>
141+
{/* eslint-enable material-ui/no-hardcoded-labels */}
140142
</tr>
141143
</thead>
142144
<tbody>
@@ -168,11 +170,13 @@ export default function PropertiesTable(props: PropertiesTableProps) {
168170
{isRequired ? '*' : ''}
169171
{isOptional ? '?' : ''}
170172
{isProPlan && (
173+
// eslint-disable-next-line material-ui/no-hardcoded-labels
171174
<a href="/x/introduction/licensing/#pro-plan" aria-label="Pro plan">
172175
<span className="plan-pro" />
173176
</a>
174177
)}
175178
{isPremiumPlan && (
179+
// eslint-disable-next-line material-ui/no-hardcoded-labels
176180
<a href="/x/introduction/licensing/#premium-plan" aria-label="Premium plan">
177181
<span className="plan-premium" />
178182
</a>

‎docs/src/modules/components/ApiPage/table/SlotsTable.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export default function SlotsTable(props: SlotsTableProps) {
9797
{name}
9898
</td>
9999
<td className="MuiApi-table-class-name">
100+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
100101
{className && <span className="class-name">{`.${className}`}</span>}
101102
</td>
102103
<td>{defaultValue && <code className="item-default">{defaultValue}</code>}</td>

‎docs/src/modules/components/JoyThemeBuilder.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable material-ui/no-hardcoded-labels */
12
import * as React from 'react';
23
import TypeScriptIcon from '@mui/docs/svgIcons/TypeScript';
34
import startCase from 'lodash/startCase';

‎docs/src/modules/components/JoyUsageDemo.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable material-ui/no-hardcoded-labels */
12
import * as React from 'react';
23
import Check from '@mui/icons-material/Check';
34
import CheckRounded from '@mui/icons-material/CheckRounded';

‎docs/src/modules/components/JoyVariablesDemo.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable material-ui/no-hardcoded-labels */
12
import * as React from 'react';
23
import Box from '@mui/joy/Box';
34
import Divider from '@mui/joy/Divider';

‎docs/src/modules/components/MuiProductSelector.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ const MuiProductSelector = React.forwardRef(function MuiProductSelector(
260260
},
261261
}}
262262
>
263+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
263264
<NavLabel>MUI X Components</NavLabel>
264265
</Box>
265266
{advancedProducts.map((product) => (
@@ -292,6 +293,7 @@ const MuiProductSelector = React.forwardRef(function MuiProductSelector(
292293
}}
293294
>
294295
<Box sx={{ display: 'flex', alignItems: 'center', gap: '1px' }}>
296+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
295297
<NavLabel> Toolpad </NavLabel>
296298
<Chip
297299
label="Beta"

‎docs/src/modules/components/ThemeViewer.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function ObjectEntryLabel(props: { objectKey: string; objectValue: any }) {
8181

8282
return (
8383
<React.Fragment>
84+
{/* eslint-disable-next-line material-ui/no-hardcoded-labels */}
8485
{`${objectKey}: `}
8586
{type === 'color' ? (
8687
<Color style={{ borderColor: lighten(label, 0.7) }}>

‎packages/rsc-builder/buildRsc.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import path from 'path';
22
import * as yargs from 'yargs';
33
import * as fse from 'fs-extra';
4-
import findComponents from '../api-docs-builder/utils/findComponents';
5-
import findHooks from '../api-docs-builder/utils/findHooks';
4+
import findComponents from '@mui-internal/api-docs-builder/utils/findComponents';
5+
import findHooks from '@mui-internal/api-docs-builder/utils/findHooks';
66

77
type CommandOptions = { grep?: string };
88

0 commit comments

Comments
 (0)
Please sign in to comment.