@mui/internal-code-infra 0.0.4-canary.65 → 0.0.4-canary.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.4-canary.65",
3
+ "version": "0.0.4-canary.66",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -29,10 +29,6 @@
29
29
  "types": "./build/utils/github.d.mts",
30
30
  "default": "./src/utils/github.mjs"
31
31
  },
32
- "./markdownlint": {
33
- "types": "./build/markdownlint/index.d.mts",
34
- "default": "./src/markdownlint/index.mjs"
35
- },
36
32
  "./remark": {
37
33
  "types": "./build/remark/config.d.mts",
38
34
  "default": "./src/remark/config.mjs"
@@ -192,7 +188,7 @@
192
188
  "publishConfig": {
193
189
  "access": "public"
194
190
  },
195
- "gitSha": "308d63cc49db1419769226ebad3e2ceec1dd49d2",
191
+ "gitSha": "db0c201b6c697cff1aab50b9b33270720c93f424",
196
192
  "scripts": {
197
193
  "build": "tsgo -p tsconfig.build.json",
198
194
  "typescript": "tsgo -noEmit",
@@ -1,56 +0,0 @@
1
- /**
2
- * @typedef {[string, string]} Attr
3
- */
4
- export type Attr = [string, string];
5
- export type Token = {
6
- type: string;
7
- info: string;
8
- tag: string;
9
- content: string;
10
- lineNumber: number;
11
- attrs: Attr[];
12
- };
13
- export type OnErrorObj = {
14
- lineNumber: number;
15
- detail?: string;
16
- };
17
- export type OnError = (err: OnErrorObj) => void;
18
- export type MdParams = {
19
- name: string;
20
- lines: string[];
21
- tokens: Token[];
22
- };
23
- /**
24
- * @typedef {Object} Token
25
- * @property {string} type
26
- * @property {string} info
27
- * @property {string} tag
28
- * @property {string} content
29
- * @property {number} lineNumber
30
- * @property {Attr[]} attrs
31
- */
32
- /**
33
- * @typedef {Object} OnErrorObj
34
- * @property {number} lineNumber
35
- * @property {string} [detail]
36
- */
37
- /**
38
- * @typedef {(err: OnErrorObj) => void} OnError
39
- */
40
- /**
41
- * @typedef {Object} MdParams
42
- * @property {string} name
43
- * @property {string[]} lines
44
- * @property {Token[]} tokens
45
- */
46
- declare const _default: {
47
- names: string[];
48
- description: string;
49
- tags: string[];
50
- /**
51
- * @param {import('./duplicate-h1.mjs').MdParams} params
52
- * @param {import('./duplicate-h1.mjs').OnError} onError
53
- */
54
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
55
- };
56
- export default _default;
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- names: string[];
3
- description: string;
4
- tags: string[];
5
- /**
6
- * @param {import('./duplicate-h1.mjs').MdParams} params
7
- * @param {import('./duplicate-h1.mjs').OnError} onError
8
- */
9
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
10
- };
11
- export default _default;
@@ -1,52 +0,0 @@
1
- import straightQuotes from './straight-quotes.mjs';
2
- /**
3
- * Create a base configuration for markdownlint.
4
- * @param {Object} options
5
- * @param {(typeof straightQuotes)[]} [options.rules] - An array of custom rules to include.
6
- * @param {string[]} [options.ignores] - An array of glob patterns to ignore.
7
- * @returns
8
- */
9
- export declare function createBaseConfig(options?: {
10
- rules?: (typeof straightQuotes)[];
11
- ignores?: string[];
12
- }): {
13
- config: {
14
- default: boolean;
15
- MD004: boolean;
16
- MD009: {
17
- br_spaces: number;
18
- strict: boolean;
19
- list_item_empty_lines: boolean;
20
- };
21
- MD013: boolean;
22
- MD014: boolean;
23
- MD024: {
24
- siblings_only: boolean;
25
- };
26
- MD025: {
27
- level: number;
28
- front_matter_title: string;
29
- };
30
- MD033: boolean;
31
- MD034: boolean;
32
- MD028: boolean;
33
- MD029: boolean;
34
- MD031: boolean;
35
- MD036: boolean;
36
- MD051: boolean;
37
- MD052: boolean;
38
- MD059: boolean;
39
- straightQuotes: boolean;
40
- gitDiff: boolean;
41
- tableAlignment: boolean;
42
- terminalLanguage: boolean;
43
- duplicateH1: boolean;
44
- };
45
- customRules: {
46
- names: string[];
47
- description: string;
48
- tags: string[];
49
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
50
- }[];
51
- ignores: string[];
52
- };
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- names: string[];
3
- description: string;
4
- tags: string[];
5
- /**
6
- * @param {import('./duplicate-h1.mjs').MdParams} params
7
- * @param {import('./duplicate-h1.mjs').OnError} onError
8
- */
9
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
10
- };
11
- export default _default;
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- names: string[];
3
- description: string;
4
- tags: string[];
5
- /**
6
- * @param {import('./duplicate-h1.mjs').MdParams} params
7
- * @param {import('./duplicate-h1.mjs').OnError} onError
8
- */
9
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
10
- };
11
- export default _default;
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- names: string[];
3
- description: string;
4
- tags: string[];
5
- /**
6
- * @param {import('./duplicate-h1.mjs').MdParams} params
7
- * @param {import('./duplicate-h1.mjs').OnError} onError
8
- */
9
- function: (params: import('./duplicate-h1.mjs').MdParams, onError: import('./duplicate-h1.mjs').OnError) => void;
10
- };
11
- export default _default;
@@ -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
- };