@cspell/cspell-types 5.15.0 → 5.16.0

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.
@@ -7,7 +7,7 @@
7
7
  "properties": {
8
8
  "cacheLocation": {
9
9
  "$ref": "#/definitions/FSPathResolvable",
10
- "description": "Path to the cache location. Can be a file or a directory. If none specified `.cspellcache` will be used. Relative paths are relative to the config file in which"
10
+ "description": "Path to the cache location. Can be a file or a directory. If none specified `.cspellcache` will be used. Relative paths are relative to the config file in which it is defined.\n\nA prefix of `${cwd}` is replaced with the current working directory."
11
11
  },
12
12
  "cacheStrategy": {
13
13
  "$ref": "#/definitions/CacheStrategy",
@@ -30,6 +30,108 @@
30
30
  ],
31
31
  "type": "string"
32
32
  },
33
+ "CostMapDefInsDel": {
34
+ "additionalProperties": false,
35
+ "properties": {
36
+ "description": {
37
+ "description": "A description to describe the purpose of the map.",
38
+ "type": "string"
39
+ },
40
+ "insDel": {
41
+ "description": "The cost to insert/delete one of the substrings in the map. Note: insert/delete costs are symmetrical.",
42
+ "type": "number"
43
+ },
44
+ "map": {
45
+ "description": "The set of substrings to map, these are generally single character strings.\n\nMultiple sets can be defined by using a `|` to separate them.\n\nExample: `\"eéê|aåá\"` contains two different sets.\n\nTo add a multi-character substring use `()`.\n\nExample: `\"f(ph)(gh)\"` results in the following set: `f`, `ph`, `gh`.\n\n- To match the beginning of a word, use `^`: `\"(^I)\"\"`.\n- To match the end of a word, use `$`: `\"(e$)(ing$)\"`.",
46
+ "type": "string"
47
+ },
48
+ "penalty": {
49
+ "description": "Add a penalty to the final cost. This is used to discourage certain suggestions.\n\nExample: ```yaml # Match adding/removing `-` to the end of a word. map: \"$(-$)\" replace: 50 penalty: 100 ```\n\nThis makes adding a `-` to the end of a word more expensive.\n\nThink of it as taking the toll way for speed but getting the bill later.",
50
+ "type": "number"
51
+ },
52
+ "replace": {
53
+ "description": "The cost to replace of of the substrings in the map with another substring in the map. Example: Map['a', 'i'] This would be the cost to substitute `a` with `i`: Like `bat` to `bit` or the reverse.",
54
+ "type": "number"
55
+ },
56
+ "swap": {
57
+ "description": "The cost to swap two adjacent substrings found in the map. Example: Map['e', 'i'] This represents the cost to change `ei` to `ie` or the reverse.",
58
+ "type": "number"
59
+ }
60
+ },
61
+ "required": [
62
+ "insDel",
63
+ "map"
64
+ ],
65
+ "type": "object"
66
+ },
67
+ "CostMapDefReplace": {
68
+ "additionalProperties": false,
69
+ "properties": {
70
+ "description": {
71
+ "description": "A description to describe the purpose of the map.",
72
+ "type": "string"
73
+ },
74
+ "insDel": {
75
+ "description": "The cost to insert/delete one of the substrings in the map. Note: insert/delete costs are symmetrical.",
76
+ "type": "number"
77
+ },
78
+ "map": {
79
+ "description": "The set of substrings to map, these are generally single character strings.\n\nMultiple sets can be defined by using a `|` to separate them.\n\nExample: `\"eéê|aåá\"` contains two different sets.\n\nTo add a multi-character substring use `()`.\n\nExample: `\"f(ph)(gh)\"` results in the following set: `f`, `ph`, `gh`.\n\n- To match the beginning of a word, use `^`: `\"(^I)\"\"`.\n- To match the end of a word, use `$`: `\"(e$)(ing$)\"`.",
80
+ "type": "string"
81
+ },
82
+ "penalty": {
83
+ "description": "Add a penalty to the final cost. This is used to discourage certain suggestions.\n\nExample: ```yaml # Match adding/removing `-` to the end of a word. map: \"$(-$)\" replace: 50 penalty: 100 ```\n\nThis makes adding a `-` to the end of a word more expensive.\n\nThink of it as taking the toll way for speed but getting the bill later.",
84
+ "type": "number"
85
+ },
86
+ "replace": {
87
+ "description": "The cost to replace of of the substrings in the map with another substring in the map. Example: Map['a', 'i'] This would be the cost to substitute `a` with `i`: Like `bat` to `bit` or the reverse.",
88
+ "type": "number"
89
+ },
90
+ "swap": {
91
+ "description": "The cost to swap two adjacent substrings found in the map. Example: Map['e', 'i'] This represents the cost to change `ei` to `ie` or the reverse.",
92
+ "type": "number"
93
+ }
94
+ },
95
+ "required": [
96
+ "map",
97
+ "replace"
98
+ ],
99
+ "type": "object"
100
+ },
101
+ "CostMapDefSwap": {
102
+ "additionalProperties": false,
103
+ "properties": {
104
+ "description": {
105
+ "description": "A description to describe the purpose of the map.",
106
+ "type": "string"
107
+ },
108
+ "insDel": {
109
+ "description": "The cost to insert/delete one of the substrings in the map. Note: insert/delete costs are symmetrical.",
110
+ "type": "number"
111
+ },
112
+ "map": {
113
+ "description": "The set of substrings to map, these are generally single character strings.\n\nMultiple sets can be defined by using a `|` to separate them.\n\nExample: `\"eéê|aåá\"` contains two different sets.\n\nTo add a multi-character substring use `()`.\n\nExample: `\"f(ph)(gh)\"` results in the following set: `f`, `ph`, `gh`.\n\n- To match the beginning of a word, use `^`: `\"(^I)\"\"`.\n- To match the end of a word, use `$`: `\"(e$)(ing$)\"`.",
114
+ "type": "string"
115
+ },
116
+ "penalty": {
117
+ "description": "Add a penalty to the final cost. This is used to discourage certain suggestions.\n\nExample: ```yaml # Match adding/removing `-` to the end of a word. map: \"$(-$)\" replace: 50 penalty: 100 ```\n\nThis makes adding a `-` to the end of a word more expensive.\n\nThink of it as taking the toll way for speed but getting the bill later.",
118
+ "type": "number"
119
+ },
120
+ "replace": {
121
+ "description": "The cost to replace of of the substrings in the map with another substring in the map. Example: Map['a', 'i'] This would be the cost to substitute `a` with `i`: Like `bat` to `bit` or the reverse.",
122
+ "type": "number"
123
+ },
124
+ "swap": {
125
+ "description": "The cost to swap two adjacent substrings found in the map. Example: Map['e', 'i'] This represents the cost to change `ei` to `ie` or the reverse.",
126
+ "type": "number"
127
+ }
128
+ },
129
+ "required": [
130
+ "map",
131
+ "swap"
132
+ ],
133
+ "type": "object"
134
+ },
33
135
  "CustomDictionaryPath": {
34
136
  "description": "A File System Path to a dictionary file.",
35
137
  "pattern": "^.*\\.txt$",
@@ -85,6 +187,10 @@
85
187
  "$ref": "#/definitions/ReplaceMap",
86
188
  "description": "Replacement pairs."
87
189
  },
