@mui/internal-code-infra 0.0.4-canary.8 → 0.0.4-canary.80
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 +65 -41
- 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,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,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {[string, string]} Attr
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} Token
|
|
7
|
-
* @property {string} type
|
|
8
|
-
* @property {string} info
|
|
9
|
-
* @property {string} tag
|
|
10
|
-
* @property {string} content
|
|
11
|
-
* @property {number} lineNumber
|
|
12
|
-
* @property {Attr[]} attrs
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object} OnErrorObj
|
|
17
|
-
* @property {number} lineNumber
|
|
18
|
-
* @property {string} [detail]
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {(err: OnErrorObj) => void} OnError
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @typedef {Object} MdParams
|
|
27
|
-
* @property {string} name
|
|
28
|
-
* @property {string[]} lines
|
|
29
|
-
* @property {Token[]} tokens
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
// This rule is an extension of MD025/no-multiple-top-level-headings.
|
|
33
|
-
// The rule is buggy https://github.com/DavidAnson/markdownlint/pull/1109
|
|
34
|
-
// but also blog headers don't tell you that h1 is already injected.
|
|
35
|
-
export default {
|
|
36
|
-
names: ['duplicateH1'],
|
|
37
|
-
description: 'Multiple top-level headings in the same document.',
|
|
38
|
-
tags: ['headings'],
|
|
39
|
-
/**
|
|
40
|
-
* @param {import('./duplicate-h1.mjs').MdParams} params
|
|
41
|
-
* @param {import('./duplicate-h1.mjs').OnError} onError
|
|
42
|
-
*/
|
|
43
|
-
function: (params, onError) => {
|
|
44
|
-
/**
|
|
45
|
-
* @type {number|boolean}
|
|
46
|
-
*/
|
|
47
|
-
let hasTopLevelHeading = false;
|
|
48
|
-
params.tokens.forEach((token) => {
|
|
49
|
-
if (token.type === 'heading_open' && token.tag === 'h1') {
|
|
50
|
-
// Avoid duplicate errors with MD025.
|
|
51
|
-
if (hasTopLevelHeading !== false && hasTopLevelHeading !== 1) {
|
|
52
|
-
onError({
|
|
53
|
-
lineNumber: token.lineNumber,
|
|
54
|
-
});
|
|
55
|
-
} else if (params.name.includes('/docs/pages/blog/')) {
|
|
56
|
-
onError({
|
|
57
|
-
lineNumber: token.lineNumber,
|
|
58
|
-
detail: 'In the blog, the h1 is already added using the markdown header.title value.',
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Store the first h1 of the page.
|
|
63
|
-
if (hasTopLevelHeading === false) {
|
|
64
|
-
hasTopLevelHeading = token.lineNumber;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
names: ['gitDiff'],
|
|
3
|
-
description: 'Respect the format output of git diff.',
|
|
4
|
-
tags: ['spaces'],
|
|
5
|
-
/**
|
|
6
|
-
* @param {import('./duplicate-h1.mjs').MdParams} params
|
|
7
|
-
* @param {import('./duplicate-h1.mjs').OnError} onError
|
|
8
|
-
*/
|
|
9
|
-
function: (params, onError) => {
|
|
10
|
-
params.tokens.forEach((token) => {
|
|
11
|
-
if (token.type === 'fence' && token.info === 'diff') {
|
|
12
|
-
token.content.split('\n').forEach((line, index) => {
|
|
13
|
-
if (
|
|
14
|
-
line[0] !== ' ' &&
|
|
15
|
-
line[0] !== '-' &&
|
|
16
|
-
line[0] !== '+' &&
|
|
17
|
-
line !== '' &&
|
|
18
|
-
line.indexOf('@@ ') !== 0 &&
|
|
19
|
-
line.indexOf('diff --git ') !== 0 &&
|
|
20
|
-
line.indexOf('index ') !== 0
|
|
21
|
-
) {
|
|
22
|
-
onError({
|
|
23
|
-
lineNumber: token.lineNumber + index + 1,
|
|
24
|
-
detail: `The line start with "+" or "-" or " ": ${line}`,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import straightQuotes from './straight-quotes.mjs';
|
|
2
|
-
import gitDiff from './git-diff.mjs';
|
|
3
|
-
import tableAlignment from './table-alignment.mjs';
|
|
4
|
-
import terminalLanguage from './terminal-language.mjs';
|
|
5
|
-
import duplicateH1 from './duplicate-h1.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create a base configuration for markdownlint.
|
|
9
|
-
* @param {Object} options
|
|
10
|
-
* @param {(typeof straightQuotes)[]} [options.rules] - An array of custom rules to include.
|
|
11
|
-
* @param {string[]} [options.ignores] - An array of glob patterns to ignore.
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export function createBaseConfig(options = {}) {
|
|
15
|
-
const { rules = [], ignores = [] } = options;
|
|
16
|
-
// https://github.com/DavidAnson/markdownlint#rules--aliases
|
|
17
|
-
return {
|
|
18
|
-
config: {
|
|
19
|
-
default: true,
|
|
20
|
-
MD004: false, // MD004/ul-style. Buggy
|
|
21
|
-
MD009: {
|
|
22
|
-
// MD009/no-trailing-spaces
|
|
23
|
-
br_spaces: 0,
|
|
24
|
-
strict: true,
|
|
25
|
-
list_item_empty_lines: false,
|
|
26
|
-
},
|
|
27
|
-
MD013: false, // MD013/line-length. Already handled by Prettier.
|
|
28
|
-
MD014: false, // MD014/commands-show-output. It's OK.
|
|
29
|
-
MD024: { siblings_only: true }, // MD024/no-duplicate-heading/no-duplicate-header
|
|
30
|
-
MD025: {
|
|
31
|
-
// Heading level
|
|
32
|
-
level: 1,
|
|
33
|
-
// RegExp for matching title in front matter
|
|
34
|
-
front_matter_title: '',
|
|
35
|
-
},
|
|
36
|
-
MD033: false, // MD033/no-inline-html. We use it from time to time, it's fine.
|
|
37
|
-
MD034: false, // MD034/no-bare-urls. Not a concern for us, our Markdown interpreter supports it.
|
|
38
|
-
MD028: false, // MD028/no-blanks-blockquote prevent double blockquote
|
|
39
|
-
MD029: false, // MD029/ol-prefix. Buggy
|
|
40
|
-
MD031: false, // MD031/blanks-around-fences Some code blocks inside li
|
|
41
|
-
MD036: false, // MD036/no-emphasis-as-heading/no-emphasis-as-header. It's OK.
|
|
42
|
-
MD051: false, // MD051/link-fragments. Many false positives in the changelog.
|
|
43
|
-
MD052: false, // MD052/reference-links-images. Many false positives in the changelog.
|
|
44
|
-
MD059: false, // MD059/descriptive-link-text. Does not allow links on text like "link", whereas we redirect to "Link" component.
|
|
45
|
-
straightQuotes: true,
|
|
46
|
-
gitDiff: true,
|
|
47
|
-
tableAlignment: true,
|
|
48
|
-
terminalLanguage: true,
|
|
49
|
-
duplicateH1: true,
|
|
50
|
-
},
|
|
51
|
-
customRules: [straightQuotes, gitDiff, tableAlignment, terminalLanguage, duplicateH1, ...rules],
|
|
52
|
-
ignores: [
|
|
53
|
-
'CHANGELOG.old.md',
|
|
54
|
-
'**/node_modules/**',
|
|
55
|
-
'**/build/**',
|
|
56
|
-
'.github/PULL_REQUEST_TEMPLATE.md',
|
|
57
|
-
'docs/public/**',
|
|
58
|
-
'docs/export/**',
|
|
59
|
-
...ignores,
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const nonStraightQuotes = /[‘’“”]/;
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
names: ['straightQuotes'],
|
|
5
|
-
description: 'Only allow straight quotes.',
|
|
6
|
-
tags: ['spelling'],
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('./duplicate-h1.mjs').MdParams} params
|
|
9
|
-
* @param {import('./duplicate-h1.mjs').OnError} onError
|
|
10
|
-
*/
|
|
11
|
-
function: (params, onError) => {
|
|
12
|
-
params.lines.forEach((line, lineNumber) => {
|
|
13
|
-
// It will match
|
|
14
|
-
// opening single quote: \xE2\x80\x98
|
|
15
|
-
// closing single quote: \xE2\x80\x99
|
|
16
|
-
// opening double quote: \xE2\x80\x9C
|
|
17
|
-
// closing double quote: \xE2\x80\x9D
|
|
18
|
-
if (nonStraightQuotes.test(line)) {
|
|
19
|
-
onError({
|
|
20
|
-
lineNumber: lineNumber + 1,
|
|
21
|
-
detail: `For line: ${line}`,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {import('./duplicate-h1.mjs').Attr[]} attrs
|
|
3
|
-
* @returns {Record<string, string>}
|
|
4
|
-
*/
|
|
5
|
-
function attr(attrs) {
|
|
6
|
-
return (attrs || []).reduce((acc, item) => ({ ...acc, [item[0]]: item[1] }), {});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
names: ['tableAlignment'],
|
|
11
|
-
description: 'Set table alignment.',
|
|
12
|
-
tags: ['table'],
|
|
13
|
-
/**
|
|
14
|
-
* @param {import('./duplicate-h1.mjs').MdParams} params
|
|
15
|
-
* @param {import('./duplicate-h1.mjs').OnError} onError
|
|
16
|
-
*/
|
|
17
|
-
function: (params, onError) => {
|
|
18
|
-
params.tokens.forEach((token) => {
|
|
19
|
-
// This is wrong:
|
|
20
|
-
// | Version | Supported |
|
|
21
|
-
// | ------- | ------------------ |
|
|
22
|
-
//
|
|
23
|
-
// The second column should be left aligned because it contains text:
|
|
24
|
-
// | Version | Supported |
|
|
25
|
-
// | ------- | :----------------- |
|
|
26
|
-
//
|
|
27
|
-
// However, columns that includes numbers should be right aligned:
|
|
28
|
-
// | Version | Supported |
|
|
29
|
-
// | ------: | :----------------- |
|
|
30
|
-
//
|
|
31
|
-
// More details: https://ux.stackexchange.com/questions/24066/what-is-the-best-practice-for-data-table-cell-content-alignment
|
|
32
|
-
//
|
|
33
|
-
// In this check we expect the style to be 'text-align:right' or equivalent.
|
|
34
|
-
if (token.type === 'th_open' && attr(token.attrs).style == null) {
|
|
35
|
-
onError({
|
|
36
|
-
lineNumber: token.lineNumber,
|
|
37
|
-
detail: `${params.lines[token.lineNumber - 1]}`,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
names: ['terminalLanguage'],
|
|
3
|
-
description: 'Set the right language for terminal code.',
|
|
4
|
-
tags: ['code'],
|
|
5
|
-
/**
|
|
6
|
-
* @param {import('./duplicate-h1.mjs').MdParams} params
|
|
7
|
-
* @param {import('./duplicate-h1.mjs').OnError} onError
|
|
8
|
-
*/
|
|
9
|
-
function: (params, onError) => {
|
|
10
|
-
params.tokens.forEach((token) => {
|
|
11
|
-
if (token.type === 'fence' && token.info === 'sh') {
|
|
12
|
-
onError({
|
|
13
|
-
lineNumber: token.lineNumber,
|
|
14
|
-
detail: `Use "bash" instead of "sh".`,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
};
|