comment-variables 0.12.2 → 0.12.4

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.
@@ -1,12 +1,14 @@
1
+ // const obj = { test: "Testing." }; // errors, object string values in config files are reserved for exports from the config.
2
+
1
3
  const data = {
2
4
  // for testing
3
5
  levelOne: {
4
6
  levelTwo: {
5
7
  levelThree: "Level three." /* $COMMENT#LEVELONE#LEVELTWO#LEVELTHREE */, // New placeholder structure. Not as sexy, but first and foremost guaranteed to be functional appended right at the end of the value as a Block comment, and last but not least also guaranteed to not modify Value Locations in the process. So `comment-variables placeholders` it is, and this justifies enforcing strings only for values even outside of the use of the VS Code extension.
6
- levelThreeEscape:
7
- "Level three. \
8
- fdff\
9
- " /* $COMMENT#LEVELONE#LEVELTWO#LEVELTHREEESCAPE */, // valid
8
+ // levelThreeEscape:
9
+ // "Level three. \
10
+ // fdff\
11
+ // " /* $COMMENT#LEVELONE#LEVELTWO#LEVELTHREEESCAPE */, // NOW ERRORS AS INTENDED, unrecognizedValuesSet
10
12
  stillLevelThree:
11
13
  "LEVELONE#LEVELTWO#LEVELTHREE" /* $COMMENT#LEVELONE#LEVELTWO#STILLLEVELTHREE */, // now is an alias
12
14
  otherLevelThree:
@@ -44,6 +46,7 @@ const data = {
44
46
  // key: "key not allowed", // errors, "key", "value" and "placeholder" not allowed
45
47
  // value: "value not allowed", // errors, "key", "value" and "placeholder" not allowed
46
48
  // placeholder: "placeholder not allowed", // errors, "key", "value" and "placeholder" not allowed
49
+ // noConcat: "no" + "concat", // errors, unrecognized value
47
50
  },
48
51
  },
49
52
  // for deving
@@ -6,11 +6,6 @@
6
6
  "key": "LEVELONE#LEVELTWO#LEVELTHREE",
7
7
  "placeholder": "$COMMENT#LEVELONE#LEVELTWO#LEVELTHREE"
8
8
  },
9
- "levelThreeEscape": {
10
- "value": "Level three. fdff",
11
- "key": "LEVELONE#LEVELTWO#LEVELTHREEESCAPE",
12
- "placeholder": "$COMMENT#LEVELONE#LEVELTWO#LEVELTHREEESCAPE"
13
- },
14
9
  "stillLevelThree": {
15
10
  "value": "Level three.",
16
11
  "key": "LEVELONE#LEVELTWO#STILLLEVELTHREE",
@@ -5,9 +5,9 @@ import {
5
5
  } from "comment-variables-resolve-config";
6
6
 
7
7
  /**
8
- * $COMMENT#JSDOC#DEFINITIONS#MAKERULECOMPRESS
9
- * @param {{[key: string]: string}} reversedFlattenedConfigData $COMMENT#JSDOC#PARAMS#REVERSEDFLATTENEDCONFIGDATA
10
- * @returns $COMMENT#JSDOC#RETURNS#MAKERULECOMPRESS
8
+ * The utility that creates the compress rule based on the reversed flattened config data, used to transform actual comments into `$COMMENT` placeholders.
9
+ * @param {{[key: string]: string}} reversedFlattenedConfigData The reversed flattened config data, with actual comments as keys and `$COMMENT` placeholders as values.
10
+ * @returns The compress rule based on the reversed flattened config data.
11
11
  */
12
12
  const makeRule = (reversedFlattenedConfigData) => {
13
13
  /** 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. */
@@ -4,10 +4,10 @@ import {
4
4
  } from "comment-variables-resolve-config";
5
5
 
6
6
  /**
7
- * $COMMENT#JSDOC#DEFINITIONS#MAKERULERESOLVE
8
- * @param {{[key: string]: string}} flattenedConfigData $COMMENT#JSDOC#PARAMS#FLATTENEDCONFIGDATA
9
- * @param {{[key: string]: string}} aliases_flattenedKeys $COMMENT#JSDOC#PARAMS#ALIASES_FLATTENEDKEYS
10
- * @returns $COMMENT#JSDOC#RETURNS#MAKERULERESOLVE
7
+ * The utility that creates the resolve rule based on the flattened config data, used to transform `$COMMENT` placeholders into actual comments.
8
+ * @param {{[key: string]: string}} flattenedConfigData The flattened config data, with `$COMMENT` placeholders as keys and actual comments as values.
9
+ * @param {{[key: string]: string}} aliases_flattenedKeys The dictionary that connects aliases to their original flattened keys in case an encountered placeholder is actually an alias.
10
+ * @returns The resolve rule based on the flattened config data.
11
11
  */
12
12
  const makeRule = (flattenedConfigData, aliases_flattenedKeys) => {
13
13
  /** @type {import('@typescript-eslint/utils').TSESLint.RuleModule<typeof placeholderMessageId, []>} */
@@ -21,11 +21,11 @@ import { ruleNames_makeRules } from "../constants/rules.js";
21
21
  /* coreCommentsFlow */
22
22
 
23
23
  /**
24
- * $COMMENT#JSDOC#DEFINITIONS#CORECOMMENTSFLOW
25
- * @param {typeof resolveRuleName | typeof compressRuleName} ruleName $COMMENT#JSDOC#PARAMS#RULENAME
26
- * @param {string[]} ignores $COMMENT#JSDOC#PARAMS#IGNORES
27
- * @param {{[key: string]: string}} flattenedConfigData $COMMENT#JSDOC#PARAMS#EITHERFLATTENEDCONFIGDATA
28
- * @param {Record<string, string> | undefined} aliases_flattenedKeys $COMMENT#JSDOC#PARAMS#ALIASES_FLATTENEDKEYS
24
+ * The core flow at the heart of resolving and compressing comments.
25
+ * @param {typeof resolveRuleName | typeof compressRuleName} ruleName The name of the rule currently used. (Either `"resolve"` or `"compress"`.)
26
+ * @param {string[]} ignores The array of paths and globs for the flow's ESLint instance to ignore.
27
+ * @param {{[key: string]: string}} flattenedConfigData Either the flattened config data or the reversed flattened config data, since they share the same structure.
28
+ * @param {Record<string, string> | undefined} aliases_flattenedKeys The dictionary that connects aliases to their original flattened keys in case an encountered placeholder is actually an alias.
29
29
  * @returns
30
30
  */
31
31
  const coreCommentsFlow = async (
@@ -104,10 +104,10 @@ const coreCommentsFlow = async (
104
104
  /* resolveCommentsFlow */
105
105
 
106
106
  /**
107
- * $COMMENT#JSDOC#DEFINITIONS#RESOLVECOMMENTSFLOW
108
- * @param {string[]} ignores $COMMENT#JSDOC#PARAMS#IGNORES
109
- * @param {Record<string, string>} flattenedConfigData $COMMENT#JSDOC#PARAMS#FLATTENEDCONFIGDATA
110
- * @param {Record<string, string>} aliases_flattenedKeys $COMMENT#JSDOC#PARAMS#ALIASES_FLATTENEDKEYS
107
+ * The flow that resolves `$COMMENT` placeholders into actual comments.
108
+ * @param {string[]} ignores The array of paths and globs for the flow's ESLint instance to ignore.
109
+ * @param {Record<string, string>} flattenedConfigData The flattened config data, with `$COMMENT` placeholders as keys and actual comments as values.
110
+ * @param {Record<string, string>} aliases_flattenedKeys The dictionary that connects aliases to their original flattened keys in case an encountered placeholder is actually an alias.
111
111
  * @returns
112
112
  */
113
113
  export const resolveCommentsFlow = async (
@@ -125,9 +125,9 @@ export const resolveCommentsFlow = async (
125
125
  /* compressCommentsFlow */
126
126
 
127
127
  /**
128
- * $COMMENT#JSDOC#DEFINITIONS#COMPRESSCOMMENTSFLOW
129
- * @param {string[]} ignores $COMMENT#JSDOC#PARAMS#IGNORES
130
- * @param {{[key: string]: string}} reversedFlattenedConfigData $COMMENT#JSDOC#PARAMS#REVERSEDFLATTENEDCONFIGDATA
128
+ * The flow that compresses actual comments into `$COMMENT` placeholders.
129
+ * @param {string[]} ignores The array of paths and globs for the flow's ESLint instance to ignore.
130
+ * @param {{[key: string]: string}} reversedFlattenedConfigData The reversed flattened config data, with actual comments as keys and `$COMMENT` placeholders as values.
131
131
  * @returns
132
132
  */
133
133
  export const compressCommentsFlow = async (
@@ -138,10 +138,10 @@ export const compressCommentsFlow = async (
138
138
  /* placeholdersCommentsFlow */
139
139
 
140
140
  /**
141
- * $COMMENT#JSDOC#DEFINITIONS#PLACEHOLDERSCOMMENTSFLOW
142
- * @param {string[]} configPathIgnores $COMMENT#JSDOC#PARAMS#CONFIGPATHIGNORES
143
- * @param {{[k: string]: string;}} originalFlattenedConfigData $COMMENT#JSDOC#PARAMS#ORIGINALFLATTENEDCONFIGDATA
144
- * @param {Record<string, string>} aliases_flattenedKeys $COMMENT#JSDOC#PARAMS#ALIASES_FLATTENEDKEYS
141
+ * The flow that creates `$COMMENT` placeholders right next to where they're defined.
142
+ * @param {string[]} configPathIgnores The array of paths linked to the config file, (named "ignores" given it is ignored by the "compress" and "resolve" commands).
143
+ * @param {{[k: string]: string;}} originalFlattenedConfigData The original flattened config data, before changes to Aliases Variables and Composed Variables are applied.
144
+ * @param {Record<string, string>} aliases_flattenedKeys The dictionary that connects aliases to their original flattened keys in case an encountered placeholder is actually an alias.
145
145
  * @returns
146
146
  */
147
147
  export const placeholdersCommentsFlow = async (
@@ -1,16 +1,16 @@
1
1
  /* exitDueToFailure */
2
2
 
3
3
  /**
4
- * $COMMENT#JSDOC#DEFINITIONS#EXITDUETOFAILURE
5
- * @returns {never} $COMMENT#JSDOC#RETURNS#EXITDUETOFAILURE
4
+ * Terminates the whole process with a 'failure' code (`1`).
5
+ * @returns {never} Never. (Somehow typing needs to be explicit for unreachable code inference.)
6
6
  */
7
7
  export const exitDueToFailure = () => process.exit(1);
8
8
 
9
9
  /* logError */
10
10
 
11
11
  /**
12
- * $COMMENT#JSDOC#DEFINITIONS#LOGERROR
13
- * @param {{type: "error" | "warning"; message: string}} error $COMMENT#JSDOC#PARAMS#ERROR
12
+ * Logs an error to the console depending on its type. (`"error"` or `"warning"`.)
13
+ * @param {{type: "error" | "warning"; message: string}} error The error object being handle for the logging.
14
14
  * @returns
15
15
  */
16
16
  export const logError = (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comment-variables",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "A CLI tool for configuring, managing and maintaining JavaScript comments as JavaScript variables.",
5
5
  "bin": {
6
6
  "jscomments": "./library/index.js",
@@ -27,7 +27,7 @@
27
27
  "type": "module",
28
28
  "dependencies": {
29
29
  "@eslint/markdown": "^6.5.0",
30
- "comment-variables-resolve-config": "^1.10.1",
30
+ "comment-variables-resolve-config": "^1.11.0",
31
31
  "eslint": "^9.29.0"
32
32
  },
33
33
  "devDependencies": {