eslint-plugin-jsdoc 57.0.5 → 57.0.7

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.
@@ -0,0 +1,86 @@
1
+ import iterateJsdoc from './iterateJsdoc.js';
2
+
3
+ /**
4
+ * @param {{
5
+ * contexts: (string|{
6
+ * comment: string,
7
+ * context: string,
8
+ * message: string
9
+ * })[],
10
+ * description?: string,
11
+ * contextName?: string
12
+ * url?: string,
13
+ * }} cfg
14
+ * @returns {import('@eslint/core').RuleDefinition<
15
+ * import('@eslint/core').RuleDefinitionTypeOptions
16
+ * >}
17
+ */
18
+ export const buildForbidRuleDefinition = ({
19
+ contextName,
20
+ contexts,
21
+ description,
22
+ url,
23
+ }) => {
24
+ return iterateJsdoc(({
25
+ // context,
26
+ info: {
27
+ comment,
28
+ },
29
+ report,
30
+ utils,
31
+ }) => {
32
+ const {
33
+ contextStr,
34
+ foundContext,
35
+ } = utils.findContext(contexts, comment);
36
+
37
+ // We are not on the *particular* matching context/comment, so don't assume
38
+ // we need reporting
39
+ if (!foundContext) {
40
+ return;
41
+ }
42
+
43
+ const message = /** @type {import('./iterateJsdoc.js').ContextObject} */ (
44
+ foundContext
45
+ )?.message ??
46
+ 'Syntax is restricted: {{context}}' +
47
+ (comment ? ' with {{comment}}' : '');
48
+
49
+ report(message, null, null, comment ? {
50
+ comment,
51
+ context: contextStr,
52
+ } : {
53
+ context: contextStr,
54
+ });
55
+ }, {
56
+ contextSelected: true,
57
+ meta: {
58
+ docs: {
59
+ description: description ?? contextName ?? 'Reports when certain comment structures are present.',
60
+ url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',
61
+ },
62
+ fixable: 'code',
63
+ schema: [],
64
+ type: 'suggestion',
65
+ },
66
+ modifyContext: (context) => {
67
+ // Reproduce context object with our own `contexts`
68
+ const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
69
+ return Object.create(
70
+ Object.getPrototypeOf(context),
71
+ {
72
+ ...propertyDescriptors,
73
+ options: {
74
+ ...propertyDescriptors.options,
75
+ value: [
76
+ {
77
+ contexts,
78
+ },
79
+ ],
80
+ },
81
+ },
82
+ );
83
+ },
84
+ nonGlobalSettings: true,
85
+ });
86
+ };
package/src/index-cjs.js CHANGED
@@ -1,7 +1,9 @@
1
+ import {
2
+ buildForbidRuleDefinition,
3
+ } from './buildForbidRuleDefinition.js';
1
4
  import {
2
5
  getJsdocProcessorPlugin,
3
6
  } from './getJsdocProcessorPlugin.js';
4
- import iterateJsdoc from './iterateJsdoc.js';
5
7
  import checkAccess from './rules/checkAccess.js';
6
8
  import checkAlignment from './rules/checkAlignment.js';
7
9
  import checkExamples from './rules/checkExamples.js';
@@ -61,91 +63,6 @@ import textEscaping from './rules/textEscaping.js';
61
63
  import typeFormatting from './rules/typeFormatting.js';
62
64
  import validTypes from './rules/validTypes.js';
63
65
 
64
- /**
65
- * @param {{
66
- * contexts: (string|{
67
- * comment: string,
68
- * context: string,
69
- * message: string
70
- * })[],
71
- * description?: string,
72
- * contextName?: string
73
- * url?: string,
74
- * }} cfg
75
- * @returns {import('@eslint/core').RuleDefinition<
76
- * import('@eslint/core').RuleDefinitionTypeOptions
77
- * >}
78
- */
79
- export const buildForbidRuleDefinition = ({
80
- contextName,
81
- contexts,
82
- description,
83
- url,
84
- }) => {
85
- return iterateJsdoc(({
86
- // context,
87
- info: {
88
- comment,
89
- },
90
- report,
91
- utils,
92
- }) => {
93
- const {
94
- contextStr,
95
- foundContext,
96
- } = utils.findContext(contexts, comment);
97
-
98
- // We are not on the *particular* matching context/comment, so don't assume
99
- // we need reporting
100
- if (!foundContext) {
101
- return;
102
- }
103
-
104
- const message = /** @type {import('./iterateJsdoc.js').ContextObject} */ (
105
- foundContext
106
- )?.message ??
107
- 'Syntax is restricted: {{context}}' +
108
- (comment ? ' with {{comment}}' : '');
109
-
110
- report(message, null, null, comment ? {
111
- comment,
112
- context: contextStr,
113
- } : {
114
- context: contextStr,
115
- });
116
- }, {
117
- contextSelected: true,
118
- meta: {
119
- docs: {
120
- description: description ?? contextName ?? 'Reports when certain comment structures are present.',
121
- url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',
122
- },
123
- fixable: 'code',
124
- schema: [],
125
- type: 'suggestion',
126
- },
127
- modifyContext: (context) => {
128
- // Reproduce context object with our own `contexts`
129
- const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
130
- return Object.create(
131
- Object.getPrototypeOf(context),
132
- {
133
- ...propertyDescriptors,
134
- options: {
135
- ...propertyDescriptors.options,
136
- value: [
137
- {
138
- contexts,
139
- },
140
- ],
141
- },
142
- },
143
- );
144
- },
145
- nonGlobalSettings: true,
146
- });
147
- };
148
-
149
66
  /* eslint-disable jsdoc/valid-types -- Bug */
