@mui/internal-code-infra 0.0.4-canary.8 → 0.0.4-canary.81
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.
- package/LICENSE +1 -1
- package/README.md +19 -8
- package/build/babel-config.d.mts +5 -1
- package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
- package/build/brokenLinksChecker/index.d.mts +45 -2
- package/build/changelog/types.d.ts +1 -1
- package/build/cli/cmdArgosPush.d.mts +2 -2
- package/build/cli/cmdBuild.d.mts +3 -2
- package/build/cli/cmdCopyFiles.d.mts +2 -2
- package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
- package/build/cli/cmdGenerateChangelog.d.mts +2 -2
- package/build/cli/cmdGithubAuth.d.mts +2 -2
- package/build/cli/cmdListWorkspaces.d.mts +6 -4
- package/build/cli/cmdNetlifyIgnore.d.mts +3 -2
- package/build/cli/cmdPublish.d.mts +4 -2
- package/build/cli/cmdPublishCanary.d.mts +3 -3
- package/build/cli/cmdPublishNewPackage.d.mts +4 -2
- package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
- package/build/cli/cmdVale.d.mts +46 -0
- package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
- package/build/eslint/baseConfig.d.mts +3 -1
- package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
- package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
- package/build/eslint/mui/rules/no-floating-cleanup.d.mts +5 -0
- package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
- package/build/eslint/mui/rules/no-presentation-role.d.mts +5 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
- package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
- package/build/remark/config.d.mts +43 -0
- package/build/remark/createLintTester.d.mts +10 -0
- package/build/remark/firstBlockHeading.d.mts +4 -0
- package/build/remark/gitDiff.d.mts +2 -0
- package/build/remark/noSpaceInLinks.d.mts +2 -0
- package/build/remark/straightQuotes.d.mts +2 -0
- package/build/remark/tableAlignment.d.mts +2 -0
- package/build/remark/terminalLanguage.d.mts +2 -0
- package/build/utils/babel.d.mts +1 -1
- package/build/utils/build.d.mts +56 -37
- package/build/utils/git.d.mts +7 -0
- package/build/utils/github.d.mts +1 -1
- package/build/utils/pnpm.d.mts +81 -2
- package/build/utils/testUtils.d.mts +7 -0
- package/build/utils/typescript.d.mts +6 -16
- package/package.json +66 -42
- package/src/babel-config.mjs +3 -1
- package/src/brokenLinksChecker/crawlWorker.mjs +240 -0
- package/src/brokenLinksChecker/index.mjs +263 -188
- package/src/changelog/fetchChangelogs.mjs +6 -2
- package/src/changelog/renderChangelog.mjs +1 -1
- package/src/changelog/types.ts +1 -1
- package/src/cli/cmdBuild.mjs +51 -85
- package/src/cli/cmdListWorkspaces.mjs +12 -27
- package/src/cli/cmdNetlifyIgnore.mjs +34 -93
- package/src/cli/cmdPublish.mjs +95 -20
- package/src/cli/cmdPublishCanary.mjs +128 -132
- package/src/cli/cmdPublishNewPackage.mjs +27 -6
- package/src/cli/cmdSetVersionOverrides.mjs +8 -9
- package/src/cli/cmdVale.mjs +513 -0
- package/src/cli/index.mjs +2 -0
- package/src/cli/packageJson.d.ts +1 -1
- package/src/eslint/baseConfig.mjs +51 -19
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/eslint/mui/config.mjs +24 -4
- package/src/eslint/mui/index.mjs +6 -0
- package/src/eslint/mui/rules/no-floating-cleanup.mjs +187 -0
- package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
- package/src/eslint/mui/rules/no-presentation-role.mjs +60 -0
- package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
- package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
- package/src/estree-typescript.d.ts +1 -1
- package/src/remark/config.mjs +157 -0
- package/src/remark/createLintTester.mjs +19 -0
- package/src/remark/firstBlockHeading.mjs +87 -0
- package/src/remark/gitDiff.mjs +43 -0
- package/src/remark/noSpaceInLinks.mjs +42 -0
- package/src/remark/straightQuotes.mjs +31 -0
- package/src/remark/tableAlignment.mjs +23 -0
- package/src/remark/terminalLanguage.mjs +19 -0
- package/src/untyped-plugins.d.ts +11 -11
- package/src/utils/build.mjs +604 -270
- package/src/utils/git.mjs +27 -7
- package/src/utils/pnpm.mjs +277 -10
- package/src/utils/testUtils.mjs +18 -0
- package/src/utils/typescript.mjs +23 -42
- package/vale/.vale.ini +1 -0
- package/vale/styles/MUI/CorrectReferenceAllCases.yml +42 -0
- package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
- package/vale/styles/MUI/GoogleLatin.yml +11 -0
- package/vale/styles/MUI/MuiBrandName.yml +22 -0
- package/vale/styles/MUI/NoBritish.yml +112 -0
- package/vale/styles/MUI/NoCompanyName.yml +17 -0
- package/build/markdownlint/duplicate-h1.d.mts +0 -56
- package/build/markdownlint/git-diff.d.mts +0 -11
- package/build/markdownlint/index.d.mts +0 -52
- package/build/markdownlint/straight-quotes.d.mts +0 -11
- package/build/markdownlint/table-alignment.d.mts +0 -11
- package/build/markdownlint/terminal-language.d.mts +0 -11
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
- package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
- package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -28
- package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
- package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
- package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
- package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
- package/src/brokenLinksChecker/index.test.ts +0 -261
- package/src/changelog/categorizeCommits.test.ts +0 -319
- package/src/changelog/filterCommits.test.ts +0 -363
- package/src/changelog/parseCommitLabels.test.ts +0 -509
- package/src/changelog/renderChangelog.test.ts +0 -378
- package/src/changelog/sortSections.test.ts +0 -199
- package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
- package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
- package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
- package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
- package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
- package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
- package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
- package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
- package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
- package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
- package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
- package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
- package/src/markdownlint/duplicate-h1.mjs +0 -69
- package/src/markdownlint/git-diff.mjs +0 -31
- package/src/markdownlint/index.mjs +0 -62
- package/src/markdownlint/straight-quotes.mjs +0 -26
- package/src/markdownlint/table-alignment.mjs +0 -42
- package/src/markdownlint/terminal-language.mjs +0 -19
- package/src/utils/build.test.mjs +0 -705
- package/src/utils/template.test.mjs +0 -133
- package/src/utils/typescript.test.mjs +0 -380
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
2
|
-
import TSESlintParser from '@typescript-eslint/parser';
|
|
3
|
-
import rule from './add-undef-to-optional.mjs';
|
|
4
|
-
|
|
5
|
-
const ruleTester = new RuleTester({
|
|
6
|
-
languageOptions: {
|
|
7
|
-
parser: TSESlintParser,
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
ruleTester.run('add-undef-to-optional', rule, {
|
|
12
|
-
valid: [
|
|
13
|
-
{
|
|
14
|
-
name: 'optional property with undefined',
|
|
15
|
-
code: `
|
|
16
|
-
export type Hello = {
|
|
17
|
-
name?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'optional property with undefined in union',
|
|
23
|
-
code: `
|
|
24
|
-
export type Hello = {
|
|
25
|
-
name?: (string | number) | undefined;
|
|
26
|
-
};
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'optional property with undefined and type reference',
|
|
31
|
-
code: `
|
|
32
|
-
type NameArg = string | number;
|
|
33
|
-
export type Hello = {
|
|
34
|
-
name?: NameArg | undefined;
|
|
35
|
-
};
|
|
36
|
-
`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'optional property with type reference including undefined',
|
|
40
|
-
code: `
|
|
41
|
-
type NameArg = string | number | undefined;
|
|
42
|
-
export type Hello = {
|
|
43
|
-
name?: NameArg;
|
|
44
|
-
};
|
|
45
|
-
`,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'optional property with built-in type reference and explicit undefined',
|
|
49
|
-
code: `
|
|
50
|
-
export type Hello = {
|
|
51
|
-
data?: Record<string, string> | undefined;
|
|
52
|
-
};
|
|
53
|
-
`,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'optional property with generic type reference and explicit undefined',
|
|
57
|
-
code: `
|
|
58
|
-
export type Hello<T> = {
|
|
59
|
-
value?: T | undefined;
|
|
60
|
-
};
|
|
61
|
-
`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'required property without undefined',
|
|
65
|
-
code: `
|
|
66
|
-
export type Hello = {
|
|
67
|
-
name: string | number;
|
|
68
|
-
};
|
|
69
|
-
`,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'optional property with null and undefined',
|
|
73
|
-
code: `
|
|
74
|
-
export type Hello = {
|
|
75
|
-
name?: string | null | undefined;
|
|
76
|
-
};
|
|
77
|
-
`,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'optional property with complex union including undefined',
|
|
81
|
-
code: `
|
|
82
|
-
export type Hello = {
|
|
83
|
-
name?: (string | number | boolean) | undefined;
|
|
84
|
-
};
|
|
85
|
-
`,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'optional property with nested type reference including undefined',
|
|
89
|
-
code: `
|
|
90
|
-
type Inner = string | undefined;
|
|
91
|
-
type Outer = Inner | number;
|
|
92
|
-
export type Hello = {
|
|
93
|
-
name?: Outer;
|
|
94
|
-
};
|
|
95
|
-
`,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'optional property with type reference in interface',
|
|
99
|
-
code: `
|
|
100
|
-
type NameArg = string | undefined;
|
|
101
|
-
export interface Hello {
|
|
102
|
-
name?: NameArg;
|
|
103
|
-
}
|
|
104
|
-
`,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: 'multiple optional properties with mixed scenarios',
|
|
108
|
-
code: `
|
|
109
|
-
type WithUndef = string | undefined;
|
|
110
|
-
type WithoutUndef = string | number;
|
|
111
|
-
export type Hello = {
|
|
112
|
-
a?: WithUndef;
|
|
113
|
-
b?: WithoutUndef | undefined;
|
|
114
|
-
c?: string | undefined;
|
|
115
|
-
};
|
|
116
|
-
`,
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'optional property with any type',
|
|
120
|
-
code: `
|
|
121
|
-
export type Hello = {
|
|
122
|
-
value?: any;
|
|
123
|
-
};
|
|
124
|
-
`,
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: 'optional property with unknown type',
|
|
128
|
-
code: `
|
|
129
|
-
export type Hello = {
|
|
130
|
-
value?: unknown;
|
|
131
|
-
};
|
|
132
|
-
`,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: 'optional property with any in union',
|
|
136
|
-
code: `
|
|
137
|
-
export type Hello = {
|
|
138
|
-
value?: string | any;
|
|
139
|
-
};
|
|
140
|
-
`,
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'optional property with unknown in union',
|
|
144
|
-
code: `
|
|
145
|
-
export type Hello = {
|
|
146
|
-
value?: string | unknown;
|
|
147
|
-
};
|
|
148
|
-
`,
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'optional property with type reference to any',
|
|
152
|
-
code: `
|
|
153
|
-
type AnyType = any;
|
|
154
|
-
export type Hello = {
|
|
155
|
-
value?: AnyType;
|
|
156
|
-
};
|
|
157
|
-
`,
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
name: 'optional property with type reference to unknown',
|
|
161
|
-
code: `
|
|
162
|
-
type UnknownType = unknown;
|
|
163
|
-
export type Hello = {
|
|
164
|
-
value?: UnknownType;
|
|
165
|
-
};
|
|
166
|
-
`,
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: 'optional property with ReactNode',
|
|
170
|
-
code: `
|
|
171
|
-
import { ReactNode } from 'react';
|
|
172
|
-
export type Hello = {
|
|
173
|
-
children?: ReactNode;
|
|
174
|
-
};
|
|
175
|
-
`,
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: 'optional property with React.ReactNode',
|
|
179
|
-
code: `
|
|
180
|
-
import React from 'react';
|
|
181
|
-
export type Hello = {
|
|
182
|
-
children?: React.ReactNode;
|
|
183
|
-
};
|
|
184
|
-
`,
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
name: 'optional property with ReactNode without import',
|
|
188
|
-
code: `
|
|
189
|
-
export type Hello = {
|
|
190
|
-
content?: ReactNode;
|
|
191
|
-
};
|
|
192
|
-
`,
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: 'optional property with React.ReactNode in union',
|
|
196
|
-
code: `
|
|
197
|
-
import React from 'react';
|
|
198
|
-
export type Hello = {
|
|
199
|
-
value?: string | React.ReactNode;
|
|
200
|
-
};
|
|
201
|
-
`,
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
invalid: [
|
|
205
|
-
{
|
|
206
|
-
name: 'optional property without undefined',
|
|
207
|
-
code: `export type Hello = {
|
|
208
|
-
name?: string | number;
|
|
209
|
-
};
|
|
210
|
-
`,
|
|
211
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
212
|
-
output: `export type Hello = {
|
|
213
|
-
name?: (string | number) | undefined;
|
|
214
|
-
};
|
|
215
|
-
`,
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: 'optional property with simple type',
|
|
219
|
-
code: `export type Hello = {
|
|
220
|
-
name?: string;
|
|
221
|
-
};
|
|
222
|
-
`,
|
|
223
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
224
|
-
output: `export type Hello = {
|
|
225
|
-
name?: (string) | undefined;
|
|
226
|
-
};
|
|
227
|
-
`,
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: 'optional property with local type reference without undefined',
|
|
231
|
-
code: `type NameArg = string | number;
|
|
232
|
-
export type Hello = {
|
|
233
|
-
name?: NameArg;
|
|
234
|
-
};
|
|
235
|
-
`,
|
|
236
|
-
errors: [{ messageId: 'addUndefined', line: 3, column: 3 }],
|
|
237
|
-
output: `type NameArg = string | number;
|
|
238
|
-
export type Hello = {
|
|
239
|
-
name?: (NameArg) | undefined;
|
|
240
|
-
};
|
|
241
|
-
`,
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
name: 'optional property in interface without undefined',
|
|
245
|
-
code: `export interface Hello {
|
|
246
|
-
name?: string;
|
|
247
|
-
}
|
|
248
|
-
`,
|
|
249
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
250
|
-
output: `export interface Hello {
|
|
251
|
-
name?: (string) | undefined;
|
|
252
|
-
}
|
|
253
|
-
`,
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
name: 'multiple optional properties missing undefined',
|
|
257
|
-
code: `export type Hello = {
|
|
258
|
-
name?: string;
|
|
259
|
-
age?: number;
|
|
260
|
-
};
|
|
261
|
-
`,
|
|
262
|
-
errors: [
|
|
263
|
-
{ messageId: 'addUndefined', line: 2, column: 3 },
|
|
264
|
-
{ messageId: 'addUndefined', line: 3, column: 3 },
|
|
265
|
-
],
|
|
266
|
-
output: `export type Hello = {
|
|
267
|
-
name?: (string) | undefined;
|
|
268
|
-
age?: (number) | undefined;
|
|
269
|
-
};
|
|
270
|
-
`,
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
name: 'optional property with union but no undefined',
|
|
274
|
-
code: `export type Hello = {
|
|
275
|
-
value?: string | number | boolean;
|
|
276
|
-
};
|
|
277
|
-
`,
|
|
278
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
279
|
-
output: `export type Hello = {
|
|
280
|
-
value?: (string | number | boolean) | undefined;
|
|
281
|
-
};
|
|
282
|
-
`,
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
name: 'optional property with nested type reference without undefined',
|
|
286
|
-
code: `type Inner = string | number;
|
|
287
|
-
type Outer = Inner | boolean;
|
|
288
|
-
export type Hello = {
|
|
289
|
-
value?: Outer;
|
|
290
|
-
};
|
|
291
|
-
`,
|
|
292
|
-
errors: [{ messageId: 'addUndefined', line: 4, column: 3 }],
|
|
293
|
-
output: `type Inner = string | number;
|
|
294
|
-
type Outer = Inner | boolean;
|
|
295
|
-
export type Hello = {
|
|
296
|
-
value?: (Outer) | undefined;
|
|
297
|
-
};
|
|
298
|
-
`,
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
name: 'optional property with null but no undefined',
|
|
302
|
-
code: `export type Hello = {
|
|
303
|
-
value?: string | null;
|
|
304
|
-
};
|
|
305
|
-
`,
|
|
306
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
307
|
-
output: `export type Hello = {
|
|
308
|
-
value?: (string | null) | undefined;
|
|
309
|
-
};
|
|
310
|
-
`,
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
name: 'optional property with imported type reference',
|
|
314
|
-
code: `import { SomeType } from './other';
|
|
315
|
-
export type Hello = {
|
|
316
|
-
name?: SomeType;
|
|
317
|
-
};
|
|
318
|
-
`,
|
|
319
|
-
errors: [{ messageId: 'addUndefined', line: 3, column: 3 }],
|
|
320
|
-
output: `import { SomeType } from './other';
|
|
321
|
-
export type Hello = {
|
|
322
|
-
name?: (SomeType) | undefined;
|
|
323
|
-
};
|
|
324
|
-
`,
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
name: 'optional property with built-in type reference',
|
|
328
|
-
code: `export type Hello = {
|
|
329
|
-
data?: Record<string, string>;
|
|
330
|
-
};
|
|
331
|
-
`,
|
|
332
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
333
|
-
output: `export type Hello = {
|
|
334
|
-
data?: (Record<string, string>) | undefined;
|
|
335
|
-
};
|
|
336
|
-
`,
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
name: 'optional property with generic type parameter',
|
|
340
|
-
code: `export type Hello<T> = {
|
|
341
|
-
value?: T;
|
|
342
|
-
};
|
|
343
|
-
`,
|
|
344
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
345
|
-
output: `export type Hello<T> = {
|
|
346
|
-
value?: (T) | undefined;
|
|
347
|
-
};
|
|
348
|
-
`,
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
name: 'optional property with function type without undefined',
|
|
352
|
-
code: `export type Hello = {
|
|
353
|
-
onPressedChange?: (pressed: boolean, eventDetails: Toggle.ChangeEventDetails) => void;
|
|
354
|
-
}`,
|
|
355
|
-
errors: [{ messageId: 'addUndefined', line: 2, column: 3 }],
|
|
356
|
-
output: `export type Hello = {
|
|
357
|
-
onPressedChange?: ((pressed: boolean, eventDetails: Toggle.ChangeEventDetails) => void) | undefined;
|
|
358
|
-
}`,
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import eslint from 'eslint';
|
|
2
|
-
import parser from '@typescript-eslint/parser';
|
|
3
|
-
import rule from './consistent-production-guard.mjs';
|
|
4
|
-
|
|
5
|
-
const ruleTester = new eslint.RuleTester({
|
|
6
|
-
languageOptions: {
|
|
7
|
-
parser,
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
ruleTester.run('consistent-production-guard', rule, {
|
|
12
|
-
valid: [
|
|
13
|
-
// Should pass: Valid !== comparison with 'production'
|
|
14
|
-
{
|
|
15
|
-
code: `
|
|
16
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
-
console.log('dev');
|
|
18
|
-
}
|
|
19
|
-
`,
|
|
20
|
-
},
|
|
21
|
-
// Should pass: Valid === comparison with 'production'
|
|
22
|
-
{
|
|
23
|
-
code: `
|
|
24
|
-
if (process.env.NODE_ENV === 'production') {
|
|
25
|
-
console.log('prod');
|
|
26
|
-
}
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
// Should pass: Reversed comparison (literal on left)
|
|
30
|
-
{
|
|
31
|
-
code: `
|
|
32
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
33
|
-
console.log('dev');
|
|
34
|
-
}
|
|
35
|
-
`,
|
|
36
|
-
},
|
|
37
|
-
// Should pass: Reversed comparison with ===
|
|
38
|
-
{
|
|
39
|
-
code: `
|
|
40
|
-
if ('production' === process.env.NODE_ENV) {
|
|
41
|
-
console.log('prod');
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
},
|
|
45
|
-
// Should pass: Code without process.env.NODE_ENV
|
|
46
|
-
{
|
|
47
|
-
code: `
|
|
48
|
-
const foo = 'bar';
|
|
49
|
-
if (foo === 'baz') {
|
|
50
|
-
console.log('test');
|
|
51
|
-
}
|
|
52
|
-
`,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
invalid: [
|
|
56
|
-
// Should fail: Comparing with 'development'
|
|
57
|
-
{
|
|
58
|
-
code: `
|
|
59
|
-
if (process.env.NODE_ENV === 'development') {
|
|
60
|
-
console.log('dev');
|
|
61
|
-
}
|
|
62
|
-
`,
|
|
63
|
-
errors: [
|
|
64
|
-
{
|
|
65
|
-
messageId: 'invalidComparison',
|
|
66
|
-
data: { comparedValue: 'development' },
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
// Should fail: Comparing with 'test'
|
|
71
|
-
{
|
|
72
|
-
code: `
|
|
73
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
74
|
-
console.log('not test');
|
|
75
|
-
}
|
|
76
|
-
`,
|
|
77
|
-
errors: [
|
|
78
|
-
{
|
|
79
|
-
messageId: 'invalidComparison',
|
|
80
|
-
data: { comparedValue: 'test' },
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
// Should fail: Reversed comparison with 'development'
|
|
85
|
-
{
|
|
86
|
-
code: `
|
|
87
|
-
if ('development' === process.env.NODE_ENV) {
|
|
88
|
-
console.log('dev');
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
errors: [
|
|
92
|
-
{
|
|
93
|
-
messageId: 'invalidComparison',
|
|
94
|
-
data: { comparedValue: 'development' },
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
// Should fail: Non-static comparison (variable)
|
|
99
|
-
{
|
|
100
|
-
code: `
|
|
101
|
-
const env = 'production';
|
|
102
|
-
if (process.env.NODE_ENV !== env) {
|
|
103
|
-
console.log('check');
|
|
104
|
-
}
|
|
105
|
-
`,
|
|
106
|
-
errors: [
|
|
107
|
-
{
|
|
108
|
-
messageId: 'invalidComparison',
|
|
109
|
-
data: { comparedValue: 'non-literal' },
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
// Should fail: Non-static comparison (reversed)
|
|
114
|
-
{
|
|
115
|
-
code: `
|
|
116
|
-
const env = 'production';
|
|
117
|
-
if (env === process.env.NODE_ENV) {
|
|
118
|
-
console.log('check');
|
|
119
|
-
}
|
|
120
|
-
`,
|
|
121
|
-
errors: [
|
|
122
|
-
{
|
|
123
|
-
messageId: 'invalidComparison',
|
|
124
|
-
data: { comparedValue: 'non-literal' },
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
// Should fail: Invalid usage (function call)
|
|
129
|
-
{
|
|
130
|
-
code: `
|
|
131
|
-
foo(process.env.NODE_ENV);
|
|
132
|
-
`,
|
|
133
|
-
errors: [
|
|
134
|
-
{
|
|
135
|
-
messageId: 'invalidUsage',
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
// Should fail: Invalid usage (assignment)
|
|
140
|
-
{
|
|
141
|
-
code: `
|
|
142
|
-
const env = process.env.NODE_ENV;
|
|
143
|
-
`,
|
|
144
|
-
errors: [
|
|
145
|
-
{
|
|
146
|
-
messageId: 'invalidUsage',
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
// Should fail: Invalid usage (template literal)
|
|
151
|
-
{
|
|
152
|
-
code: `
|
|
153
|
-
const message = \`Environment: \${process.env.NODE_ENV}\`;
|
|
154
|
-
`,
|
|
155
|
-
errors: [
|
|
156
|
-
{
|
|
157
|
-
messageId: 'invalidUsage',
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import eslint from 'eslint';
|
|
2
|
-
import parser from '@typescript-eslint/parser';
|
|
3
|
-
import rule from './disallow-active-element-as-key-event-target.mjs';
|
|
4
|
-
|
|
5
|
-
const ruleTester = new eslint.RuleTester({
|
|
6
|
-
languageOptions: {
|
|
7
|
-
parser,
|
|
8
|
-
parserOptions: { sourceType: 'module' },
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
ruleTester.run('disallow-active-element-as-key-event-target', rule, {
|
|
13
|
-
valid: [
|
|
14
|
-
"import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyDown(getByRole('button'), { key: ' ' })",
|
|
15
|
-
"import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyDown(document.body, { key: 'Escape' })",
|
|
16
|
-
"import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyUp(document.body, { key: 'Tab' })",
|
|
17
|
-
],
|
|
18
|
-
invalid: [
|
|
19
|
-
{
|
|
20
|
-
code: "import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyUp(document.activeElement, { key: 'LeftArrow' })",
|
|
21
|
-
errors: [
|
|
22
|
-
{
|
|
23
|
-
message:
|
|
24
|
-
"Don't use document.activeElement as a target for keyboard events. Prefer the actual element.",
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
code: "import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyDown(document.activeElement, { key: 'DownArrow' })",
|
|
30
|
-
errors: [
|
|
31
|
-
{
|
|
32
|
-
message:
|
|
33
|
-
"Don't use document.activeElement as a target for keyboard events. Prefer the actual element.",
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
code: "import { fireEvent } from 'any-path';\nfireEvent.keyDown(document.activeElement, { key: 'DownArrow' })",
|
|
39
|
-
errors: [
|
|
40
|
-
{
|
|
41
|
-
message:
|
|
42
|
-
"Don't use document.activeElement as a target for keyboard events. Prefer the actual element.",
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: "fireEvent.keyDown(document.activeElement, { key: 'DownArrow' })",
|
|
48
|
-
errors: [
|
|
49
|
-
{
|
|
50
|
-
message:
|
|
51
|
-
"Don't use document.activeElement as a target for keyboard events. Prefer the actual element.",
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
// test non-null assertion operator
|
|
57
|
-
code: "import { fireEvent } from '@mui/internal-test-utils';\nfireEvent.keyUp(document.activeElement!, { key: 'LeftArrow' })",
|
|
58
|
-
errors: [
|
|
59
|
-
{
|
|
60
|
-
message:
|
|
61
|
-
"Don't use document.activeElement as a target for keyboard events. Prefer the actual element.",
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
});
|