@mui/internal-code-infra 0.0.4-canary.9 → 0.0.4-canary.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -8
  3. package/build/babel-config.d.mts +5 -1
  4. package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
  5. package/build/brokenLinksChecker/index.d.mts +45 -2
  6. package/build/changelog/types.d.ts +3 -1
  7. package/build/cli/cmdArgosPush.d.mts +2 -2
  8. package/build/cli/cmdBuild.d.mts +3 -2
  9. package/build/cli/cmdCopyFiles.d.mts +2 -2
  10. package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
  11. package/build/cli/cmdGenerateChangelog.d.mts +2 -2
  12. package/build/cli/cmdGithubAuth.d.mts +2 -2
  13. package/build/cli/cmdListWorkspaces.d.mts +6 -4
  14. package/build/cli/cmdNetlifyIgnore.d.mts +3 -2
  15. package/build/cli/cmdPublish.d.mts +4 -2
  16. package/build/cli/cmdPublishCanary.d.mts +3 -3
  17. package/build/cli/cmdPublishNewPackage.d.mts +4 -2
  18. package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
  19. package/build/cli/cmdVale.d.mts +46 -0
  20. package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
  21. package/build/eslint/baseConfig.d.mts +3 -1
  22. package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
  23. package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
  24. package/build/eslint/mui/rules/no-floating-cleanup.d.mts +5 -0
  25. package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
  26. package/build/eslint/mui/rules/no-presentation-role.d.mts +5 -0
  27. package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
  28. package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
  29. package/build/remark/config.d.mts +43 -0
  30. package/build/remark/createLintTester.d.mts +10 -0
  31. package/build/remark/firstBlockHeading.d.mts +4 -0
  32. package/build/remark/gitDiff.d.mts +2 -0
  33. package/build/remark/noSpaceInLinks.d.mts +2 -0
  34. package/build/remark/straightQuotes.d.mts +2 -0
  35. package/build/remark/tableAlignment.d.mts +2 -0
  36. package/build/remark/terminalLanguage.d.mts +2 -0
  37. package/build/utils/babel.d.mts +1 -1
  38. package/build/utils/build.d.mts +56 -37
  39. package/build/utils/git.d.mts +7 -0
  40. package/build/utils/github.d.mts +1 -1
  41. package/build/utils/pnpm.d.mts +81 -2
  42. package/build/utils/testUtils.d.mts +7 -0
  43. package/build/utils/typescript.d.mts +6 -16
  44. package/package.json +74 -50
  45. package/src/babel-config.mjs +3 -1
  46. package/src/brokenLinksChecker/crawlWorker.mjs +240 -0
  47. package/src/brokenLinksChecker/index.mjs +263 -188
  48. package/src/changelog/fetchChangelogs.mjs +8 -2
  49. package/src/changelog/renderChangelog.mjs +1 -1
  50. package/src/changelog/types.ts +3 -1
  51. package/src/cli/cmdBuild.mjs +51 -85
  52. package/src/cli/cmdListWorkspaces.mjs +12 -27
  53. package/src/cli/cmdNetlifyIgnore.mjs +34 -93
  54. package/src/cli/cmdPublish.mjs +95 -20
  55. package/src/cli/cmdPublishCanary.mjs +128 -132
  56. package/src/cli/cmdPublishNewPackage.mjs +27 -6
  57. package/src/cli/cmdSetVersionOverrides.mjs +8 -9
  58. package/src/cli/cmdVale.mjs +513 -0
  59. package/src/cli/index.mjs +2 -0
  60. package/src/cli/packageJson.d.ts +2 -3
  61. package/src/eslint/baseConfig.mjs +51 -19
  62. package/src/eslint/docsConfig.mjs +2 -1
  63. package/src/eslint/mui/config.mjs +24 -4
  64. package/src/eslint/mui/index.mjs +6 -0
  65. package/src/eslint/mui/rules/no-floating-cleanup.mjs +187 -0
  66. package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
  67. package/src/eslint/mui/rules/no-presentation-role.mjs +60 -0
  68. package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
  69. package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
  70. package/src/estree-typescript.d.ts +1 -1
  71. package/src/remark/config.mjs +157 -0
  72. package/src/remark/createLintTester.mjs +19 -0
  73. package/src/remark/firstBlockHeading.mjs +87 -0
  74. package/src/remark/gitDiff.mjs +43 -0
  75. package/src/remark/noSpaceInLinks.mjs +42 -0
  76. package/src/remark/straightQuotes.mjs +31 -0
  77. package/src/remark/tableAlignment.mjs +23 -0
  78. package/src/remark/terminalLanguage.mjs +19 -0
  79. package/src/untyped-plugins.d.ts +11 -11
  80. package/src/utils/build.mjs +604 -270
  81. package/src/utils/git.mjs +27 -7
  82. package/src/utils/pnpm.mjs +277 -10
  83. package/src/utils/testUtils.mjs +18 -0
  84. package/src/utils/typescript.mjs +23 -42
  85. package/vale/.vale.ini +1 -0
  86. package/vale/styles/MUI/CorrectReferenceAllCases.yml +42 -0
  87. package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
  88. package/vale/styles/MUI/GoogleLatin.yml +11 -0
  89. package/vale/styles/MUI/MuiBrandName.yml +22 -0
  90. package/vale/styles/MUI/NoBritish.yml +112 -0
  91. package/vale/styles/MUI/NoCompanyName.yml +17 -0
  92. package/build/markdownlint/duplicate-h1.d.mts +0 -56
  93. package/build/markdownlint/git-diff.d.mts +0 -11
  94. package/build/markdownlint/index.d.mts +0 -52
  95. package/build/markdownlint/straight-quotes.d.mts +0 -11
  96. package/build/markdownlint/table-alignment.d.mts +0 -11
  97. package/build/markdownlint/terminal-language.d.mts +0 -11
  98. package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
  99. package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
  100. package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
  101. package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
  102. package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
  103. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -28
  104. package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
  105. package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
  106. package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
  107. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
  108. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
  109. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
  110. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
  111. package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
  112. package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
  113. package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
  114. package/src/brokenLinksChecker/index.test.ts +0 -261
  115. package/src/changelog/categorizeCommits.test.ts +0 -319
  116. package/src/changelog/filterCommits.test.ts +0 -363
  117. package/src/changelog/parseCommitLabels.test.ts +0 -509
  118. package/src/changelog/renderChangelog.test.ts +0 -378
  119. package/src/changelog/sortSections.test.ts +0 -199
  120. package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
  121. package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
  122. package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
  123. package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
  124. package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
  125. package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
  126. package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
  127. package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
  128. package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
  129. package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
  130. package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
  131. package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
  132. package/src/markdownlint/duplicate-h1.mjs +0 -69
  133. package/src/markdownlint/git-diff.mjs +0 -31
  134. package/src/markdownlint/index.mjs +0 -62
  135. package/src/markdownlint/straight-quotes.mjs +0 -26
  136. package/src/markdownlint/table-alignment.mjs +0 -42
  137. package/src/markdownlint/terminal-language.mjs +0 -19
  138. package/src/utils/build.test.mjs +0 -705
  139. package/src/utils/template.test.mjs +0 -133
  140. package/src/utils/typescript.test.mjs +0 -380
