eslint-plugin-jsdoc 55.0.3 → 55.0.5

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,217 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _decamelize = _interopRequireDefault(require("decamelize"));
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _gitdown = _interopRequireDefault(require("gitdown"));
10
+ var _glob = require("glob");
11
+ var _path = _interopRequireDefault(require("path"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /**
14
+ * This script is used to inline assertions into the README.md documents.
15
+ */
16
+ const dirname = __dirname;
17
+
18
+ /**
19
+ * @param {string} code
20
+ * @returns {string}
21
+ */
22
+ const trimCode = code => {
23
+ let lines = code.replace(/^\n/v, '').trimEnd().split('\n');
24
+ const firsLineIndentation = lines[0].match(/^\s+/v);
25
+ const lastLineIndentation = lines[lines.length - 1].match(/^\s+/v);
26
+ const firstIndentSize = firsLineIndentation ? firsLineIndentation[0].length : 0;
27
+ const lastIndentSize = lastLineIndentation ? lastLineIndentation[0].length : 0;
28
+ lines = lines.map((line, index) => {
29
+ const lineIndentSize = firstIndentSize !== 0 || index === 0 ? Math.min(firstIndentSize, lastIndentSize) : lastIndentSize;
30
+ return line.slice(lineIndentSize);
31
+ });
32
+ return lines.join('\n').replaceAll('\r', '\\r');
33
+ };
34
+
35
+ /**
36
+ * @param {import('eslint').RuleTester.InvalidTestCase|import('eslint').RuleTester.ValidTestCase} setup
37
+ * @param {string} ruleName
38
+ * @returns {string}
39
+ */
40
+ const formatCodeSnippet = (setup, ruleName) => {
41
+ const paragraphs = [];
42
+ paragraphs.push(trimCode(setup.code));
43
+ if (setup.settings) {
44
+ paragraphs.push(`// Settings: ${JSON.stringify(setup.settings)}`);
45
+ }
46
+ if (setup.options) {
47
+ paragraphs.push(`// "jsdoc/${ruleName}": ["error"|"warn", ${JSON.stringify(setup.options).slice(1)}`);
48
+ }
49
+ if ('errors' in setup) {
50
+ paragraphs.push(`// Message: ${/** @type {Array<import('eslint').RuleTester.TestCaseError>} */setup.errors[0].message}`);
51
+ }
52
+ return paragraphs.join('\n');
53
+ };
54
+ const getAssertions = async () => {
55
+ const assertionFiles = (await (0, _glob.glob)(_path.default.resolve(dirname, '../../test/rules/assertions/*.js'))).filter(file => {
56
+ return !file.includes('flatConfig');
57
+ }).toReversed();
58
+ const assertionNames = assertionFiles.map(filePath => {
59
+ return _path.default.basename(filePath, '.js');
60
+ });
61
+ const assertionCodes = await Promise.all(assertionFiles.map(async (filePath, idx) => {
62
+ /**
63
+ * @type {{
64
+ * invalid: (import('eslint').RuleTester.InvalidTestCase & {ignoreReadme?: true})[],
65
+ * valid: (import('eslint').RuleTester.ValidTestCase & {ignoreReadme?: true})[]
66
+ * }}
67
+ */
68
+ const codes = (await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(filePath)).default;
69
+ const ruleName = (0, _decamelize.default)(assertionNames[idx], {
70
+ separator: '-'
71
+ });
72
+ return {
73
+ invalid: codes.invalid.filter(({
74
+ ignoreReadme
75
+ }) => {
76
+ return !ignoreReadme;
77
+ }).map(setup => {
78
+ return formatCodeSnippet(setup, ruleName);
79
+ }),
80
+ valid: codes.valid.filter(({
81
+ ignoreReadme
82
+ }) => {
83
+ return !ignoreReadme;
84
+ }).map(setup => {
85
+ return formatCodeSnippet(setup, ruleName);
86
+ })
87
+ };
88
+ }));
89
+ return {
90
+ assertionNames,
91
+ assertions: Object.fromEntries(assertionNames.map((assertionName, index) => {
92
+ return [assertionName, assertionCodes[index]];
93
+ }))
94
+ };
95
+ };
96
+ const getSomeBranch = () => {
97
+ const gitConfig = _fs.default.readFileSync(_path.default.join(dirname, '../../.git/config')).toString();
98
+ const [, branch] = /\[branch "([^"]+)"\]/v.exec(gitConfig) || [];
99
+ return branch;
100
+ };
101
+
102
+ // Scan the directory for these instead?
103
+ const extraFiles = ['settings.md', 'advanced.md', 'processors.md', 'README.md'];
104
+ const otherPaths = extraFiles.map(extraFile => {
105
+ return _path.default.join(dirname, '..', '..', '.README', extraFile);
106
+ });
107
+ const generateDocs = async () => {
108
+ const {
109
+ assertionNames,
110
+ assertions
111
+ } = await getAssertions();
112
+ const docContents = await Promise.all([...assertionNames.map(assertionName => {
113
+ return _path.default.join(dirname, '..', '..', '.README', 'rules', (0, _decamelize.default)(assertionName, {
114
+ separator: '-'
115
+ }) + '.md');
116
+ }), ...otherPaths].map(async docPath => {
117
+ const gitdown = await _gitdown.default.readFile(docPath);
118
+ gitdown.setConfig({
119
+ gitinfo: {
120
+ defaultBranchName: getSomeBranch() || 'master',
121
+ gitPath: _path.default.join(dirname, '../../.git')
122
+ }
123
+ });
124
+ return gitdown.get();
125
+ }));
126
+ return docContents.map(docContent => {
127
+ return docContent.replaceAll(/<!-- assertions-(passing|failing) ([a-z]+?) -->/gvi,
128
+ /**
129
+ * @param {string} _assertionsBlock
130
+ * @param {string} passingFailing
131
+ * @param {string} ruleName
132
+ * @returns {string}
133
+ */
134
+ (_assertionsBlock, passingFailing, ruleName) => {
135
+ const ruleAssertions = assertions[ruleName];
136
+ if (!ruleAssertions) {
137
+ throw new Error(`No assertions available for rule "${ruleName}".`);
138
+ }
139
+ return passingFailing === 'failing' ? 'The following patterns are considered problems:\n\n````ts\n' + ruleAssertions.invalid.join('\n\n') + '\n````\n\n' : 'The following patterns are not considered problems:\n\n````ts\n' + ruleAssertions.valid.join('\n\n') + '\n````\n';
140
+ }
141
+ // Allow relative paths in source for #902 but generate compiled file in
142
+ // manner compatible with GitHub and npmjs.com
143
+ ).replaceAll('(../#', '(#user-content-eslint-plugin-jsdoc-');
144
+ });
145
+ };
146
+
147
+ /**
148
+ * @returns {string[]}
149
+ */
150
+ const getDocPaths = () => {
151
+ const basePath = _path.default.join(dirname, '..', '..', '.README');
152
+ const writeBasePath = _path.default.join(dirname, '..', '..', 'docs');
153
+ const docPaths = /** @type {string[]} */_fs.default.readdirSync(basePath).flatMap(docFile => {
154
+ if (extraFiles.includes(docFile)) {
155
+ // Will get path separately below
156
+ return null;
157
+ }
158
+ if (docFile === '.DS_Store') {
159
+ return null;
160
+ }
161
+ const innerBasePath = _path.default.join(basePath, docFile);
162
+ const writeInnerBasePath = _path.default.join(writeBasePath, docFile);
163
+ const stat = _fs.default.statSync(innerBasePath);
164
+ if (stat.isFile()) {
165
+ // Currently settings and advanced
166
+ return writeInnerBasePath;
167
+ }
168
+ if (stat.isDirectory()) {
169
+ return _fs.default.readdirSync(innerBasePath).map(innerDocFile => {
170
+ return _path.default.join(writeInnerBasePath, innerDocFile);
171
+ }).sort((a, b) => {
172
+ const newA = a.replace(/\.md/v, '');
173
+ const newB = b.replace(/\.md/v, '');
174
+ return newA < newB ? -1 : newB > newA ? 1 : 0;
175
+ });
176
+ }
177
+ return null;
178
+ }).filter(Boolean);
179
+ return [...docPaths, ...extraFiles.slice(0, -1).map(extraFile => {
180
+ return _path.default.join(dirname, '..', '..', 'docs', extraFile);
181
+ }), _path.default.join(dirname, '..', '..', 'README.md')];
182
+ };
183
+ const generateDocsAndWriteToDisk = async () => {
184
+ const [docContents, docPaths] = await Promise.all([generateDocs(), getDocPaths()]);
185
+ for (const [idx, docContent] of docContents.entries()) {
186
+ const destPath = docPaths[idx];
187
+ _fs.default.writeFileSync(destPath, docContent);
188
+ }
189
+ };
190
+ const assertDocsAreUpToDate = async () => {
191
+ const [docContents, docPaths] = await Promise.all([generateDocs(), getDocPaths()]);
192
+ for (const [idx, docContent] of docContents.entries()) {
193
+ const docPath = docPaths[idx];
194
+ const isUpToDate = _fs.default.readFileSync(docPath, 'utf8') === docContent;
195
+ if (!isUpToDate) {
196
+ throw new Error('Docs are not up to date, please run `pnpm run create-docs` to update it.');
197
+ }
198
+ }
199
+ };
200
+ const main = async () => {
201
+ try {
202
+ const hasCheckFlag = process.argv.includes('--check');
203
+ if (hasCheckFlag) {
204
+ await assertDocsAreUpToDate();
205
+ } else {
206
+ await generateDocsAndWriteToDisk();
207
+ }
208
+ } catch (error) {
209
+ /* eslint-disable-next-line no-console */
210
+ console.error(error);
211
+ process.exit(1);
212
+ }
213
+ };
214
+ main();
215
+ var _default = exports.default = generateDocs;
216
+ module.exports = exports.default;
217
+ //# sourceMappingURL=generateDocs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateDocs.cjs","names":["_decamelize","_interopRequireDefault","require","_fs","_gitdown","_glob","_path","e","__esModule","default","_interopRequireWildcard","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","dirname","__dirname","trimCode","code","lines","replace","trimEnd","split","firsLineIndentation","match","lastLineIndentation","length","firstIndentSize","lastIndentSize","map","line","index","lineIndentSize","Math","min","slice","join","replaceAll","formatCodeSnippet","setup","ruleName","paragraphs","push","settings","JSON","stringify","options","errors","message","getAssertions","assertionFiles","glob","path","resolve","filter","file","includes","toReversed","assertionNames","filePath","basename","assertionCodes","Promise","all","idx","codes","specifier","then","s","decamelize","separator","invalid","ignoreReadme","valid","assertions","fromEntries","assertionName","getSomeBranch","gitConfig","fs","readFileSync","toString","branch","exec","extraFiles","otherPaths","extraFile","generateDocs","docContents","docPath","gitdown","Gitdown","readFile","setConfig","gitinfo","defaultBranchName","gitPath","docContent","_assertionsBlock","passingFailing","ruleAssertions","Error","getDocPaths","basePath","writeBasePath","docPaths","readdirSync","flatMap","docFile","innerBasePath","writeInnerBasePath","stat","statSync","isFile","isDirectory","innerDocFile","sort","a","b","newA","newB","Boolean","generateDocsAndWriteToDisk","entries","destPath","writeFileSync","assertDocsAreUpToDate","isUpToDate","main","hasCheckFlag","process","argv","error","console","exit","_default","exports","module"],"sources":["../src/bin/generateDocs.js"],"sourcesContent":["import decamelize from 'decamelize';\nimport fs from 'fs';\nimport Gitdown from 'gitdown';\nimport {\n glob,\n} from 'glob';\n/**\n * This script is used to inline assertions into the README.md documents.\n */\nimport path from 'path';\n\nconst dirname = import.meta.dirname;\n\n/**\n * @param {string} code\n * @returns {string}\n */\nconst trimCode = (code) => {\n let lines = code.replace(/^\\n/v, '').trimEnd().split('\\n');\n\n const firsLineIndentation = lines[0].match(/^\\s+/v);\n const lastLineIndentation = lines[lines.length - 1].match(/^\\s+/v);\n\n const firstIndentSize = firsLineIndentation ? firsLineIndentation[0].length : 0;\n const lastIndentSize = lastLineIndentation ? lastLineIndentation[0].length : 0;\n\n lines = lines.map((line, index) => {\n const lineIndentSize = firstIndentSize !== 0 || index === 0 ?\n Math.min(firstIndentSize, lastIndentSize) :\n lastIndentSize;\n\n return line.slice(lineIndentSize);\n });\n\n return lines.join('\\n').replaceAll('\\r', '\\\\r');\n};\n\n/**\n * @param {import('eslint').RuleTester.InvalidTestCase|import('eslint').RuleTester.ValidTestCase} setup\n * @param {string} ruleName\n * @returns {string}\n */\nconst formatCodeSnippet = (setup, ruleName) => {\n const paragraphs = [];\n\n paragraphs.push(trimCode(setup.code));\n\n if (setup.settings) {\n paragraphs.push(`// Settings: ${JSON.stringify(setup.settings)}`);\n }\n\n if (setup.options) {\n paragraphs.push(`// \"jsdoc/${ruleName}\": [\"error\"|\"warn\", ${JSON.stringify(setup.options).slice(1)}`);\n }\n\n if ('errors' in setup) {\n paragraphs.push(`// Message: ${\n /** @type {Array<import('eslint').RuleTester.TestCaseError>} */ (\n setup.errors\n )[0].message}`);\n }\n\n return paragraphs.join('\\n');\n};\n\nconst getAssertions = async () => {\n const assertionFiles = (await glob(path.resolve(dirname, '../../test/rules/assertions/*.js'))).filter((file) => {\n return !file.includes('flatConfig');\n }).toReversed();\n\n const assertionNames = assertionFiles.map((filePath) => {\n return path.basename(filePath, '.js');\n });\n\n const assertionCodes = await Promise.all(assertionFiles.map(async (filePath, idx) => {\n /**\n * @type {{\n * invalid: (import('eslint').RuleTester.InvalidTestCase & {ignoreReadme?: true})[],\n * valid: (import('eslint').RuleTester.ValidTestCase & {ignoreReadme?: true})[]\n * }}\n */\n const codes = (await import(filePath)).default;\n\n const ruleName = decamelize(assertionNames[idx], {\n separator: '-',\n });\n\n return {\n invalid: codes.invalid.filter(({\n ignoreReadme,\n }) => {\n return !ignoreReadme;\n }).map((setup) => {\n return formatCodeSnippet(setup, ruleName);\n }),\n valid: codes.valid.filter(({\n ignoreReadme,\n }) => {\n return !ignoreReadme;\n }).map((setup) => {\n return formatCodeSnippet(setup, ruleName);\n }),\n };\n }));\n\n return {\n assertionNames,\n assertions: Object.fromEntries(assertionNames.map((assertionName, index) => {\n return [\n assertionName, assertionCodes[index],\n ];\n })),\n };\n};\n\nconst getSomeBranch = () => {\n const gitConfig = fs.readFileSync(path.join(dirname, '../../.git/config')).toString();\n const [\n , branch,\n ] = /\\[branch \"([^\"]+)\"\\]/v.exec(gitConfig) || [];\n\n return branch;\n};\n\n// Scan the directory for these instead?\nconst extraFiles = [\n 'settings.md',\n 'advanced.md',\n 'processors.md',\n 'README.md',\n];\n\nconst otherPaths = extraFiles.map((extraFile) => {\n return path.join(dirname, '..', '..', '.README', extraFile);\n});\n\nconst generateDocs = async () => {\n const {\n assertionNames,\n assertions,\n } = await getAssertions();\n\n const docContents = await Promise.all([\n ...assertionNames.map((assertionName) => {\n return path.join(\n dirname, '..', '..', '.README', 'rules', decamelize(assertionName, {\n separator: '-',\n }) + '.md',\n );\n }),\n ...otherPaths,\n ].map(async (docPath) => {\n const gitdown = await Gitdown.readFile(docPath);\n\n gitdown.setConfig({\n gitinfo: {\n defaultBranchName: getSomeBranch() || 'master',\n gitPath: path.join(dirname, '../../.git'),\n },\n });\n\n return gitdown.get();\n }));\n\n return docContents.map((docContent) => {\n return docContent.replaceAll(\n /<!-- assertions-(passing|failing) ([a-z]+?) -->/gvi,\n /**\n * @param {string} _assertionsBlock\n * @param {string} passingFailing\n * @param {string} ruleName\n * @returns {string}\n */\n (_assertionsBlock, passingFailing, ruleName) => {\n const ruleAssertions = assertions[ruleName];\n\n if (!ruleAssertions) {\n throw new Error(`No assertions available for rule \"${ruleName}\".`);\n }\n\n return passingFailing === 'failing' ?\n 'The following patterns are considered problems:\\n\\n````ts\\n' +\n ruleAssertions.invalid.join('\\n\\n') + '\\n````\\n\\n' :\n 'The following patterns are not considered problems:\\n\\n````ts\\n' +\n ruleAssertions.valid.join('\\n\\n') + '\\n````\\n';\n },\n // Allow relative paths in source for #902 but generate compiled file in\n // manner compatible with GitHub and npmjs.com\n ).replaceAll('(../#', '(#user-content-eslint-plugin-jsdoc-');\n });\n};\n\n/**\n * @returns {string[]}\n */\nconst getDocPaths = () => {\n const basePath = path.join(dirname, '..', '..', '.README');\n const writeBasePath = path.join(dirname, '..', '..', 'docs');\n const docPaths = /** @type {string[]} */ (fs.readdirSync(basePath).flatMap((docFile) => {\n if (extraFiles.includes(docFile)) {\n // Will get path separately below\n return null;\n }\n\n if (docFile === '.DS_Store') {\n return null;\n }\n\n const innerBasePath = path.join(basePath, docFile);\n const writeInnerBasePath = path.join(writeBasePath, docFile);\n const stat = fs.statSync(innerBasePath);\n if (stat.isFile()) {\n // Currently settings and advanced\n return writeInnerBasePath;\n }\n\n if (stat.isDirectory()) {\n return fs.readdirSync(innerBasePath).map((innerDocFile) => {\n return path.join(writeInnerBasePath, innerDocFile);\n }).sort((a, b) => {\n const newA = a.replace(/\\.md/v, '');\n const newB = b.replace(/\\.md/v, '');\n return newA < newB ? -1 : (newB > newA ? 1 : 0);\n });\n }\n\n return null;\n }).filter(Boolean));\n\n return [\n ...docPaths,\n ...extraFiles.slice(0, -1).map((extraFile) => {\n return path.join(dirname, '..', '..', 'docs', extraFile);\n }),\n path.join(dirname, '..', '..', 'README.md'),\n ];\n};\n\nconst generateDocsAndWriteToDisk = async () => {\n const [\n docContents,\n docPaths,\n ] = await Promise.all([\n generateDocs(), getDocPaths(),\n ]);\n for (const [\n idx,\n docContent,\n ] of docContents.entries()) {\n const destPath = docPaths[idx];\n fs.writeFileSync(destPath, docContent);\n }\n};\n\nconst assertDocsAreUpToDate = async () => {\n const [\n docContents,\n docPaths,\n ] = await Promise.all([\n generateDocs(), getDocPaths(),\n ]);\n for (const [\n idx,\n docContent,\n ] of docContents.entries()) {\n const docPath = docPaths[idx];\n const isUpToDate = fs.readFileSync(docPath, 'utf8') === docContent;\n\n if (!isUpToDate) {\n throw new Error('Docs are not up to date, please run `pnpm run create-docs` to update it.');\n }\n }\n};\n\nconst main = async () => {\n try {\n const hasCheckFlag = process.argv.includes('--check');\n\n if (hasCheckFlag) {\n await assertDocsAreUpToDate();\n } else {\n await generateDocsAndWriteToDisk();\n }\n } catch (error) {\n /* eslint-disable-next-line no-console */\n console.error(error);\n\n process.exit(1);\n }\n};\n\nmain();\n\nexport default generateDocs;\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAMA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,wBAAAH,CAAA,EAAAI,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OA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ACxC,MAAM,CACJtC,WAAW,EACXiB,QAAQ,CACT,GAAG,MAAM3C,OAAO,CAACC,GAAG,CAAC,CACpBwB,YAAY,CAAC,CAAC,EAAEe,WAAW,CAAC,CAAC,CAC9B,CAAC;EACF,KAAK,MAAM,CACTtC,GAAG,EACHiC,UAAU,CACX,IAAIT,WAAW,CAACmC,OAAO,CAAC,CAAC,EAAE;IAC1B,MAAMlC,OAAO,GAAGgB,QAAQ,CAACzC,GAAG,CAAC;IAC7B,MAAM+D,UAAU,GAAGhD,WAAE,CAACC,YAAY,CAACS,OAAO,EAAE,MAAM,CAAC,KAAKQ,UAAU;IAElE,IAAI,CAAC8B,UAAU,EAAE;MACf,MAAM,IAAI1B,KAAK,CAAC,0EAA0E,CAAC;IAC7F;EACF;AACF,CAAC;AAED,MAAM2B,IAAI,GAAG,MAAAA,CAAA,KAAY;EACvB,IAAI;IACF,MAAMC,YAAY,GAAGC,OAAO,CAACC,IAAI,CAAC3E,QAAQ,CAAC,SAAS,CAAC;IAErD,IAAIyE,YAAY,EAAE;MAChB,MAAMH,qBAAqB,CAAC,CAAC;IAC/B,CAAC,MAAM;MACL,MAAMJ,0BAA0B,CAAC,CAAC;IACpC;EACF,CAAC,CAAC,OAAOU,KAAK,EAAE;IACd;IACAC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IAEpBF,OAAO,CAACI,IAAI,CAAC,CAAC,CAAC;EACjB;AACF,CAAC;AAEDN,IAAI,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAA3I,OAAA,GAEQ0F,YAAY;AAAAkD,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAA3I,OAAA","ignoreList":[]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.jsdoc = exports.default = void 0;
7
+ var _objectDeepMerge = require("object-deep-merge");
8
+ var _indexCjs = _interopRequireDefault(require("./index-cjs.cjs"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /* eslint-disable perfectionist/sort-imports -- For auto-generate; Do not remove */
11
+ // BEGIN REPLACE
12
+ // eslint-disable-next-line unicorn/prefer-export-from --- Reusing `index`
13
+ var _default = exports.default = _indexCjs.default; // END REPLACE
14
+ /* eslint-disable jsdoc/valid-types -- Bug */
15
+ /**
16
+ * @type {((
17
+ * cfg?: {
18
+ * mergeSettings?: boolean,
19
+ * config?: `flat/${import('./index-cjs.js').ConfigGroups}${import('./index-cjs.js').ConfigVariants}${import('./index-cjs.js').ErrorLevelVariants}`,
20
+ * settings?: Partial<import('./iterateJsdoc.js').Settings>
21
+ * }
22
+ * ) => import('eslint').Linter.Config)}
23
+ */
24
+ /* eslint-enable jsdoc/valid-types -- Bug */
25
+ const jsdoc = function (cfg) {
26
+ /** @type {import('eslint').Linter.Config} */
27
+ let outputConfig = {
28
+ plugins: {
29
+ jsdoc: _indexCjs.default
30
+ }
31
+ };
32
+ if (cfg?.config) {
33
+ // @ts-expect-error Security check
34
+ if (cfg.config === '__proto__') {
35
+ throw new TypeError('Disallowed config value');
36
+ }
37
+ outputConfig = _indexCjs.default.configs[cfg.config];
38
+ }
39
+ outputConfig.settings = {
40
+ jsdoc: cfg?.mergeSettings === false ? cfg.settings : (0, _objectDeepMerge.merge)({}, cfg?.settings ?? {}, cfg?.config?.includes('recommended') ? {
41
+ // We may need to drop these for "typescript" (non-"flavor") configs,
42
+ // if support is later added: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
43
+ structuredTags: {
44
+ next: {
45
+ required: ['type']
46
+ },
47
+ throws: {
48
+ required: ['type']
49
+ },
50
+ yields: {
51
+ required: ['type']
52
+ }
53
+ }
54
+ } : {})
55
+ };
56
+ return outputConfig;
57
+ };
58
+ exports.jsdoc = jsdoc;
59
+ //# sourceMappingURL=index-esm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-esm.cjs","names":["_objectDeepMerge","require","_indexCjs","_interopRequireDefault","e","__esModule","default","_default","exports","index","jsdoc","cfg","outputConfig","plugins","config","TypeError","configs","settings","mergeSettings","merge","includes","structuredTags","next","required","throws","yields"],"sources":["../src/index-esm.js"],"sourcesContent":["/* eslint-disable perfectionist/sort-imports -- For auto-generate; Do not remove */\nimport {\n merge,\n} from 'object-deep-merge';\n\n// BEGIN REPLACE\nimport index from './index-cjs.js';\n\n// eslint-disable-next-line unicorn/prefer-export-from --- Reusing `index`\nexport default index;\n// END REPLACE\n\n/* eslint-disable jsdoc/valid-types -- Bug */\n/**\n * @type {((\n * cfg?: {\n * mergeSettings?: boolean,\n * config?: `flat/${import('./index-cjs.js').ConfigGroups}${import('./index-cjs.js').ConfigVariants}${import('./index-cjs.js').ErrorLevelVariants}`,\n * settings?: Partial<import('./iterateJsdoc.js').Settings>\n * }\n * ) => import('eslint').Linter.Config)}\n */\n/* eslint-enable jsdoc/valid-types -- Bug */\nexport const jsdoc = function (cfg) {\n /** @type {import('eslint').Linter.Config} */\n let outputConfig = {\n plugins: {\n jsdoc: index,\n },\n };\n if (\n cfg?.config\n ) {\n // @ts-expect-error Security check\n if (cfg.config === '__proto__') {\n throw new TypeError('Disallowed config value');\n }\n\n outputConfig = index.configs[cfg.config];\n }\n\n outputConfig.settings = {\n jsdoc: cfg?.mergeSettings === false ?\n cfg.settings :\n merge(\n {},\n cfg?.settings ?? {},\n cfg?.config?.includes('recommended') ?\n {\n // We may need to drop these for \"typescript\" (non-\"flavor\") configs,\n // if support is later added: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html\n structuredTags: {\n next: {\n required: [\n 'type',\n ],\n },\n throws: {\n required: [\n 'type',\n ],\n },\n yields: {\n required: [\n 'type',\n ],\n },\n },\n } :\n {},\n ),\n };\n\n return outputConfig;\n};\n"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmC,SAAAE,uBAAAC,CAAA,WAAA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