@mui/internal-code-infra 0.0.4-canary.72 → 0.0.4-canary.74
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/build/utils/git.d.mts +7 -0
- package/package.json +5 -3
- package/src/cli/cmdPublish.mjs +40 -5
- package/src/utils/git.mjs +11 -0
- 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 -29
- package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +0 -15
- 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 -301
- 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/cli/cmdVale.test.mjs +0 -644
- 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-floating-cleanup.test.mjs +0 -141
- package/src/eslint/mui/rules/no-guarded-throw.test.mjs +0 -206
- package/src/eslint/mui/rules/no-presentation-role.test.mjs +0 -33
- 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/remark/firstBlockHeading.test.mjs +0 -107
- package/src/remark/gitDiff.test.mjs +0 -45
- package/src/remark/noSpaceInLinks.test.mjs +0 -22
- package/src/remark/straightQuotes.test.mjs +0 -25
- package/src/remark/tableAlignment.test.mjs +0 -28
- package/src/remark/terminalLanguage.test.mjs +0 -17
- package/src/utils/build.test.mjs +0 -1263
- package/src/utils/pnpm.test.mjs +0 -731
- package/src/utils/template.test.mjs +0 -133
- package/src/utils/typescript.test.mjs +0 -341
|
@@ -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
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import eslint from 'eslint';
|
|
2
|
-
import parser from '@typescript-eslint/parser';
|
|
3
|
-
import rule from './rules-of-use-theme-variants.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('rules-of-use-theme-variants', rule, {
|
|
15
|
-
valid: [
|
|
16
|
-
// allowed but dangerous
|
|
17
|
-
{
|
|
18
|
-
name: 'custom useThemeVariants hook',
|
|
19
|
-
code: `
|
|
20
|
-
{
|
|
21
|
-
const useCustomThemeVariants = props => useThemeVariants(props);
|
|
22
|
-
}`,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'basic useThemeVariants call',
|
|
26
|
-
code: `
|
|
27
|
-
{
|
|
28
|
-
useThemeVariants(props);
|
|
29
|
-
}
|
|
30
|
-
`,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'useThemeVariants with destructured props',
|
|
34
|
-
code: `
|
|
35
|
-
{
|
|
36
|
-
const { className, value: valueProp, ...other } = props;
|
|
37
|
-
useThemeVariants(props);
|
|
38
|
-
}
|
|
39
|
-
`,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'useThemeVariants with disabled prop override',
|
|
43
|
-
code: `
|
|
44
|
-
{
|
|
45
|
-
const { className, disabled = false, value: valueProp, ...other } = props;
|
|
46
|
-
useThemeVariants({ ...props, disabled });
|
|
47
|
-
}
|
|
48
|
-
`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'useThemeVariants with state variables',
|
|
52
|
-
code: `
|
|
53
|
-
{
|
|
54
|
-
const { className, value: valueProp, ...other } = props;
|
|
55
|
-
const [stateA, setStateA] = React.useState(0);
|
|
56
|
-
const [stateB, setStateB] = React.useState(0);
|
|
57
|
-
useThemeVariants({ stateA, ...props, stateB });
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
},
|
|
61
|
-
// unnecessary spread but it's not the responsibility of this rule to catch "unnecessary" spread
|
|
62
|
-
{
|
|
63
|
-
name: 'useThemeVariants with unnecessary spread',
|
|
64
|
-
code: `
|
|
65
|
-
{
|
|
66
|
-
const { className, value: valueProp, ...other } = props;
|
|
67
|
-
useThemeVariants({ ...props});
|
|
68
|
-
}
|
|
69
|
-
`,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
invalid: [
|
|
73
|
-
{
|
|
74
|
-
name: 'disabled prop not passed to useThemeVariants',
|
|
75
|
-
code: `
|
|
76
|
-
{
|
|
77
|
-
const { disabled = false, ...other } = props;
|
|
78
|
-
useThemeVariants({ ...props});
|
|
79
|
-
}
|
|
80
|
-
`,
|
|
81
|
-
errors: [
|
|
82
|
-
{
|
|
83
|
-
message: 'Prop `disabled` is not passed to `useThemeVariants` props.',
|
|
84
|
-
line: 4,
|
|
85
|
-
column: 20,
|
|
86
|
-
endLine: 4,
|
|
87
|
-
endColumn: 31,
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: 'variant prop not passed to useThemeVariants',
|
|
93
|
-
code: `
|
|
94
|
-
{
|
|
95
|
-
const { disabled = false, variant = 'text', ...other } = props;
|
|
96
|
-
useThemeVariants({ ...props, disabled });
|
|
97
|
-
}
|
|
98
|
-
`,
|
|
99
|
-
errors: [
|
|
100
|
-
{
|
|
101
|
-
message: 'Prop `variant` is not passed to `useThemeVariants` props.',
|
|
102
|
-
line: 4,
|
|
103
|
-
column: 20,
|
|
104
|
-
endLine: 4,
|
|
105
|
-
endColumn: 42,
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'props spread must come first',
|
|
111
|
-
code: `
|
|
112
|
-
{
|
|
113
|
-
const { disabled = false, ...other } = props;
|
|
114
|
-
useThemeVariants({ disabled, ...props });
|
|
115
|
-
}
|
|
116
|
-
`,
|
|
117
|
-
errors: [
|
|
118
|
-
{
|
|
119
|
-
message:
|
|
120
|
-
'The props spread must come first in the `useThemeVariants` props. Otherwise destructured props with default values could be overridden.',
|
|
121
|
-
line: 4,
|
|
122
|
-
column: 32,
|
|
123
|
-
endLine: 4,
|
|
124
|
-
endColumn: 40,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
// this is valid code but not analyzable by this rule
|
|
129
|
-
{
|
|
130
|
-
name: 'cannot analyze identifier pattern',
|
|
131
|
-
code: `
|
|
132
|
-
{
|
|
133
|
-
const { disabled = false, ...other } = props;
|
|
134
|
-
const themeVariantProps = { ...props, disabled };
|
|
135
|
-
useThemeVariants(themeVariantProps);
|
|
136
|
-
}
|
|
137
|
-
`,
|
|
138
|
-
errors: [
|
|
139
|
-
{
|
|
140
|
-
message: "Can only analyze object patterns but found 'Identifier'. Prefer `{...props}`.",
|
|
141
|
-
line: 5,
|
|
142
|
-
column: 20,
|
|
143
|
-
endLine: 5,
|
|
144
|
-
endColumn: 37,
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import eslint from 'eslint';
|
|
2
|
-
import parser from '@typescript-eslint/parser';
|
|
3
|
-
import rule from './straight-quotes.mjs';
|
|
4
|
-
|
|
5
|
-
const ruleTester = new eslint.RuleTester({
|
|
6
|
-
languageOptions: {
|
|
7
|
-
parser,
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
ruleTester.run('straight-quotes', rule, {
|
|
12
|
-
valid: [
|
|
13
|
-
`
|
|
14
|
-
const values = [
|
|
15
|
-
{
|
|
16
|
-
title: 'Put community first 💙',
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
`,
|
|
20
|
-
],
|
|
21
|
-
invalid: [
|
|
22
|
-
{
|
|
23
|
-
code: `
|
|
24
|
-
const values = [
|
|
25
|
-
{
|
|
26
|
-
title: 'Put community first 💙',
|
|
27
|
-
description: 'We never lose sight of who we’re serving and why.',
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
`,
|
|
31
|
-
errors: [
|
|
32
|
-
{
|
|
33
|
-
messageId: 'wrongQuotes',
|
|
34
|
-
line: 5,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: `
|
|
40
|
-
// reference ID (also known as “SHA” or “hash”) of the commit we're building.
|
|
41
|
-
const values = 'foo';
|
|
42
|
-
`,
|
|
43
|
-
errors: [
|
|
44
|
-
{
|
|
45
|
-
line: 2,
|
|
46
|
-
column: 32,
|
|
47
|
-
messageId: 'wrongQuotes',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
line: 2,
|
|
51
|
-
column: 36,
|
|
52
|
-
messageId: 'wrongQuotes',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
line: 2,
|
|
56
|
-
column: 41,
|
|
57
|
-
messageId: 'wrongQuotes',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
line: 2,
|
|
61
|
-
column: 46,
|
|
62
|
-
messageId: 'wrongQuotes',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import remarkFrontmatter from 'remark-frontmatter';
|
|
3
|
-
import remarkMdx from 'remark-mdx';
|
|
4
|
-
import { remark } from 'remark';
|
|
5
|
-
import remarkGfm from 'remark-gfm';
|
|
6
|
-
import plugin from './firstBlockHeading.mjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} input
|
|
10
|
-
* @param {Parameters<typeof plugin>[0]} [options]
|
|
11
|
-
*/
|
|
12
|
-
function lint(input, options) {
|
|
13
|
-
const file = remark()
|
|
14
|
-
.use(remarkFrontmatter, ['yaml', 'toml'])
|
|
15
|
-
.use(remarkGfm)
|
|
16
|
-
.use(plugin, options)
|
|
17
|
-
.processSync(input);
|
|
18
|
-
return file.messages.map((message) => ({
|
|
19
|
-
reason: message.reason,
|
|
20
|
-
line: message.line ?? 0,
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} input
|
|
26
|
-
* @param {Parameters<typeof plugin>[0]} [options]
|
|
27
|
-
*/
|
|
28
|
-
function lintMdx(input, options) {
|
|
29
|
-
const file = remark()
|
|
30
|
-
.use(remarkFrontmatter, ['yaml', 'toml'])
|
|
31
|
-
.use(remarkGfm)
|
|
32
|
-
.use(remarkMdx)
|
|
33
|
-
.use(plugin, options)
|
|
34
|
-
.processSync(input);
|
|
35
|
-
return file.messages.map((message) => ({
|
|
36
|
-
reason: message.reason,
|
|
37
|
-
line: message.line ?? 0,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe('remark-lint-mui-first-block-heading', () => {
|
|
42
|
-
it('accepts a document starting with an h1', () => {
|
|
43
|
-
expect(lint(`# Title\n\nSome content.\n`)).toEqual([]);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('accepts an h1 after YAML frontmatter', () => {
|
|
47
|
-
expect(lint(`---\nfoo: bar\n---\n\n# Title\n`)).toEqual([]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('flags a paragraph before the h1', () => {
|
|
51
|
-
expect(lint(`Lead paragraph.\n\n# Title\n`)).toHaveLength(1);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('flags an h2 as the first block', () => {
|
|
55
|
-
expect(lint(`## Subtitle\n\nContent.\n`)).toHaveLength(1);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('flags an empty document', () => {
|
|
59
|
-
expect(lint(``)).toHaveLength(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('flags a document starting with HTML', () => {
|
|
63
|
-
expect(lint(`<div>Hello</div>\n\n# Title\n`)).toHaveLength(1);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('accepts an h1 after a <style> block', () => {
|
|
67
|
-
expect(lint(`<style>.x { color: red; }</style>\n\n# Title\n`)).toEqual([]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('accepts an h1 after a <script> block', () => {
|
|
71
|
-
expect(lint(`<script>var x = 1;</script>\n\n# Title\n`)).toEqual([]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('accepts an h1 after an HTML comment', () => {
|
|
75
|
-
expect(lint(`<!-- a comment -->\n\n# Title\n`)).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('accepts an h1 after frontmatter and a <style> block', () => {
|
|
79
|
-
expect(lint(`---\nfoo: bar\n---\n\n<style>.x{}</style>\n\n# Title\n`)).toEqual([]);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('accepts a document with a title in YAML frontmatter', () => {
|
|
83
|
-
expect(lint(`---\ntitle: Hello\n---\n\nSome content.\n`)).toEqual([]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('still flags missing h1 when frontmatterTitle is disabled', () => {
|
|
87
|
-
expect(
|
|
88
|
-
lint(`---\ntitle: Hello\n---\n\nSome content.\n`, { frontMatterTitle: false }),
|
|
89
|
-
).toHaveLength(1);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('accepts an h1 after MDX imports', () => {
|
|
93
|
-
expect(lintMdx(`import Foo from './foo';\n\n# Title\n`)).toEqual([]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('accepts an h1 after an MDX block comment expression', () => {
|
|
97
|
-
expect(lintMdx(`{/* a comment */}\n\n# Title\n`)).toEqual([]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('accepts an h1 after MDX comment + imports', () => {
|
|
101
|
-
expect(lintMdx(`{/* lint disable */}\n\nimport Foo from './foo';\n\n# Title\n`)).toEqual([]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('flags an MDX expression that is not a comment', () => {
|
|
105
|
-
expect(lintMdx(`{value}\n\n# Title\n`)).toHaveLength(1);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { createLintTester } from './createLintTester.mjs';
|
|
3
|
-
import plugin from './gitDiff.mjs';
|
|
4
|
-
|
|
5
|
-
const lint = createLintTester(plugin);
|
|
6
|
-
|
|
7
|
-
describe('remark-lint-mui-git-diff', () => {
|
|
8
|
-
it('accepts a well-formed unified diff', () => {
|
|
9
|
-
const input = `# Title
|
|
10
|
-
|
|
11
|
-
\`\`\`diff
|
|
12
|
-
diff --git a/foo.txt b/foo.txt
|
|
13
|
-
index 0000..1111 100644
|
|
14
|
-
--- a/foo.txt
|
|
15
|
-
+++ b/foo.txt
|
|
16
|
-
@@ -1,2 +1,2 @@
|
|
17
|
-
unchanged line
|
|
18
|
-
-removed line
|
|
19
|
-
+added line
|
|
20
|
-
\`\`\`
|
|
21
|
-
`;
|
|
22
|
-
expect(lint(input)).toEqual([]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('ignores non-diff code blocks', () => {
|
|
26
|
-
const input = `\`\`\`js
|
|
27
|
-
const unrelated = 'line';
|
|
28
|
-
\`\`\`
|
|
29
|
-
`;
|
|
30
|
-
expect(lint(input)).toEqual([]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('flags lines that do not match the unified diff prefixes', () => {
|
|
34
|
-
const input = `\`\`\`diff
|
|
35
|
-
this line has no prefix
|
|
36
|
-
valid line
|
|
37
|
-
bad line too
|
|
38
|
-
\`\`\`
|
|
39
|
-
`;
|
|
40
|
-
const messages = lint(input);
|
|
41
|
-
expect(messages).toHaveLength(2);
|
|
42
|
-
expect(messages[0].line).toBe(2);
|
|
43
|
-
expect(messages[1].line).toBe(4);
|
|
44
|
-
});
|
|
45
|
-
});
|