comment-variables 1.1.1 → 1.1.3
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/README.md +1 -1
- package/comments.config.js +2 -0
- package/comments.config.json +5 -0
- package/library/_commons/constants/bases.js +0 -5
- package/library/_commons/rules/compress.js +1 -2
- package/library/_commons/rules/resolve.js +3 -6
- package/library/_commons/utilities/flows.js +6 -0
- package/library/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,4 +183,4 @@ And yes, even comments within JavaScript and TypeScript blocks in Markdown files
|
|
|
183
183
|
|
|
184
184
|
_Leverage the power of JavaScript to programmatically design your JavaScript comments._
|
|
185
185
|
|
|
186
|
-
**The Comment Variables VS Code extension is available [here](https://comvar.lemonsqueezy.com/buy/
|
|
186
|
+
**The Comment Variables VS Code extension is available [here](https://comvar.lemonsqueezy.com/buy/723b0220-ea5d-4b0a-835a-f0843e431639?logo=0&discount=0).**
|
package/comments.config.js
CHANGED
|
@@ -106,6 +106,8 @@ const data = {
|
|
|
106
106
|
constants: Object.freeze({
|
|
107
107
|
sortedReversedFlattenedConfigData:
|
|
108
108
|
"The whole `reversedFlattenedConfigData` turned from an object to an array of key-value arrays sorted by the descending length of each key to prevent partial replacements." /* $COMMENT#JSDOC#CONSTANTS#SORTEDREVERSEDFLATTENEDCONFIGDATA */,
|
|
109
|
+
composedVariablesExclusivesSet:
|
|
110
|
+
"A local Set out of composed variables exclusives for speed." /* $COMMENT#JSDOC#CONSTANTS#COMPOSEDVARIABLESEXCLUSIVESSET */,
|
|
109
111
|
}),
|
|
110
112
|
}),
|
|
111
113
|
};
|
package/comments.config.json
CHANGED
|
@@ -155,6 +155,11 @@
|
|
|
155
155
|
"value": "The whole `reversedFlattenedConfigData` turned from an object to an array of key-value arrays sorted by the descending length of each key to prevent partial replacements.",
|
|
156
156
|
"key": "JSDOC#CONSTANTS#SORTEDREVERSEDFLATTENEDCONFIGDATA",
|
|
157
157
|
"placeholder": "$COMMENT#JSDOC#CONSTANTS#SORTEDREVERSEDFLATTENEDCONFIGDATA"
|
|
158
|
+
},
|
|
159
|
+
"composedVariablesExclusivesSet": {
|
|
160
|
+
"value": "A local Set out of composed variables exclusives for speed.",
|
|
161
|
+
"key": "JSDOC#CONSTANTS#COMPOSEDVARIABLESEXCLUSIVESSET",
|
|
162
|
+
"placeholder": "$COMMENT#JSDOC#CONSTANTS#COMPOSEDVARIABLESEXCLUSIVESSET"
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
}
|
|
@@ -3,11 +3,6 @@ import path from "path";
|
|
|
3
3
|
|
|
4
4
|
import { cwd } from "comment-variables-resolve-config";
|
|
5
5
|
|
|
6
|
-
// rule names (now inside "comment-variables-resolve-config")
|
|
7
|
-
// export const resolveRuleName = "resolve";
|
|
8
|
-
// export const compressRuleName = "compress";
|
|
9
|
-
// export const placeholdersRuleName = "placeholders"; // rule?
|
|
10
|
-
|
|
11
6
|
// to prevent accidental changes
|
|
12
7
|
export const hasPackageJson = fs.existsSync(path.join(cwd, "package.json"));
|
|
13
8
|
// to prevent irreversible changes
|
|
@@ -16,7 +16,7 @@ const makeRule = (reversedFlattenedConfigData, composedVariablesExclusives) => {
|
|
|
16
16
|
reversedFlattenedConfigData
|
|
17
17
|
).sort(([a], [b]) => b.length - a.length);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/** A local Set out of composed variables exclusives for speed. */
|
|
20
20
|
const composedVariablesExclusivesSet = new Set(composedVariablesExclusives);
|
|
21
21
|
|
|
22
22
|
/** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<typeof placeholderMessageId, []>} */
|
|
@@ -49,7 +49,6 @@ const makeRule = (reversedFlattenedConfigData, composedVariablesExclusives) => {
|
|
|
49
49
|
commentKey,
|
|
50
50
|
] of sortedReversedFlattenedConfigData) {
|
|
51
51
|
// NEW
|
|
52
|
-
// if (composedVariablesExclusives.some((e) => commentKey === e))
|
|
53
52
|
if (composedVariablesExclusivesSet.has(commentKey)) continue;
|
|
54
53
|
|
|
55
54
|
const pattern = makeIsolatedStringRegex(resolvedValue);
|
|
@@ -15,7 +15,7 @@ const makeRule = (
|
|
|
15
15
|
composedVariablesExclusives,
|
|
16
16
|
aliases_flattenedKeys
|
|
17
17
|
) => {
|
|
18
|
-
|
|
18
|
+
/** A local Set out of composed variables exclusives for speed. */
|
|
19
19
|
const composedVariablesExclusivesSet = new Set(composedVariablesExclusives);
|
|
20
20
|
|
|
21
21
|
/** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<typeof placeholderMessageId, []>} */
|
|
@@ -58,11 +58,8 @@ const makeRule = (
|
|
|
58
58
|
const replacement = flattenedConfigData[key];
|
|
59
59
|
|
|
60
60
|
// NEW
|
|
61
|
-
// The
|
|
62
|
-
//
|
|
63
|
-
// Also, focusing exclusively on comment variables and barring aliases (and composed) solves many issues at once and can be checked within resolveConfig. // Done.
|
|
64
|
-
|
|
65
|
-
// if (replacement && composedVariablesExclusives.some((e) => key === e))
|
|
61
|
+
// The issue is that having patterns instead of the exact keys is way too powerful, effectively slow, and can lead to unplanned inconsistencies. It is true that doing it instance by instance, comment variable by comment variable, is painstaking. But it's the more secure in order to fix an issue that is essentially purely cosmetic.
|
|
62
|
+
// Also, focusing exclusively on comment variables and barring aliases (and composed) solves many issues at once, notably by covering aliases in one go.
|
|
66
63
|
if (replacement && composedVariablesExclusivesSet.has(key)) continue;
|
|
67
64
|
|
|
68
65
|
if (replacement) {
|
|
@@ -33,6 +33,7 @@ const coreCommentsFlow = async (
|
|
|
33
33
|
ruleName,
|
|
34
34
|
ignores,
|
|
35
35
|
flattenedConfigData,
|
|
36
|
+
// NEW
|
|
36
37
|
composedVariablesExclusives,
|
|
37
38
|
aliases_flattenedKeys
|
|
38
39
|
) => {
|
|
@@ -50,6 +51,7 @@ const coreCommentsFlow = async (
|
|
|
50
51
|
rules: {
|
|
51
52
|
[ruleName]: ruleNames_makeRules[ruleName](
|
|
52
53
|
flattenedConfigData,
|
|
54
|
+
// NEW
|
|
53
55
|
composedVariablesExclusives,
|
|
54
56
|
aliases_flattenedKeys
|
|
55
57
|
),
|
|
@@ -115,6 +117,7 @@ const coreCommentsFlow = async (
|
|
|
115
117
|
export const resolveCommentsFlow = async (
|
|
116
118
|
ignores,
|
|
117
119
|
flattenedConfigData,
|
|
120
|
+
// NEW
|
|
118
121
|
composedVariablesExclusives,
|
|
119
122
|
aliases_flattenedKeys
|
|
120
123
|
) =>
|
|
@@ -122,6 +125,7 @@ export const resolveCommentsFlow = async (
|
|
|
122
125
|
resolveRuleName,
|
|
123
126
|
ignores,
|
|
124
127
|
flattenedConfigData,
|
|
128
|
+
// NEW
|
|
125
129
|
composedVariablesExclusives,
|
|
126
130
|
aliases_flattenedKeys
|
|
127
131
|
);
|
|
@@ -138,12 +142,14 @@ export const resolveCommentsFlow = async (
|
|
|
138
142
|
export const compressCommentsFlow = async (
|
|
139
143
|
ignores,
|
|
140
144
|
reversedFlattenedConfigData,
|
|
145
|
+
// NEW
|
|
141
146
|
composedVariablesExclusives
|
|
142
147
|
) =>
|
|
143
148
|
coreCommentsFlow(
|
|
144
149
|
compressRuleName,
|
|
145
150
|
ignores,
|
|
146
151
|
reversedFlattenedConfigData,
|
|
152
|
+
// NEW
|
|
147
153
|
composedVariablesExclusives
|
|
148
154
|
);
|
|
149
155
|
|
package/library/index.js
CHANGED
|
@@ -198,6 +198,7 @@ switch (coreCommand) {
|
|
|
198
198
|
await resolveCommentsFlow(
|
|
199
199
|
ignores,
|
|
200
200
|
flattenedConfigData,
|
|
201
|
+
// NEW
|
|
201
202
|
composedVariablesExclusives,
|
|
202
203
|
aliases_flattenedKeys
|
|
203
204
|
);
|
|
@@ -207,6 +208,7 @@ switch (coreCommand) {
|
|
|
207
208
|
await compressCommentsFlow(
|
|
208
209
|
ignores,
|
|
209
210
|
reversedFlattenedConfigData,
|
|
211
|
+
// NEW
|
|
210
212
|
composedVariablesExclusives
|
|
211
213
|
);
|
|
212
214
|
break;
|
package/package.json
CHANGED