@docusaurus/eslint-plugin 0.0.0-5454 → 0.0.0-5457
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/lib/index.d.ts +3 -0
- package/lib/index.js +2 -0
- package/lib/rules/index.d.ts +1 -0
- package/lib/rules/index.js +2 -0
- package/lib/rules/prefer-docusaurus-heading.d.ts +8 -0
- package/lib/rules/prefer-docusaurus-heading.js +36 -0
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/rules/index.ts +2 -0
- package/src/rules/prefer-docusaurus-heading.ts +46 -0
package/lib/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare const _default: {
|
|
|
13
13
|
'no-html-links': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"link", [{
|
|
14
14
|
ignoreFullyResolved: boolean;
|
|
15
15
|
}], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
16
|
+
'prefer-docusaurus-heading': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"headings", [], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
16
17
|
};
|
|
17
18
|
configs: {
|
|
18
19
|
recommended: {
|
|
@@ -20,6 +21,7 @@ declare const _default: {
|
|
|
20
21
|
rules: {
|
|
21
22
|
'@docusaurus/string-literal-i18n-messages': string;
|
|
22
23
|
'@docusaurus/no-html-links': string;
|
|
24
|
+
'@docusaurus/prefer-docusaurus-heading': string;
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
all: {
|
|
@@ -28,6 +30,7 @@ declare const _default: {
|
|
|
28
30
|
'@docusaurus/string-literal-i18n-messages': string;
|
|
29
31
|
'@docusaurus/no-untranslated-text': string;
|
|
30
32
|
'@docusaurus/no-html-links': string;
|
|
33
|
+
'@docusaurus/prefer-docusaurus-heading': string;
|
|
31
34
|
};
|
|
32
35
|
};
|
|
33
36
|
};
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ module.exports = {
|
|
|
15
15
|
rules: {
|
|
16
16
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
|
17
17
|
'@docusaurus/no-html-links': 'warn',
|
|
18
|
+
'@docusaurus/prefer-docusaurus-heading': 'warn',
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
all: {
|
|
@@ -23,6 +24,7 @@ module.exports = {
|
|
|
23
24
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
|
24
25
|
'@docusaurus/no-untranslated-text': 'warn',
|
|
25
26
|
'@docusaurus/no-html-links': 'warn',
|
|
27
|
+
'@docusaurus/prefer-docusaurus-heading': 'warn',
|
|
26
28
|
},
|
|
27
29
|
},
|
|
28
30
|
},
|
package/lib/rules/index.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ declare const _default: {
|
|
|
12
12
|
'no-html-links': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"link", [{
|
|
13
13
|
ignoreFullyResolved: boolean;
|
|
14
14
|
}], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
15
|
+
'prefer-docusaurus-heading': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"headings", [], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
15
16
|
};
|
|
16
17
|
export default _default;
|
package/lib/rules/index.js
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const no_html_links_1 = tslib_1.__importDefault(require("./no-html-links"));
|
|
11
|
+
const prefer_docusaurus_heading_1 = tslib_1.__importDefault(require("./prefer-docusaurus-heading"));
|
|
11
12
|
const no_untranslated_text_1 = tslib_1.__importDefault(require("./no-untranslated-text"));
|
|
12
13
|
const string_literal_i18n_messages_1 = tslib_1.__importDefault(require("./string-literal-i18n-messages"));
|
|
13
14
|
exports.default = {
|
|
14
15
|
'no-untranslated-text': no_untranslated_text_1.default,
|
|
15
16
|
'string-literal-i18n-messages': string_literal_i18n_messages_1.default,
|
|
16
17
|
'no-html-links': no_html_links_1.default,
|
|
18
|
+
'prefer-docusaurus-heading': prefer_docusaurus_heading_1.default,
|
|
17
19
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"headings", [], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const util_1 = require("../util");
|
|
10
|
+
exports.default = (0, util_1.createRule)({
|
|
11
|
+
name: 'prefer-docusaurus-heading',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: {
|
|
15
|
+
description: 'enforce using Docusaurus theme Heading component instead of any <hn> tag',
|
|
16
|
+
recommended: false,
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
headings: 'Do not use any of the `<hn>` tags for headings. Use the `<Heading />` component from `@theme/Heading` instead.',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultOptions: [],
|
|
24
|
+
create(context) {
|
|
25
|
+
const headingTypes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
26
|
+
return {
|
|
27
|
+
JSXOpeningElement(node) {
|
|
28
|
+
const elementName = node.name.name;
|
|
29
|
+
if (!headingTypes.includes(elementName)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
context.report({ node, messageId: 'headings' });
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/eslint-plugin",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5457",
|
|
4
4
|
"description": "ESLint plugin to enforce best Docusaurus practices.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=16.14"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "ee5028f585f6d4f474839fafaa2d7d1fb4c46564"
|
|
37
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export = {
|
|
|
15
15
|
rules: {
|
|
16
16
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
|
17
17
|
'@docusaurus/no-html-links': 'warn',
|
|
18
|
+
'@docusaurus/prefer-docusaurus-heading': 'warn',
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
all: {
|
|
@@ -23,6 +24,7 @@ export = {
|
|
|
23
24
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
|
24
25
|
'@docusaurus/no-untranslated-text': 'warn',
|
|
25
26
|
'@docusaurus/no-html-links': 'warn',
|
|
27
|
+
'@docusaurus/prefer-docusaurus-heading': 'warn',
|
|
26
28
|
},
|
|
27
29
|
},
|
|
28
30
|
},
|
package/src/rules/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import noHtmlLinks from './no-html-links';
|
|
9
|
+
import preferDocusaurusHeading from './prefer-docusaurus-heading';
|
|
9
10
|
import noUntranslatedText from './no-untranslated-text';
|
|
10
11
|
import stringLiteralI18nMessages from './string-literal-i18n-messages';
|
|
11
12
|
|
|
@@ -13,4 +14,5 @@ export default {
|
|
|
13
14
|
'no-untranslated-text': noUntranslatedText,
|
|
14
15
|
'string-literal-i18n-messages': stringLiteralI18nMessages,
|
|
15
16
|
'no-html-links': noHtmlLinks,
|
|
17
|
+
'prefer-docusaurus-heading': preferDocusaurusHeading,
|
|
16
18
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {createRule} from '../util';
|
|
9
|
+
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
|
|
10
|
+
|
|
11
|
+
type Options = [];
|
|
12
|
+
type MessageIds = 'headings';
|
|
13
|
+
|
|
14
|
+
export default createRule<Options, MessageIds>({
|
|
15
|
+
name: 'prefer-docusaurus-heading',
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'problem',
|
|
18
|
+
docs: {
|
|
19
|
+
description:
|
|
20
|
+
'enforce using Docusaurus theme Heading component instead of any <hn> tag',
|
|
21
|
+
recommended: false,
|
|
22
|
+
},
|
|
23
|
+
schema: [],
|
|
24
|
+
messages: {
|
|
25
|
+
headings:
|
|
26
|
+
'Do not use any of the `<hn>` tags for headings. Use the `<Heading />` component from `@theme/Heading` instead.',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultOptions: [],
|
|
30
|
+
|
|
31
|
+
create(context) {
|
|
32
|
+
const headingTypes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
JSXOpeningElement(node) {
|
|
36
|
+
const elementName = (node.name as TSESTree.JSXIdentifier).name;
|
|
37
|
+
|
|
38
|
+
if (!headingTypes.includes(elementName)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
context.report({node, messageId: 'headings'});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|