190
+ "suggestionEditCosts": {
191
+ "$ref": "#/definitions/SuggestionCostsDefs",
192
+ "description": "Used in making suggestions. The lower the value, the more likely the suggestion will be near the top of the suggestion list.\n\nAdded with `v5.16.0`."
193
+ },
88
194
  "type": {
89
195
  "$ref": "#/definitions/DictionaryFileTypes",
90
196
  "default": "S",
@@ -143,6 +249,10 @@
143
249
  ],
144
250
  "description": "Defines the scope for when words will be added to the dictionary. Scope values: `user`, `workspace`, `folder`."
145
251
  },
252
+ "suggestionEditCosts": {
253
+ "$ref": "#/definitions/SuggestionCostsDefs",
254
+ "description": "Used in making suggestions. The lower the value, the more likely the suggestion will be near the top of the suggestion list.\n\nAdded with `v5.16.0`."
255
+ },
146
256
  "type": {
147
257
  "$ref": "#/definitions/DictionaryFileTypes",
148
258
  "default": "S",
@@ -183,6 +293,10 @@
183
293
  "$ref": "#/definitions/ReplaceMap",
184
294
  "description": "Replacement pairs."
185
295
  },
296
+ "suggestionEditCosts": {
297
+ "$ref": "#/definitions/SuggestionCostsDefs",
298
+ "description": "Used in making suggestions. The lower the value, the more likely the suggestion will be near the top of the suggestion list.\n\nAdded with `v5.16.0`."
299
+ },
186
300
  "type": {
187
301
  "$ref": "#/definitions/DictionaryFileTypes",
188
302
  "default": "S",
@@ -242,6 +356,20 @@
242
356
  "$ref": "#/definitions/FsPath",
243
357
  "description": "A File System Path.\n\nSpecial Properties:\n- `${cwd}` prefix - will be replaced with the current working directory.\n- Relative paths are relative to the configuration file."
244
358
  },
