eslint-plugin-jsdoc 61.1.8 → 61.1.9
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/rules/preferImportTag.cjs +1 -1
- package/dist/to-valid-identifier.cjs +261 -0
- package/package.json +5 -2
- package/rollup.config.js +16 -0
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _iterateJsdoc = _interopRequireWildcard(require("../iterateJsdoc.cjs"));
|
|
8
8
|
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
9
9
|
var _parseImportsExports = require("parse-imports-exports");
|
|
10
|
-
var _toValidIdentifier = _interopRequireDefault(require("to-valid-identifier"));
|
|
10
|
+
var _toValidIdentifier = _interopRequireDefault(require("../to-valid-identifier.cjs"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
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); }
|
|
13
13
|
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://262.ecma-international.org/14.0/#sec-keywords-and-reserved-words
|
|
4
|
+
// 14 is ES2023
|
|
5
|
+
const identifiers = [
|
|
6
|
+
// Keywords
|
|
7
|
+
'await',
|
|
8
|
+
'break',
|
|
9
|
+
'case',
|
|
10
|
+
'catch',
|
|
11
|
+
'class',
|
|
12
|
+
'const',
|
|
13
|
+
'continue',
|
|
14
|
+
'debugger',
|
|
15
|
+
'default',
|
|
16
|
+
'delete',
|
|
17
|
+
'do',
|
|
18
|
+
'else',
|
|
19
|
+
'enum',
|
|
20
|
+
'export',
|
|
21
|
+
'extends',
|
|
22
|
+
'false',
|
|
23
|
+
'finally',
|
|
24
|
+
'for',
|
|
25
|
+
'function',
|
|
26
|
+
'if',
|
|
27
|
+
'import',
|
|
28
|
+
'in',
|
|
29
|
+
'instanceof',
|
|
30
|
+
'new',
|
|
31
|
+
'null',
|
|
32
|
+
'return',
|
|
33
|
+
'super',
|
|
34
|
+
'switch',
|
|
35
|
+
'this',
|
|
36
|
+
'throw',
|
|
37
|
+
'true',
|
|
38
|
+
'try',
|
|
39
|
+
'typeof',
|
|
40
|
+
'var',
|
|
41
|
+
'void',
|
|
42
|
+
'while',
|
|
43
|
+
'with',
|
|
44
|
+
'yield',
|
|
45
|
+
|
|
46
|
+
// Future reserved keywords
|
|
47
|
+
'implements',
|
|
48
|
+
'interface',
|
|
49
|
+
'package',
|
|
50
|
+
'private',
|
|
51
|
+
'protected',
|
|
52
|
+
'public',
|
|
53
|
+
|
|
54
|
+
// Not keywords, but still restricted
|
|
55
|
+
'arguments',
|
|
56
|
+
'eval',
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
// https://262.ecma-international.org/14.0/#sec-value-properties-of-the-global-object
|
|
60
|
+
const globalProperties = [
|
|
61
|
+
'globalThis',
|
|
62
|
+
'Infinity',
|
|
63
|
+
'NaN',
|
|
64
|
+
'undefined',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
function reservedIdentifiers$1({includeGlobalProperties = false} = {}) {
|
|
68
|
+
return new Set([
|
|
69
|
+
...identifiers,
|
|
70
|
+
...(includeGlobalProperties ? globalProperties : []),
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* eslint-disable no-bitwise */
|
|
75
|
+
|
|
76
|
+
const BASE = 62;
|
|
77
|
+
const BASE_BIGINT = 62n;
|
|
78
|
+
const DEFAULT_ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
79
|
+
|
|
80
|
+
const cachedEncoder = new globalThis.TextEncoder();
|
|
81
|
+
const cachedDecoder = new globalThis.TextDecoder();
|
|
82
|
+
|
|
83
|
+
function assertString(value, label) {
|
|
84
|
+
if (typeof value !== 'string') {
|
|
85
|
+
throw new TypeError(`The \`${label}\` parameter must be a string, got \`${value}\` (${typeof value}).`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function validateAlphabet(alphabet) {
|
|
90
|
+
if (typeof alphabet !== 'string') {
|
|
91
|
+
throw new TypeError(`The alphabet must be a string, got \`${alphabet}\` (${typeof alphabet}).`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (alphabet.length !== BASE) {
|
|
95
|
+
throw new TypeError(`The alphabet must be exactly ${BASE} characters long, got ${alphabet.length}.`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const uniqueCharacters = new Set(alphabet);
|
|
99
|
+
if (uniqueCharacters.size !== BASE) {
|
|
100
|
+
throw new TypeError(`The alphabet must contain ${BASE} unique characters, got ${uniqueCharacters.size}.`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class Base62 {
|
|
105
|
+
constructor(options = {}) {
|
|
106
|
+
const alphabet = options.alphabet ?? DEFAULT_ALPHABET;
|
|
107
|
+
validateAlphabet(alphabet);
|
|
108
|
+
this.alphabet = [...alphabet];
|
|
109
|
+
this.indices = new Map(this.alphabet.map((character, index) => [character, index]));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#getIndex(character) {
|
|
113
|
+
const index = this.indices.get(character);
|
|
114
|
+
|
|
115
|
+
if (index === undefined) {
|
|
116
|
+
throw new TypeError(`Unexpected character for Base62 encoding: \`${character}\`.`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return index;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
encodeString(string) {
|
|
123
|
+
assertString(string, 'string');
|
|
124
|
+
return this.encodeBytes(cachedEncoder.encode(string));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
decodeString(encodedString) {
|
|
128
|
+
assertString(encodedString, 'encodedString');
|
|
129
|
+
return cachedDecoder.decode(this.decodeBytes(encodedString));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
encodeBytes(bytes) {
|
|
133
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
134
|
+
throw new TypeError('The `bytes` parameter must be an instance of Uint8Array.');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (bytes.length === 0) {
|
|
138
|
+
return '';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Prepend 0x01 to the byte array before encoding to ensure the BigInt conversion
|
|
142
|
+
// does not strip any leading zeros and to prevent any byte sequence from being
|
|
143
|
+
// interpreted as a numerically zero value.
|
|
144
|
+
let value = 1n;
|
|
145
|
+
|
|
146
|
+
for (const byte of bytes) {
|
|
147
|
+
value = (value << 8n) | BigInt(byte);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return this.encodeBigInt(value);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
decodeBytes(encodedString) {
|
|
154
|
+
assertString(encodedString, 'encodedString');
|
|
155
|
+
|
|
156
|
+
if (encodedString.length === 0) {
|
|
157
|
+
return new Uint8Array();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let value = this.decodeBigInt(encodedString);
|
|
161
|
+
|
|
162
|
+
const byteArray = [];
|
|
163
|
+
while (value > 0n) {
|
|
164
|
+
byteArray.push(Number(value & 0xFFn));
|
|
165
|
+
value >>= 8n;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Remove the 0x01 that was prepended during encoding.
|
|
169
|
+
return Uint8Array.from(byteArray.reverse().slice(1));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
encodeInteger(integer) {
|
|
173
|
+
if (!Number.isInteger(integer)) {
|
|
174
|
+
throw new TypeError(`Expected an integer, got \`${integer}\` (${typeof integer}).`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (integer < 0) {
|
|
178
|
+
throw new TypeError('The integer must be non-negative.');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (integer === 0) {
|
|
182
|
+
return this.alphabet[0];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let encodedString = '';
|
|
186
|
+
while (integer > 0) {
|
|
187
|
+
encodedString = this.alphabet[integer % BASE] + encodedString;
|
|
188
|
+
integer = Math.floor(integer / BASE);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return encodedString;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
decodeInteger(encodedString) {
|
|
195
|
+
assertString(encodedString, 'encodedString');
|
|
196
|
+
|
|
197
|
+
let integer = 0;
|
|
198
|
+
for (const character of encodedString) {
|
|
199
|
+
integer = (integer * BASE) + this.#getIndex(character);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return integer;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
encodeBigInt(bigint) {
|
|
206
|
+
if (typeof bigint !== 'bigint') {
|
|
207
|
+
throw new TypeError(`Expected a bigint, got \`${bigint}\` (${typeof bigint}).`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (bigint < 0) {
|
|
211
|
+
throw new TypeError('The bigint must be non-negative.');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (bigint === 0n) {
|
|
215
|
+
return this.alphabet[0];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let encodedString = '';
|
|
219
|
+
while (bigint > 0n) {
|
|
220
|
+
encodedString = this.alphabet[Number(bigint % BASE_BIGINT)] + encodedString;
|
|
221
|
+
bigint /= BASE_BIGINT;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return encodedString;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
decodeBigInt(encodedString) {
|
|
228
|
+
assertString(encodedString, 'encodedString');
|
|
229
|
+
|
|
230
|
+
let bigint = 0n;
|
|
231
|
+
for (const character of encodedString) {
|
|
232
|
+
bigint = (bigint * BASE_BIGINT) + BigInt(this.#getIndex(character));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return bigint;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Create default instance with standard alphabet
|
|
240
|
+
const defaultBase62 = new Base62();
|
|
241
|
+
const encodeInteger = integer => defaultBase62.encodeInteger(integer);
|
|
242
|
+
|
|
243
|
+
const reservedIdentifiers = reservedIdentifiers$1({includeGlobalProperties: true});
|
|
244
|
+
|
|
245
|
+
const encodeCodePoint = x => `$${encodeInteger(x.codePointAt(0))}$`;
|
|
246
|
+
|
|
247
|
+
function toValidIdentifier(value) {
|
|
248
|
+
if (typeof value !== 'string') {
|
|
249
|
+
throw new TypeError(`Expected a string, got \`${typeof value}\`.`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (reservedIdentifiers.has(value)) {
|
|
253
|
+
// We prefix with underscore to avoid any potential conflicts with the Base62 encoded string.
|
|
254
|
+
return `$_${value}$`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return value.replaceAll(/(?<!^)\P{ID_Continue}/gu, encodeCodePoint)
|
|
258
|
+
.replaceAll(/^[^_\p{ID_Start}]/gu, encodeCodePoint);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
module.exports = toValidIdentifier;
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@es-joy/jsdoc-eslint-parser": "^0.25.0",
|
|
34
34
|
"@eslint/core": "^0.16.0",
|
|
35
35
|
"@hkdobrev/run-if-changed": "^0.6.3",
|
|
36
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
36
37
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
37
38
|
"@semantic-release/github": "^12.0.0",
|
|
38
39
|
"@semantic-release/npm": "^13.1.1",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"playwright": "^1.56.1",
|
|
70
71
|
"replace": "^1.2.2",
|
|
71
72
|
"rimraf": "^6.0.1",
|
|
73
|
+
"rollup": "^4.52.5",
|
|
72
74
|
"semantic-release": "^25.0.1",
|
|
73
75
|
"sinon": "^21.0.0",
|
|
74
76
|
"typescript": "5.9.3",
|
|
@@ -167,7 +169,8 @@
|
|
|
167
169
|
"tsc": "tsc",
|
|
168
170
|
"tsc-build": "tsc -p tsconfig-prod.json",
|
|
169
171
|
"tsc-cjs": "tsc -p tsconfig-cjs.json",
|
|
170
|
-
"
|
|
172
|
+
"rollup": "rollup -c",
|
|
173
|
+
"build": "node ./src/bin/buildEntryFileForTS.js && rimraf ./dist && pnpm rollup && NODE_ENV=production babel ./src --out-file-extension .cjs --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && replace 'to-valid-identifier' '../to-valid-identifier.cjs' 'dist' -r --include=\"*.cjs\" && replace 'require\\(\"\\.(.*?)\\.[^.]*?\"\\)' 'require(\".$1.cjs\")' 'dist' -r --include=\"*.cjs\" && pnpm tsc-build && pnpm tsc-cjs",
|
|
171
174
|
"attw": "attw --pack .",
|
|
172
175
|
"check-docs": "node ./src/bin/generateDocs.js --check",
|
|
173
176
|
"create-docs": "pnpm run create-options && node ./src/bin/generateDocs.js && pnpm ruleTypes",
|
|
@@ -182,5 +185,5 @@
|
|
|
182
185
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
183
186
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
184
187
|
},
|
|
185
|
-
"version": "61.1.
|
|
188
|
+
"version": "61.1.9"
|
|
186
189
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nodeResolve,
|
|
3
|
+
} from '@rollup/plugin-node-resolve';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
input: 'node_modules/to-valid-identifier/index.js',
|
|
8
|
+
output: {
|
|
9
|
+
file: 'dist/to-valid-identifier.cjs',
|
|
10
|
+
format: 'cjs',
|
|
11
|
+
},
|
|
12
|
+
plugins: [
|
|
13
|
+
nodeResolve(),
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
];
|