eslint-plugin-jsdoc 57.0.6 → 57.0.8
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 +2 -12
- package/dist/index-cjs.cjs +7 -81
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-cjs.d.ts +2 -12
- package/dist/index-esm.cjs +4 -3
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index.cjs +7 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -12
- package/package.json +4 -4
- package/src/buildForbidRuleDefinition.js +86 -0
- package/src/index-cjs.js +4 -87
- package/src/index-esm.js +3 -2
- package/src/index.js +4 -87
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
|
|
@@ -153,7 +70,7 @@ export const buildForbidRuleDefinition = ({
|
|
|
153
70
|
* @typedef {"" | "-error"} ErrorLevelVariants
|
|
154
71
|
* @type {import('eslint').ESLint.Plugin & {
|
|
155
72
|
* configs: Record<`flat/${ConfigGroups}${ConfigVariants}${ErrorLevelVariants}`,
|
|
156
|
-
* import('eslint').Linter.Config
|
|
73
|
+
* import('eslint').Linter.Config> & Record<"examples"|"default-expressions"|"examples-and-default-expressions", import('eslint').Linter.Config[]>
|
|
157
74
|
* }}
|
|
158
75
|
*/
|
|
159
76
|
const index = {};
|
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 './
|
|
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
|
|
@@ -159,7 +76,7 @@ export const buildForbidRuleDefinition = ({
|
|
|
159
76
|
* @typedef {"" | "-error"} ErrorLevelVariants
|
|
160
77
|
* @type {import('eslint').ESLint.Plugin & {
|
|
161
78
|
* configs: Record<`flat/${ConfigGroups}${ConfigVariants}${ErrorLevelVariants}`,
|
|
162
|
-
* import('eslint').Linter.Config
|
|
79
|
+
* import('eslint').Linter.Config> & Record<"examples"|"default-expressions"|"examples-and-default-expressions", import('eslint').Linter.Config[]>
|
|
163
80
|
* }}
|
|
164
81
|
*/
|
|
165
82
|
const index = {};
|