eslint-plugin-jsdoc 57.0.6 → 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.
- package/dist/buildForbidRuleDefinition.cjs +83 -0
- package/dist/buildForbidRuleDefinition.cjs.map +1 -0
- package/dist/buildForbidRuleDefinition.d.ts +11 -0
- package/dist/cjs/buildForbidRuleDefinition.d.ts +10 -0
- package/dist/cjs/index-cjs.d.ts +0 -10
- package/dist/index-cjs.cjs +6 -80
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-cjs.d.ts +0 -10
- package/dist/index-esm.cjs +4 -3
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index.cjs +6 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -10
- package/package.json +1 -1
- package/src/buildForbidRuleDefinition.js +86 -0
- package/src/index-cjs.js +3 -86
- package/src/index-esm.js +3 -2
- package/src/index.js +3 -86
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
|