150
67
  /**
151
68
  * @typedef {"recommended" | "stylistic" | "contents" | "logical" | "requirements"} ConfigGroups
@@ -563,6 +480,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
563
480
  // Can generally look nicer to pad a little even if code imposes more stringency
564
481
  '@stylistic/padded-blocks': 0,
565
482
 
483
+ '@typescript-eslint/no-unused-vars': 0,
484
+
566
485
  // "always" newline rule at end unlikely in sample code
567
486
  'eol-last': 0,
568
487
 
package/src/index-esm.js CHANGED
@@ -4,9 +4,10 @@ import {
4
4
  } from 'object-deep-merge';
5
5
 
6
6
  // BEGIN REPLACE
7
- import index, {
7
+ import index from './index-cjs.js';
8
+ import {
8
9
  buildForbidRuleDefinition,
9
- } from './index-cjs.js';
10
+ } from './buildForbidRuleDefinition.js';
10
11
 
11
12
  // eslint-disable-next-line unicorn/prefer-export-from --- Reusing `index`
12
13
  export default index;
package/src/index.js CHANGED
@@ -4,10 +4,12 @@ import {
4
4
  merge,
5
5
  } from 'object-deep-merge';
6
6
 
7
+ import {
8
+ buildForbidRuleDefinition,
9
+ } from './buildForbidRuleDefinition.js';
7
10
  import {
8
11
  getJsdocProcessorPlugin,
9
12
  } from './getJsdocProcessorPlugin.js';
10
- import iterateJsdoc from './iterateJsdoc.js';
11
13
  import checkAccess from './rules/checkAccess.js';
12
14
  import checkAlignment from './rules/checkAlignment.js';
13
15
  import checkExamples from './rules/checkExamples.js';
@@ -67,91 +69,6 @@ import textEscaping from './rules/textEscaping.js';
67
69
  import typeFormatting from './rules/typeFormatting.js';
68
70
  import validTypes from './rules/validTypes.js';
69
71
 
70
- /**
71
- * @param {{
72
- * contexts: (string|{
73
- * comment: string,
74
- * context: string,
75
- * message: string
76
- * })[],
77
- * description?: string,
78
- * contextName?: string
79
- * url?: string,
80
- * }} cfg
81
- * @returns {import('@eslint/core').RuleDefinition<
82
- * import('@eslint/core').RuleDefinitionTypeOptions
83
- * >}
84
- */
85
- export const buildForbidRuleDefinition = ({
86
- contextName,
87
- contexts,
88
- description,
89
- url,
90
- }) => {
91
- return iterateJsdoc(({
92
- // context,
93
- info: {
94
- comment,
95
- },
96
- report,
97
- utils,
98
- }) => {
99
- const {
100
- contextStr,
101
- foundContext,
102
- } = utils.findContext(contexts, comment);
103
-
104
- // We are not on the *particular* matching context/comment, so don't assume
105
- // we need reporting
106
- if (!foundContext) {
107
- return;
108
- }
109
-
110
- const message = /** @type {import('./iterateJsdoc.js').ContextObject} */ (
111
- foundContext
112
- )?.message ??
113
- 'Syntax is restricted: {{context}}' +
114
- (comment ? ' with {{comment}}' : '');
115
-
116
- report(message, null, null, comment ? {
117
- comment,
118
- context: contextStr,
119
- } : {
120
- context: contextStr,
121
- });
122
- }, {
123
- contextSelected: true,
124
- meta: {
125
- docs: {
126
- description: description ?? contextName ?? 'Reports when certain comment structures are present.',
127
- url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',
128
- },
129
- fixable: 'code',
130
- schema: [],
131
- type: 'suggestion',
132
- },
133
- modifyContext: (context) => {
134
- // Reproduce context object with our own `contexts`
135
- const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
136
- return Object.create(
137
- Object.getPrototypeOf(context),
138
- {
139
- ...propertyDescriptors,
140
- options: {
141
- ...propertyDescriptors.options,
142
- value: [
143
- {
144
- contexts,
145
- },
146
- ],
147
- },
148
- },
149
- );
150
- },
151
- nonGlobalSettings: true,
152
- });
153
- };
154
-
155
72
  /* eslint-disable jsdoc/valid-types -- Bug */
156
73
  /**
157
74
  * @typedef {"recommended" | "stylistic" | "contents" | "logical" | "requirements"} ConfigGroups
@@ -569,6 +486,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([
569
486
  // Can generally look nicer to pad a little even if code imposes more stringency
570
487
  '@stylistic/padded-blocks': 0,
571
488
 
489
+ '@typescript-eslint/no-unused-vars': 0,
490
+
572
491
  // "always" newline rule at end unlikely in sample code
573
492
  'eol-last': 0,
574
493
 
@@ -47,6 +47,8 @@ const defaultMdRules = {
47
47
  // Can generally look nicer to pad a little even if code imposes more stringency
48
48
  '@stylistic/padded-blocks': 0,
49
49
 
50
+ '@typescript-eslint/no-unused-vars': 0,
51
+
50
52
  // "always" newline rule at end unlikely in sample code
51
53
  'eol-last': 0,
52
54