359
+ "FeatureEnableOnly": {
360
+ "type": "boolean"
361
+ },
362
+ "Features": {
363
+ "additionalProperties": false,
364
+ "description": "Features are behaviors or settings that can be explicitly configured.",
365
+ "properties": {
366
+ "weighted-suggestions": {
367
+ "$ref": "#/definitions/FeatureEnableOnly",
368
+ "description": "Enable/disable using weighted suggestions."
369
+ }
370
+ },
371
+ "type": "object"
372
+ },
245
373
  "FsPath": {
246
374
  "description": "A File System Path. Relative paths are relative to the configuration file.",
247
375
  "type": "string"
@@ -742,6 +870,26 @@
742
870
  "description": "Simple Glob string, the root will be globRoot.",
743
871
  "type": "string"
744
872
  },
873
+ "SuggestionCostMapDef": {
874
+ "anyOf": [
875
+ {
876
+ "$ref": "#/definitions/CostMapDefReplace"
877
+ },
878
+ {
879
+ "$ref": "#/definitions/CostMapDefInsDel"
880
+ },
881
+ {
882
+ "$ref": "#/definitions/CostMapDefSwap"
883
+ }
884
+ ],
885
+ "description": "A WeightedMapDef enables setting weights for edits between related characters and substrings.\n\nMultiple groups can be defined using a `|`. A multi-character substring is defined using `()`.\n\nFor example, in some languages, some letters sound alike.\n\n```yaml map: 'sc(sh)(sch)(ss)|t(tt)' # two groups. replace: 50 # Make it 1/2 the cost of a normal edit to replace a `t` with `tt`. ```\n\nThe following could be used to make inserting, removing, or replacing vowels cheaper. ```yaml map: 'aeiouy' insDel: 50 # Make it is cheaper to insert or delete a vowel. replace: 45 # It is even cheaper to replace one with another. ```\n\nNote: the default edit distance is 100."
886
+ },
887
+ "SuggestionCostsDefs": {
888
+ "items": {
889
+ "$ref": "#/definitions/SuggestionCostMapDef"
890
+ },
891
+ "type": "array"
892
+ },
745
893
  "Version": {
746
894
  "anyOf": [
747
895
  {
@@ -828,6 +976,10 @@
828
976
  },
829
977
  "type": "array"
830
978
  },
979
+ "features": {
980
+ "$ref": "#/definitions/Features",
981
+ "description": "Configure CSpell features.\n\n- Added with `v5.16.0`."
982
+ },
831
983
  "files": {
832
984
  "description": "Glob patterns of files to be checked. Glob patterns are relative to the `globRoot` of the configuration file that defines them.",
833
985
  "items": {
@@ -45,7 +45,7 @@ export interface RunResult {
45
45
  /** Number of processing errors. */
46
46
  errors: number;
47
47
  /** Number files that used results from the cache. */
48
- cachedFiles: number;
48
+ cachedFiles?: number;
49
49
  }
50
50
  export declare type ResultEmitter = (result: RunResult) => void | Promise<void>;
51
51
  export interface CSpellReporter {
@@ -1,3 +1,5 @@
1
+ import { Features } from './features';
2
+ import type { SuggestionCostsDefs } from './suggestionCostsDef';
1
3
  export declare type ReplaceEntry = [string, string];
2
4
  export declare type ReplaceMap = ReplaceEntry[];
3
5
  /**
@@ -86,6 +88,12 @@ export interface FileSettings extends ExtendableSettings, CommandLineSettings {
86
88
  * Tells the spell checker to searching for `.gitignore` files when it reaches a matching root.
87
89
  */
88
90
  gitignoreRoot?: FsPath | FsPath[];
91
+ /**
92
+ * Configure CSpell features.
93
+ *
94
+ * - Added with `v5.16.0`.
95
+ */
96
+ features?: Features;
89
97
  }
90
98
  export interface ExtendableSettings extends Settings {
91
99
  /** Overrides to apply based upon the file path. */
@@ -199,7 +207,10 @@ export interface CacheSettings {
199
207
  /**
200
208
  * Path to the cache location. Can be a file or a directory.
201
209
  * If none specified `.cspellcache` will be used.
202
- * Relative paths are relative to the config file in which
210
+ * Relative paths are relative to the config file in which it
211
+ * is defined.
212
+ *
213
+ * A prefix of `${cwd}` is replaced with the current working directory.
203
214
  */
204
215
  cacheLocation?: FSPathResolvable;
205
216
  /**
@@ -374,6 +385,13 @@ export interface DictionaryDefinitionBase {
374
385
  * @default "S"
375
386
  */
376
387
  type?: DictionaryFileTypes;
388
+ /**
389
+ * Used in making suggestions. The lower the value, the more likely the suggestion
390
+ * will be near the top of the suggestion list.
391
+ *
392
+ * Added with `v5.16.0`.
393
+ */
394
+ suggestionEditCosts?: SuggestionCostsDefs;
377
395
  }
378
396
  export interface DictionaryDefinitionPreferred extends DictionaryDefinitionBase {
379
397
  /** Path to the file. */
@@ -12,6 +12,7 @@ exports.ConfigFields = {
12
12
  enabledLanguageIds: 'enabledLanguageIds',
13
13
  enableFiletypes: 'enableFiletypes',
14
14
  enableGlobDot: 'enableGlobDot',
15
+ features: 'features',
15
16
  files: 'files',
16
17
  flagWords: 'flagWords',
17
18
  gitignoreRoot: 'gitignoreRoot',
@@ -0,0 +1,38 @@
1
+ /**
2
+ * These are experimental features and are subject to change or removal.
3
+ */
4
+ export interface FeaturesExperimental {
5
+ /**
6
+ * Enable/disable using weighted suggestions.
7
+ */
8
+ 'weighted-suggestions': FeatureEnableOnly;
9
+ }
10
+ /**
11
+ * These are the current set of active features
12
+ */
13
+ export interface FeaturesActive {
14
+ }
15
+ /**
16
+ * These are feature settings that have been deprecated or moved elsewhere they will have no
17
+ * effect on the code but are here to prevent schema errors. The will get cleaned out on major versions.
18
+ */
19
+ export interface FeaturesDeprecated {
20
+ }
21
+ /**
22
+ * Features are behaviors or settings that can be explicitly configured.
23
+ */
24
+ export interface Features extends Partial<FeaturesActive>, Partial<FeaturesDeprecated>, Partial<FeaturesExperimental> {
25
+ }
26
+ export declare type Feature = FeatureEnableOnly | FeatureWithConfiguration;
27
+ export declare type FeatureEnableOnly = boolean;
28
+ /**
29
+ * Feature Configuration.
30
+ */
31
+ export interface FeatureWithConfiguration {
32
+ enable: boolean;
33
+ }
34
+ export declare type FeatureNamesKnown = keyof Features;
35
+ export declare type FeatureNamesExperimental = keyof FeaturesExperimental;
36
+ export declare type FeatureNamesActive = keyof FeaturesActive;
37
+ export declare type FeatureNamesDeprecated = keyof FeaturesDeprecated;
38
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-empty-interface */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=features.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- export { ConfigFields, type CSpellUserSettingsFields } from './configFields';
1
+ export { ConfigFields } from './configFields';
2
+ export type { CSpellUserSettingsFields } from './configFields';
2
3
  export * from './CSpellReporter';
3
4
  export * from './CSpellSettingsDef';
5
+ export type { SuggestionCostMapDef, SuggestionCostsDefs } from './suggestionCostsDef';
4
6
  export type { TextDocumentOffset, TextOffset } from './TextOffset';
7
+ export type { Features, Feature } from './features';
5
8
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.ConfigFields = void 0;
14
+ // Using old-style of `type` exports because the new style breaks some integrations.
14
15
  var configFields_1 = require("./configFields");
15
16
  Object.defineProperty(exports, "ConfigFields", { enumerable: true, get: function () { return configFields_1.ConfigFields; } });
16
17
  __exportStar(require("./CSpellReporter"), exports);
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A WeightedMapDef enables setting weights for edits between related characters and substrings.
3
+ *
4
+ * Multiple groups can be defined using a `|`.
5
+ * A multi-character substring is defined using `()`.
6
+ *
7
+ * For example, in some languages, some letters sound alike.
8
+ *
9
+ * ```yaml
10
+ * map: 'sc(sh)(sch)(ss)|t(tt)' # two groups.
11
+ * replace: 50 # Make it 1/2 the cost of a normal edit to replace a `t` with `tt`.
12
+ * ```
13
+ *
14
+ * The following could be used to make inserting, removing, or replacing vowels cheaper.
15
+ * ```yaml
16
+ * map: 'aeiouy'
17
+ * insDel: 50 # Make it is cheaper to insert or delete a vowel.
18
+ * replace: 45 # It is even cheaper to replace one with another.
19
+ * ```
20
+ *
21
+ * Note: the default edit distance is 100.
22
+ */
23
+ export declare type SuggestionCostMapDef = CostMapDefReplace | CostMapDefInsDel | CostMapDefSwap;
24
+ export declare type SuggestionCostsDefs = SuggestionCostMapDef[];
25
+ interface CostMapDefBase {
26
+ /**
27
+ * The set of substrings to map, these are generally single character strings.
28
+ *
29
+ * Multiple sets can be defined by using a `|` to separate them.
30
+ *
31
+ * Example: `"eéê|aåá"` contains two different sets.
32
+ *
33
+ * To add a multi-character substring use `()`.
34
+ *
35
+ * Example: `"f(ph)(gh)"` results in the following set: `f`, `ph`, `gh`.
36
+ *
37
+ * - To match the beginning of a word, use `^`: `"(^I)""`.
38
+ * - To match the end of a word, use `$`: `"(e$)(ing$)"`.
39
+ *
40
+ */
41
+ map: string;
42
+ /** The cost to insert/delete one of the substrings in the map. Note: insert/delete costs are symmetrical. */
43
+ insDel?: number;
44
+ /**
45
+ * The cost to replace of of the substrings in the map with another substring in the map.
46
+ * Example: Map['a', 'i']
47
+ * This would be the cost to substitute `a` with `i`: Like `bat` to `bit` or the reverse.
48
+ */
49
+ replace?: number;
50
+ /**
51
+ * The cost to swap two adjacent substrings found in the map.
52
+ * Example: Map['e', 'i']
53
+ * This represents the cost to change `ei` to `ie` or the reverse.
54
+ */
55
+ swap?: number;
56
+ /**
57
+ * A description to describe the purpose of the map.
58
+ */
59
+ description?: string;
60
+ /**
61
+ * Add a penalty to the final cost.
62
+ * This is used to discourage certain suggestions.
63
+ *
64
+ * Example:
65
+ * ```yaml
66
+ * # Match adding/removing `-` to the end of a word.
67
+ * map: "$(-$)"
68
+ * replace: 50
69
+ * penalty: 100
70
+ * ```
71
+ *
72
+ * This makes adding a `-` to the end of a word more expensive.
73
+ *
74
+ * Think of it as taking the toll way for speed but getting the bill later.
75
+ */
76
+ penalty?: number;
77
+ }
78
+ export interface CostMapDefReplace extends CostMapDefBase {
79
+ replace: number;
80
+ }
81
+ export interface CostMapDefInsDel extends CostMapDefBase {
82
+ insDel: number;
83
+ }
84
+ export interface CostMapDefSwap extends CostMapDefBase {
85
+ swap: number;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=suggestionCostsDef.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=suggestionCostsDef.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "5.15.0",
6
+ "version": "5.16.0",
7
7
  "description": "Types for cspell and cspell-lib",
8
8
  "main": "dist/index.js",
9
9
  "typings": "dist/index.d.ts",
@@ -19,6 +19,7 @@
19
19
  "build-dev": "tsc -p tsconfig.dev.json",
20
20
  "build-schema": "ts-json-schema-generator --no-top-ref --path src/CSpellSettingsDef.ts --type CSpellSettings --validation-keywords markdownDescription --validation-keywords scope --validation-keywords deprecated --validation-keywords deprecationMessage -o ./cspell.schema.json && cp ./cspell.schema.json ../..",
21
21
  "build-docs": "typedoc --out ../../docs/types/cspell-types src/index.ts",
22
+ "test-build-docs": "typedoc --out ./temp/docs src/index.ts",
22
23
  "clean-build": "npm run clean && npm run build",
23
24
  "compile": "tsc -p .",
24
25
  "test-schema": "ajv -s ./cspell.schema.json -d \"cspell.test.{json,yaml}\" -c ./ajv.config.js",
@@ -49,12 +50,12 @@
49
50
  },
50
51
  "devDependencies": {
51
52
  "ajv-cli": "^5.0.0",
52
- "jest": "^27.4.6",
53
+ "jest": "^27.4.7",
53
54
  "rimraf": "^3.0.2",
54
55
  "ts-json-schema-generator": "^0.97.0",
55
- "typedoc": "^0.22.10",
56
- "typedoc-plugin-markdown": "^3.11.9",
56
+ "typedoc": "0.22.11",
57
+ "typedoc-plugin-markdown": "^3.11.12",
57
58
  "typescript": "^4.5.4"
58
59
  },
59
- "gitHead": "04d61378054cbecd28df100ca704c7322abab8ba"
60
+ "gitHead": "c5d994f58bdb48c4d16f1708607b28c8a7b52a65"
60
61
  }