@@ -1,247 +0,0 @@
1
- import eslint from 'eslint';
2
- import parser from '@typescript-eslint/parser';
3
- import rule from './mui-name-matches-component-name.mjs';
4
-
5
- const ruleTester = new eslint.RuleTester({
6
- languageOptions: {
7
- parser,
8
- },
9
- });
10
-
11
- ruleTester.run('mui-name-matches-component-name', rule, {
12
- valid: [
13
- // useThemeProps
14
- `
15
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
16
- inProps: StaticDateRangePickerProps<TDate>,
17
- ref: React.Ref<HTMLDivElement>,
18
- ) {
19
- const props = useThemeProps({ props: inProps, name: 'MuiStaticDateRangePicker' });
20
- });
21
- `,
22
- `
23
- function CssBaseline(inProps) {
24
- useThemeProps({ props: inProps, name: 'MuiCssBaseline' });
25
- }
26
- `,
27
- `
28
- const Container = createContainer({
29
- createStyledComponent: styled('div', {
30
- name: 'MuiContainer',
31
- slot: 'Root',
32
- overridesResolver: (props, styles) => {
33
- const { ownerState } = props;
34
-
35
- return [
36
- styles.root,
37
- ownerState.fixed && styles.fixed,
38
- ownerState.disableGutters && styles.disableGutters,
39
- ];
40
- },
41
- }),
42
- useThemeProps: (inProps) => useThemeProps({ props: inProps, name: 'MuiContainer' }),
43
- });
44
- `,
45
- `
46
- const Grid = createGrid({
47
- createStyledComponent: styled('div', {
48
- name: 'MuiGrid',
49
- overridesResolver: (props, styles) => styles.root,
50
- }),
51
- componentName: 'MuiGrid',
52
- useThemeProps: (inProps) => useThemeProps({ props: inProps, name: 'MuiGrid' }),
53
- }) as OverridableComponent<GridTypeMap>;
54
- `,
55
- {
56
- code: `
57
- function useDatePickerDefaultizedProps(props, name) {
58
- useThemeProps({ props, name });
59
- }
60
- `,
61
- options: [{ customHooks: ['useDatePickerDefaultizedProps'] }],
62
- },
63
- // ================
64
- // useDefaultProps
65
- `
66
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
67
- inProps: StaticDateRangePickerProps<TDate>,
68
- ref: React.Ref<HTMLDivElement>,
69
- ) {
70
- const props = useDefaultProps({ props: inProps, name: 'MuiStaticDateRangePicker' });
71
- });
72
- `,
73
- `
74
- function CssBaseline(inProps) {
75
- useDefaultProps({ props: inProps, name: 'MuiCssBaseline' });
76
- }
77
- `,
78
- `
79
- const Container = createContainer({
80
- createStyledComponent: styled('div', {
81
- name: 'MuiContainer',
82
- slot: 'Root',
83
- overridesResolver: (props, styles) => {
84
- const { ownerState } = props;
85
-
86
- return [
87
- styles.root,
88
- ownerState.fixed && styles.fixed,
89
- ownerState.disableGutters && styles.disableGutters,
90
- ];
91
- },
92
- }),
93
- useDefaultProps: (inProps) => useDefaultProps({ props: inProps, name: 'MuiContainer' }),
94
- });
95
- `,
96
- `
97
- const Grid = createGrid({
98
- createStyledComponent: styled('div', {
99
- name: 'MuiGrid',
100
- overridesResolver: (props, styles) => styles.root,
101
- }),
102
- componentName: 'MuiGrid',
103
- useDefaultProps: (inProps) => useDefaultProps({ props: inProps, name: 'MuiGrid' }),
104
- }) as OverridableComponent<GridTypeMap>;
105
- `,
106
- {
107
- code: `
108
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
109
- inProps: StaticDateRangePickerProps<TDate>,
110
- ref: React.Ref<HTMLDivElement>,
111
- ) {
112
- const props = useDatePickerDefaultizedProps(inProps, 'MuiStaticDateRangePicker');
113
- });
114
- `,
115
- options: [{ customHooks: ['useDatePickerDefaultizedProps'] }],
116
- },
117
- {
118
- code: `
119
- function useDatePickerDefaultizedProps(props, name) {
120
- useDefaultProps({ props, name });
121
- }
122
- `,
123
- options: [{ customHooks: ['useDatePickerDefaultizedProps'] }],
124
- },
125
- ],
126
- invalid: [
127
- // useThemeProps
128
- {
129
- code: `
130
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
131
- inProps: StaticDateRangePickerProps<TDate>,
132
- ref: React.Ref<HTMLDivElement>,
133
- ) {
134
- const props = useThemeProps({ props: inProps, name: 'MuiPickersDateRangePicker' });
135
- });
136
- `,
137
- errors: [
138
- {
139
- message:
140
- "Expected `name` to be 'MuiStaticDateRangePicker' but instead got 'MuiPickersDateRangePicker'.",
141
- },
142
- ],
143
- },
144
- {
145
- code: 'useThemeProps({ props: inProps })',
146
- errors: [
147
- {
148
- message: 'Unable to find `name` property. Did you forget to pass `name`?',
149
- },
150
- ],
151
- },
152
- {
153
- code: 'useThemeProps({ props: inProps, name })',
154
- errors: [
155
- {
156
- message:
157
- 'Unable to resolve `name`. Please hardcode the `name` i.e. use a string literal.',
158
- },
159
- ],
160
- },
161
- {
162
- code: "useThemeProps({ props: inProps, name: 'MuiPickersDateRangePicker' })",
163
- errors: [
164
- {
165
- message: 'Unable to find component for this call.',
166
- },
167
- ],
168
- },
169
- {
170
- code: `
171
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
172
- inProps: StaticDateRangePickerProps<TDate>,
173
- ref: React.Ref<HTMLDivElement>,
174
- ) {
175
- const props = useDatePickerDefaultizedProps(inProps, 'MuiPickersDateRangePicker');
176
- });
177
- `,
178
- options: [{ customHooks: ['useDatePickerDefaultizedProps'] }],
179
- errors: [
180
- {
181
- message:
182
- "Expected `name` to be 'MuiStaticDateRangePicker' but instead got 'MuiPickersDateRangePicker'.",
183
- },
184
- ],
185
- },
186
- // ================
187
- // useDefaultProps
188
- {
189
- code: `
190
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
191
- inProps: StaticDateRangePickerProps<TDate>,
192
- ref: React.Ref<HTMLDivElement>,
193
- ) {
194
- const props = useDefaultProps({ props: inProps, name: 'MuiPickersDateRangePicker' });
195
- });
196
- `,
197
- errors: [
198
- {
199
- message:
200
- "Expected `name` to be 'MuiStaticDateRangePicker' but instead got 'MuiPickersDateRangePicker'.",
201
- },
202
- ],
203
- },
204
- {
205
- code: 'useDefaultProps({ props: inProps })',
206
- errors: [
207
- {
208
- message: 'Unable to find `name` property. Did you forget to pass `name`?',
209
- },
210
- ],
211
- },
212
- {
213
- code: 'useDefaultProps({ props: inProps, name })',
214
- errors: [
215
- {
216
- message:
217
- 'Unable to resolve `name`. Please hardcode the `name` i.e. use a string literal.',
218
- },
219
- ],
220
- },
221
- {
222
- code: "useDefaultProps({ props: inProps, name: 'MuiPickersDateRangePicker' })",
223
- errors: [
224
- {
225
- message: 'Unable to find component for this call.',
226
- },
227
- ],
228
- },
229
- {
230
- code: `
231
- const StaticDateRangePicker = React.forwardRef(function StaticDateRangePicker<TDate>(
232
- inProps: StaticDateRangePickerProps<TDate>,
233
- ref: React.Ref<HTMLDivElement>,
234
- ) {
235
- const props = useDatePickerDefaultizedProps(inProps);
236
- });
237
- `,
238
- options: [{ customHooks: ['useDatePickerDefaultizedProps'] }],
239
- errors: [
240
- {
241
- message:
242
- "Unable to find name argument. Expected `useDatePickerDefaultizedProps(firstParameter, 'MuiComponent')`.",
243
- },
244
- ],
245
- },
246
- ],
247
- });
@@ -1,40 +0,0 @@
1
- import eslint from 'eslint';
2
- import parser from '@typescript-eslint/parser';
3
- import rule from './no-empty-box.mjs';
4
-
5
- const ruleTester = new eslint.RuleTester({
6
- languageOptions: {
7
- parser,
8
- parserOptions: {
9
- ecmaFeatures: { jsx: true },
10
- },
11
- },
12
- });
13
-
14
- ruleTester.run('no-empty-box', rule, {
15
- valid: ['<Box sx={{ width: 1 }}>Foo</Box>', '<Box sx={{ width: 1 }} />', '<Box {...props} />'],
16
- invalid: [
17
- {
18
- code: '<Box>Foo</Box>',
19
- errors: [
20
- {
21
- messageId: 'emptyBox',
22
- data: {
23
- component: 'div',
24
- },
25
- },
26
- ],
27
- },
28
- {
29
- code: '<Box component="span">Foo</Box>',
30
- errors: [
31
- {
32
- messageId: 'emptyBox',
33
- data: {
34
- component: 'span',
35
- },
36
- },
37
- ],
38
- },
39
- ],
40
- });
@@ -1,73 +0,0 @@
1
- import eslint from 'eslint';
2
- import parser from '@typescript-eslint/parser';
3
- import rule from './no-styled-box.mjs';
4
-
5
- const ruleTester = new eslint.RuleTester({
6
- languageOptions: {
7
- parser,
8
- parserOptions: {
9
- ecmaFeatures: { jsx: true },
10
- },
11
- },
12
- });
13
-
14
- ruleTester.run('no-styled-box', rule, {
15
- valid: [
16
- `
17
- import { styled } from '@mui/system';
18
- styled('div');
19
- `,
20
- `
21
- import { styled } from '@mui/system';
22
- styled('div', {});
23
- `,
24
- ],
25
- invalid: [
26
- {
27
- code: `
28
- import { styled } from '@mui/system';
29
- import Box from '@mui/material/Box';
30
-
31
- const foo = styled(Box)({
32
- color: 'red',
33
- });
34
- `,
35
- errors: [
36
- {
37
- messageId: 'noBox',
38
- },
39
- ],
40
- output: `
41
- import { styled } from '@mui/system';
42
- import Box from '@mui/material/Box';
43
-
44
- const foo = styled('div')({
45
- color: 'red',
46
- });
47
- `,
48
- },
49
- {
50
- code: `
51
- import { styled } from '@mui/system';
52
- import Box from '@mui/material/Box';
53
-
54
- const foo = styled(Box, {})({
55
- color: 'red',
56
- });
57
- `,
58
- errors: [
59
- {
60
- messageId: 'noBox',
61
- },
62
- ],
63
- output: `
64
- import { styled } from '@mui/system';
65
- import Box from '@mui/material/Box';
66
-
67
- const foo = styled('div', {})({
68
- color: 'red',
69
- });
70
- `,
71
- },
72
- ],
73
- });
@@ -1,265 +0,0 @@
1
- import eslint from 'eslint';
2
- import parser from '@typescript-eslint/parser';
3
- import rule from './require-dev-wrapper.mjs';
4
-
5
- const ruleTester = new eslint.RuleTester({
6
- languageOptions: {
7
- parser,
8
- },
9
- });
10
-
11
- ruleTester.run('require-dev-wrapper', rule, {
12
- valid: [
13
- // Should pass: Function wrapped with !== production check
14
- {
15
- code: `
16
- if (process.env.NODE_ENV !== 'production') {
17
- checkSlot(key, overrides[k]);
18
- }
19
- `,
20
- },
21
- // Should pass: Function wrapped with === 'development' check (tree-shakes in production)
22
- {
23
- code: `
24
- if (process.env.NODE_ENV === 'development') {
25
- checkSlot(key, overrides[k]);
26
- }
27
- `,
28
- },
29
- // Should pass: Function wrapped in a for loop inside production check
30
- {
31
- code: `
32
- if (process.env.NODE_ENV !== 'production') {
33
- for (key in slots) {
34
- checkSlot(key, overrides[k]);
35
- }
36
- }
37
- `,
38
- },
39
- // Should pass: Other functions not in the list
40
- {
41
- code: `
42
- otherFunction('hello');
43
- `,
44
- },
45
- // Should pass: warnOnce wrapped correctly
46
- {
47
- code: `
48
- if (process.env.NODE_ENV !== 'production') {
49
- warnOnce('Some warning message');
50
- }
51
- `,
52
- },
53
- // Should pass: Multiple statements in production check
54
- {
55
- code: `
56
- if (process.env.NODE_ENV !== 'production') {
57
- const message = 'Warning';
58
- warn(message);
59
- checkSlot(key, value);
60
- }
61
- `,
62
- },
63
- // Should pass: Nested blocks
64
- {
65
- code: `
66
- if (process.env.NODE_ENV !== 'production') {
67
- if (someCondition) {
68
- warnOnce('nested warning');
69
- }
70
- }
71
- `,
72
- },
73
- // Should pass: Reversed comparison (literal on left)
74
- {
75
- code: `
76
- if ('production' !== process.env.NODE_ENV) {
77
- checkSlot(key, value);
78
- }
79
- `,
80
- },
81
- // Should pass: Function in else block when if checks for production
82
- {
83
- code: `
84
- if (process.env.NODE_ENV === 'production') {
85
- // production code
86
- } else {
87
- checkSlot(key, value);
88
- }
89
- `,
90
- },
91
- // Should pass: Nested if statement in else block
92
- {
93
- code: `
94
- if (process.env.NODE_ENV === 'production') {
95
- // production code
96
- } else {
97
- if (someCondition) {
98
- warnOnce('nested warning in else');
99
- }
100
- }
101
- `,
102
- },
103
- // Should pass: else-if chain where inner if is a valid dev guard
104
- {
105
- code: `
106
- if (a) {
107
- } else if (process.env.NODE_ENV !== 'production') {
108
- warn('dev only');
109
- }
110
- `,
111
- },
112
- // Should pass: else-if after production check (call is in the non-production branch)
113
- {
114
- code: `
115
- if (process.env.NODE_ENV === 'production') {
116
- } else if (someCondition) {
117
- warn('not production');
118
- }
119
- `,
120
- },
121
- ],
122
- invalid: [
123
- // Should fail: checkSlot without production check
124
- {
125
- code: `
126
- checkSlot(key, overrides[k]);
127
- `,
128
- errors: [
129
- {
130
- messageId: 'missingDevWrapper',
131
- data: { functionName: 'checkSlot' },
132
- },
133
- ],
134
- },
135
- // Should fail: warnOnce without production check
136
- {
137
- code: `
138
- warnOnce('Some warning');
139
- `,
140
- errors: [
141
- {
142
- messageId: 'missingDevWrapper',
143
- data: { functionName: 'warnOnce' },
144
- },
145
- ],
146
- },
147
- // Should fail: warn without production check
148
- {
149
- code: `
150
- warn('Some warning');
151
- `,
152
- errors: [
153
- {
154
- messageId: 'missingDevWrapper',
155
- data: { functionName: 'warn' },
156
- },
157
- ],
158
- },
159
- // Should fail: Multiple unwrapped calls
160
- {
161
- code: `
162
- checkSlot(key, value);
163
- warn('Warning message');
164
- `,
165
- errors: [
166
- {
167
- messageId: 'missingDevWrapper',
168
- data: { functionName: 'checkSlot' },
169
- },
170
- {
171
- messageId: 'missingDevWrapper',
172
- data: { functionName: 'warn' },
173
- },
174
- ],
175
- },
176
- // Should fail: Inside wrong conditional (no process.env.NODE_ENV)
177
- {
178
- code: `
179
- if (someOtherCondition) {
180
- checkSlot(key, value);
181
- }
182
- `,
183
- errors: [
184
- {
185
- messageId: 'missingDevWrapper',
186
- data: { functionName: 'checkSlot' },
187
- },
188
- ],
189
- },
190
- // Should fail: Inside else block of production check (!== 'production')
191
- {
192
- code: `
193
- if (process.env.NODE_ENV !== 'production') {
194
- // ok
195
- } else {
196
- checkSlot(key, value);
197
- }
198
- `,
199
- errors: [
200
- {
201
- messageId: 'missingDevWrapper',
202
- data: { functionName: 'checkSlot' },
203
- },
204
- ],
205
- },
206
- // Should fail: In then block of === 'production' (would run in production!)
207
- {
208
- code: `
209
- if (process.env.NODE_ENV === 'production') {
210
- checkSlot(key, value);
211
- }
212
- `,
213
- errors: [
214
- {
215
- messageId: 'missingDevWrapper',
216
- data: { functionName: 'checkSlot' },
217
- },
218
- ],
219
- },
220
- // Should fail: !== 'test' doesn't reliably tree-shake
221
- {
222
- code: `
223
- if (process.env.NODE_ENV !== 'test') {
224
- checkSlot(key, value);
225
- }
226
- `,
227
- errors: [
228
- {
229
- messageId: 'missingDevWrapper',
230
- data: { functionName: 'checkSlot' },
231
- },
232
- ],
233
- },
234
- // Should fail: Non-static check doesn't tree-shake
235
- {
236
- code: `
237
- const env = 'production';
238
- if (process.env.NODE_ENV !== env) {
239
- checkSlot(key, value);
240
- }
241
- `,
242
- errors: [
243
- {
244
- messageId: 'missingDevWrapper',
245
- data: { functionName: 'checkSlot' },
246
- },
247
- ],
248
- },
249
- // Should fail: else-if after !== 'production' means call runs IN production
250
- {
251
- code: `
252
- if (process.env.NODE_ENV !== 'production') {
253
- } else if (someCondition) {
254
- warn('this runs in production');
255
- }
256
- `,
257
- errors: [
258
- {
259
- messageId: 'missingDevWrapper',
260
- data: { functionName: 'warn' },
261
- },
262
- ],
263
- },
264
- ],
265
- });