cspell-lib 6.7.0 → 6.8.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.
@@ -1,7 +1,23 @@
1
1
  import type { CSpellUserSettings } from '@cspell/cspell-types';
2
2
  import { Sequence } from 'gensequence';
3
3
  export declare type CSpellUserSettingsKeys = keyof CSpellUserSettings;
4
+ export interface DirectiveIssue {
5
+ /**
6
+ * the start and end offsets within the document of the issue.
7
+ */
8
+ range: [start: number, end: number];
9
+ /**
10
+ * The text causing the issue.
11
+ */
12
+ text: string;
13
+ message: string;
14
+ suggestions: string[];
15
+ }
4
16
  export declare function getInDocumentSettings(text: string): CSpellUserSettings;
17
+ export declare function validateInDocumentSettings(docText: string, _settings: CSpellUserSettings): Iterable<DirectiveIssue>;
18
+ export declare const regExSpellingGuardBlock: RegExp;
19
+ export declare const regExSpellingGuardNext: RegExp;
20
+ export declare const regExSpellingGuardLine: RegExp;
5
21
  declare function parseCompoundWords(match: string): CSpellUserSettings;
6
22
  declare function parseWords(match: string): CSpellUserSettings;
7
23
  declare function parseIgnoreWords(match: string): CSpellUserSettings;
@@ -23,14 +23,57 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.internal = exports.getIgnoreRegExpFromDocument = exports.getIgnoreWordsFromDocument = exports.getInDocumentSettings = void 0;
26
+ exports.internal = exports.getIgnoreRegExpFromDocument = exports.getIgnoreWordsFromDocument = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.validateInDocumentSettings = exports.getInDocumentSettings = void 0;
27
+ const cspell_pipe_1 = require("@cspell/cspell-pipe");
27
28
  const gensequence_1 = require("gensequence");
29
+ const SpellingDictionary_1 = require("../SpellingDictionary");
28
30
  const Text = __importStar(require("../util/text"));
29
31
  const util_1 = require("../util/util");
30
32
  const CSpellSettingsServer_1 = require("./CSpellSettingsServer");
31
33
  // cspell:ignore gimuy
32
34
  const regExMatchRegEx = /\/.*\/[gimuy]*/;
33
- const regExInFileSettings = [/(?:spell-?checker|c?spell)::?(.*)/gi, /(LocalWords:?.*)/g];
35
+ const regExCSpellInDocDirective = /(?:spell-?checker|c?spell)::?(.*)/gi;
36
+ const regExCSpellDirectiveKey = /(?<=(?:spell-?checker|c?spell)::?)(?!:)(.*)/i;
37
+ const regExInFileSettings = [regExCSpellInDocDirective, /(LocalWords:?.*)/g];
38
+ const officialDirectives = [
39
+ 'enable',
40
+ 'disable',
41
+ 'disable-line',
42
+ 'disable-next',
43
+ 'disable-next-line',
44
+ 'word',
45
+ 'words',
46
+ 'ignore',
47
+ 'ignoreWord',
48
+ 'ignoreWords',
49
+ 'includeRegExp',
50
+ 'ignoreRegExp',
51
+ 'locale',
52
+ 'language',
53
+ 'dictionaries',
54
+ 'enableCompoundWords',
55
+ 'enableAllowCompoundWords',
56
+ 'disableCompoundWords',
57
+ 'disableAllowCompoundWords',
58
+ 'enableCaseSensitive',
59
+ 'disableCaseSensitive',
60
+ ];
61
+ const preferredDirectives = [
62
+ 'enable',
63
+ 'disable',
64
+ 'disable-line',
65
+ 'disable-next-line',
66
+ 'words',
67
+ 'ignore',
68
+ 'locale',
69
+ 'dictionaries',
70
+ 'enableCaseSensitive',
71
+ 'disableCaseSensitive',
72
+ ];
73
+ const allDirectives = new Set(preferredDirectives.concat(officialDirectives));
74
+ const dictInDocSettings = (0, SpellingDictionary_1.createSpellingDictionary)(allDirectives, 'Directives', 'Directive List', {
75
+ supportNonStrictSearches: false,
76
+ });
34
77
  const EmptyWords = [];
35
78
  Object.freeze(EmptyWords);
36
79
  function getInDocumentSettings(text) {
@@ -43,21 +86,62 @@ function getInDocumentSettings(text) {
43
86
  return settings;
44
87
  }
45
88
  exports.getInDocumentSettings = getInDocumentSettings;
89
+ function validateInDocumentSettings(docText, _settings) {
90
+ return (0, cspell_pipe_1.pipeSync)(getPossibleInDocSettings(docText), (0, cspell_pipe_1.opMap)(parseSettingMatchValidation), (0, cspell_pipe_1.opFilter)(util_1.isDefined));
91
+ }
92
+ exports.validateInDocumentSettings = validateInDocumentSettings;
93
+ const settingParsers = [
94
+ [/^(?:enable|disable)(?:allow)?CompoundWords\b/i, parseCompoundWords],
95
+ [/^(?:enable|disable)CaseSensitive\b/i, parseCaseSensitive],
96
+ [/^enable\b(?!-)/i, parseEnable],
97
+ [/^disable(-line|-next(-line)?)?\b(?!-)/i, parseDisable],
98
+ [/^words?\s/i, parseWords],
99
+ [/^ignore(?:words?)?\s/i, parseIgnoreWords],
100
+ [/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
101
+ [/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
102
+ [/^locale?\s/i, parseLocale],
103
+ [/^language\s/i, parseLocale],
104
+ [/^dictionaries\s/i, parseDictionaries],
105
+ [/^LocalWords:/, (w) => parseWords(w.replace(/LocalWords:?/gi, ' '))],
106
+ ];
107
+ exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi;
108
+ exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
109
+ exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
110
+ const issueMessages = {
111
+ unknownDirective: 'Unknown CSpell directive',
112
+ };
113
+ function parseSettingMatchValidation(matchArray) {
114
+ const [fullMatch = ''] = matchArray;
115
+ const directiveMatch = fullMatch.match(regExCSpellDirectiveKey);
116
+ if (!directiveMatch)
117
+ return undefined;
118
+ const match = directiveMatch[1];
119
+ const possibleSetting = match.trim();
120
+ if (!possibleSetting)
121
+ return undefined;
122
+ const start = (matchArray.index || 0) + (directiveMatch.index || 0) + (match.length - match.trimStart().length);
123
+ const text = possibleSetting.replace(/^([-\w]+)?.*/, '$1');
124
+ const end = start + text.length;
125
+ if (!text)
126
+ return undefined;
127
+ const matchingParsers = settingParsers.filter(([regex]) => regex.test(possibleSetting));
128
+ if (matchingParsers.length > 0)
129
+ return undefined;
130
+ // No matches were found, let make some suggestions.
131
+ const dictSugs = dictInDocSettings.suggest(text, { ignoreCase: false }).map((sug) => sug.word);
132
+ const sugs = new Set((0, cspell_pipe_1.pipeSync)(dictSugs, (0, cspell_pipe_1.opAppend)(allDirectives)));
133
+ const suggestions = [...sugs].slice(0, 8);
134
+ const issue = {
135
+ range: [start, end],
136
+ text,
137
+ message: issueMessages.unknownDirective,
138
+ suggestions,
139
+ };
140
+ return issue;
141
+ }
46
142
  function parseSettingMatch(matchArray) {
47
143
  const [, match = ''] = matchArray;
48
144
  const possibleSetting = match.trim();
49
- const settingParsers = [
50
- [/^(?:enable|disable)(?:allow)?CompoundWords/i, parseCompoundWords],
51
- [/^(?:enable|disable)CaseSensitive/i, parseCaseSensitive],
52
- [/^words?\s/i, parseWords],
53
- [/^ignore(?:words?)?\s/i, parseIgnoreWords],
54
- [/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
55
- [/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
56
- [/^locale?\s/i, parseLocale],
57
- [/^language\s/i, parseLocale],
58
- [/^dictionaries\s/i, parseDictionaries],
59
- [/^LocalWords:/, (w) => parseWords(w.replace(/LocalWords:?/gi, ' '))],
60
- ];
61
145
  return settingParsers
62
146
  .filter(([regex]) => regex.test(possibleSetting))
63
147
  .map(([, fn]) => fn)
@@ -113,6 +197,14 @@ function getWordsFromDocument(text) {
113
197
  const { words = EmptyWords } = getInDocumentSettings(text);
114
198
  return words;
115
199
  }
200
+ function parseEnable(_match) {
201
+ // Do nothing. Enable / Disable is handled in a different way.
202
+ return {};
203
+ }
204
+ function parseDisable(_match) {
205
+ // Do nothing. Enable / Disable is handled in a different way.
206
+ return {};
207
+ }
116
208
  function getIgnoreWordsFromDocument(text) {
117
209
  const { ignoreWords = EmptyWords } = getInDocumentSettings(text);
118
210
  return ignoreWords;
@@ -12,7 +12,7 @@ exports.regExCStyleHexValue = /\b0x[0-9a-f]+\b/gi;
12
12
  exports.regExCSSHexValue = /#[0-9a-f]{3,8}\b/gi;
13
13
  exports.regExUUID = /\b[0-9a-fx]{8}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{12}\b/gi; // x - represents placeholder values
14
14
  exports.regExUnicodeRef = /\bU\+[0-9a-f]{4,5}(?:-[0-9a-f]{4,5})?/gi;
15
- exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi;
15
+ exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b(?!-)[\s\S]*?((?:\1\s*enable\b)|$)/gi;
16
16
  exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
17
17
  exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
18
18
  exports.regExIgnoreSpellingDirectives = /\bc?spell(?:-?checker)?::?\s*ignoreRegExp.*/gim;
@@ -48,10 +48,23 @@ export declare type HasOptions = SearchOptions;
48
48
  export interface SpellingDictionaryOptions {
49
49
  repMap?: ReplaceMap;
50
50
  useCompounds?: boolean;
51
+ /**
52
+ * The dictionary is case aware.
53
+ */
51
54
  caseSensitive?: boolean;
52
55
  noSuggest?: boolean;
53
56
  weightMap?: WeightMap | undefined;
54
57
  dictionaryInformation?: DictionaryInformation;
58
+ /**
59
+ * Strip Case and Accents to allow for case insensitive searches and
60
+ * words without accents.
61
+ *
62
+ * Note: this setting only applies to word lists. It has no-impact on trie
63
+ * dictionaries.
64
+ *
65
+ * @default true
66
+ */
67
+ supportNonStrictSearches?: boolean;
55
68
  }
56
69
  export interface SpellingDictionary {
57
70
  readonly name: string;
@@ -34,7 +34,8 @@ exports.createSpellingDictionary = createSpellingDictionary;
34
34
  function _createSpellingDictionary(params) {
35
35
  const [wordList, name, source, options] = params;
36
36
  // console.log(`createSpellingDictionary ${name} ${source}`);
37
- const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList);
37
+ const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
38
+ const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions);
38
39
  const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
39
40
  const opts = { ...(options || defaultOptions) };
40
41
  if (opts.weightMap === undefined && opts.dictionaryInformation) {
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export type { CreateTextDocumentParams, TextDocument, TextDocumentLine } from '.
12
12
  export * from './Settings';
13
13
  export { defaultFileName as defaultSettingsFilename } from './Settings';
14
14
  export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings';
15
- export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, Document, fileToDocument, isBinaryFile, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile';
15
+ export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, Document, fileToDocument, fileToTextDocument, isBinaryFile, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile';
16
16
  export { CompoundWordsMethod, createSpellingDictionary, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryLoadError, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
17
17
  export { SuggestionError, suggestionsForWord, suggestionsForWords } from './suggestions';
18
18
  export type { SuggestedWord, SuggestionOptions, SuggestionsForWordResult } from './suggestions';
@@ -21,7 +21,7 @@ export { traceWords, traceWordsAsync } from './trace';
21
21
  export type { TraceOptions, TraceResult } from './trace';
22
22
  export { getLogger, Logger, setLogger } from './util/logger';
23
23
  export { resolveFile } from './util/resolveFile';
24
- export { checkText, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator';
24
+ export { checkText, checkTextDocument, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator';
25
25
  export { Text, Link };
26
26
  export { ExclusionHelper };
27
27
  export declare function clearCachedFiles(): Promise<void>;
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getDictionary = exports.clearCachedFiles = exports.ExclusionHelper = exports.Link = exports.Text = exports.validateText = exports.IncludeExcludeFlag = exports.checkText = exports.resolveFile = exports.setLogger = exports.getLogger = exports.traceWordsAsync = exports.traceWords = exports.DocumentValidator = exports.suggestionsForWords = exports.suggestionsForWord = exports.SuggestionError = exports.SpellingDictionaryLoadError = exports.SpellingDictionaryCollection = exports.refreshDictionaryCache = exports.isSpellingDictionaryLoadError = exports.createSpellingDictionary = exports.CompoundWordsMethod = exports.spellCheckFile = exports.spellCheckDocument = exports.isBinaryFile = exports.fileToDocument = exports.determineFinalDocumentSettings = exports.constructSettingsForText = exports.combineTextAndLanguageSettings = exports.defaultSettingsFilename = exports.updateTextDocument = exports.createTextDocument = exports.getLanguagesForExt = exports.writeToFileIterableP = exports.writeToFileIterable = exports.writeToFile = exports.readFileSync = exports.readFile = exports.asyncIterableToArray = void 0;
29
+ exports.getDictionary = exports.clearCachedFiles = exports.ExclusionHelper = exports.Link = exports.Text = exports.validateText = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = exports.resolveFile = exports.setLogger = exports.getLogger = exports.traceWordsAsync = exports.traceWords = exports.DocumentValidator = exports.suggestionsForWords = exports.suggestionsForWord = exports.SuggestionError = exports.SpellingDictionaryLoadError = exports.SpellingDictionaryCollection = exports.refreshDictionaryCache = exports.isSpellingDictionaryLoadError = exports.createSpellingDictionary = exports.CompoundWordsMethod = exports.spellCheckFile = exports.spellCheckDocument = exports.isBinaryFile = exports.fileToTextDocument = exports.fileToDocument = exports.determineFinalDocumentSettings = exports.constructSettingsForText = exports.combineTextAndLanguageSettings = exports.defaultSettingsFilename = exports.updateTextDocument = exports.createTextDocument = exports.getLanguagesForExt = exports.writeToFileIterableP = exports.writeToFileIterable = exports.writeToFile = exports.readFileSync = exports.readFile = exports.asyncIterableToArray = void 0;
30
30
  const ExclusionHelper = __importStar(require("./exclusionHelper"));
31
31
  exports.ExclusionHelper = ExclusionHelper;
32
32
  const Settings_1 = require("./Settings");
@@ -58,6 +58,7 @@ Object.defineProperty(exports, "constructSettingsForText", { enumerable: true, g
58
58
  var spellCheckFile_1 = require("./spellCheckFile");
59
59
  Object.defineProperty(exports, "determineFinalDocumentSettings", { enumerable: true, get: function () { return spellCheckFile_1.determineFinalDocumentSettings; } });
60
60
  Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return spellCheckFile_1.fileToDocument; } });
61
+ Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return spellCheckFile_1.fileToTextDocument; } });
61
62
  Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return spellCheckFile_1.isBinaryFile; } });
62
63
  Object.defineProperty(exports, "spellCheckDocument", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckDocument; } });
63
64
  Object.defineProperty(exports, "spellCheckFile", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckFile; } });
@@ -84,6 +85,7 @@ var resolveFile_1 = require("./util/resolveFile");
84
85
  Object.defineProperty(exports, "resolveFile", { enumerable: true, get: function () { return resolveFile_1.resolveFile; } });
85
86
  var validator_1 = require("./validator");
86
87
  Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return validator_1.checkText; } });
88
+ Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return validator_1.checkTextDocument; } });
87
89
  Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return validator_1.IncludeExcludeFlag; } });
88
90
  Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_1.validateText; } });
89
91
  async function clearCachedFiles() {
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { CSpellSettingsWithSourceTrace, CSpellUserSettings } from '@cspell/cspell-types';
3
3
  import { URI } from 'vscode-uri';
4
+ import { TextDocument } from './Models/TextDocument';
4
5
  import { ValidateTextOptions, ValidationIssue } from './validator';
5
6
  export interface SpellCheckFileOptions extends ValidateTextOptions {
6
7
  /**
@@ -78,4 +79,6 @@ export declare function isBinaryFile(filenameUri: URI, languageId?: string | str
78
79
  export declare function fileToDocument(file: string): Document;
79
80
  export declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText;
80
81
  export declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText;
82
+ export declare function fileToTextDocument(file: string): Promise<TextDocument>;
83
+ export declare function resolveDocumentToTextDocument(doc: Document): Promise<TextDocument>;
81
84
  //# sourceMappingURL=spellCheckFile.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileToDocument = exports.isBinaryFile = exports.isBinaryDoc = exports.determineFinalDocumentSettings = exports.spellCheckDocument = exports.spellCheckFile = void 0;
3
+ exports.resolveDocumentToTextDocument = exports.fileToTextDocument = exports.fileToDocument = exports.isBinaryFile = exports.isBinaryDoc = exports.determineFinalDocumentSettings = exports.spellCheckDocument = exports.spellCheckFile = void 0;
4
4
  const fs_extra_1 = require("fs-extra");
5
5
  const vscode_uri_1 = require("vscode-uri");
6
6
  const LanguageIds_1 = require("./LanguageIds");
@@ -59,8 +59,7 @@ async function spellCheckDocument(document, options, settings) {
59
59
  }
60
60
  exports.spellCheckDocument = spellCheckDocument;
61
61
  async function spellCheckFullDocument(document, options, settings) {
62
- const { uri, text: content, languageId, locale } = document;
63
- const doc = (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale });
62
+ const doc = documentToTextDocument(document);
64
63
  const docValOptions = options;
65
64
  const docValidator = new textValidation_1.DocumentValidator(doc, docValOptions, settings);
66
65
  await docValidator.prepare();
@@ -159,4 +158,16 @@ function fileToDocument(file, text, languageId, locale) {
159
158
  });
160
159
  }
161
160
  exports.fileToDocument = fileToDocument;
161
+ async function fileToTextDocument(file) {
162
+ return documentToTextDocument(await resolveDocument(fileToDocument(file)));
163
+ }
164
+ exports.fileToTextDocument = fileToTextDocument;
165
+ function documentToTextDocument(document) {
166
+ const { uri, text: content, languageId, locale } = document;
167
+ return (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale });
168
+ }
169
+ async function resolveDocumentToTextDocument(doc) {
170
+ return documentToTextDocument(await resolveDocument(doc));
171
+ }
172
+ exports.resolveDocumentToTextDocument = resolveDocumentToTextDocument;
162
173
  //# sourceMappingURL=spellCheckFile.js.map
@@ -1,4 +1,4 @@
1
- import { MappedText, TextOffset as TextOffsetRW } from '@cspell/cspell-types';
1
+ import { MappedText, TextOffset as TextOffsetRW, Issue } from '@cspell/cspell-types';
2
2
  export declare type TextOffsetRO = Readonly<TextOffsetRW>;
3
3
  export interface ValidationOptions extends IncludeExcludeOptions {
4
4
  maxNumberOfProblems?: number;
@@ -22,7 +22,7 @@ export interface WordRangeAcc {
22
22
  isIncluded: boolean;
23
23
  rangePos: number;
24
24
  }
25
- export interface ValidationResult extends TextOffsetRW {
25
+ export interface ValidationResult extends TextOffsetRW, Pick<Issue, 'message' | 'issueType'> {
26
26
  line: TextOffsetRW;
27
27
  isFlagged?: boolean | undefined;
28
28
  isFound?: boolean | undefined;
@@ -0,0 +1,47 @@
1
+ import { CSpellUserSettings } from '@cspell/cspell-types';
2
+ import { TextDocument } from '../Models/TextDocument';
3
+ import { Document } from '../spellCheckFile';
4
+ import { DocumentValidator, DocumentValidatorOptions } from './docValidator';
5
+ /**
6
+ * Annotate text with issues and include / exclude zones.
7
+ * @param text - the text to annotate.
8
+ * @param settings - the settings to use.
9
+ * @returns the Check Text result
10
+ * @deprecated
11
+ */
12
+ export declare function checkText(text: string, settings: CSpellUserSettings): Promise<CheckTextInfo>;
13
+ /**
14
+ * Annotate text with issues and include / exclude zones.
15
+ * @param text - the text to annotate.
16
+ * @param settings - the settings to use.
17
+ * @returns the Check Text result
18
+ * @deprecated
19
+ */
20
+ export declare function checkTextOld(text: string, settings: CSpellUserSettings): Promise<CheckTextInfo>;
21
+ export interface CheckTextInfo {
22
+ text: string;
23
+ items: TextInfoItem[];
24
+ }
25
+ export interface TextInfoItem {
26
+ text: string;
27
+ startPos: number;
28
+ endPos: number;
29
+ flagIE: IncludeExcludeFlag;
30
+ isError?: boolean;
31
+ }
32
+ export declare enum IncludeExcludeFlag {
33
+ INCLUDE = "I",
34
+ EXCLUDE = "E"
35
+ }
36
+ export interface CheckTextOptions extends DocumentValidatorOptions {
37
+ }
38
+ /**
39
+ * Calculate document issues and include / exclude zones.
40
+ * @param doc - document to check
41
+ * @param options - check options
42
+ * @param settings - optional settings
43
+ * @returns
44
+ */
45
+ export declare function checkTextDocument(doc: TextDocument | Document, options: CheckTextOptions, settings?: CSpellUserSettings): Promise<CheckTextInfo>;
46
+ export declare function genCheckText(docValidator: DocumentValidator): Promise<CheckTextInfo>;
47
+ //# sourceMappingURL=checkText.d.ts.map
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.genCheckText = exports.checkTextDocument = exports.IncludeExcludeFlag = exports.checkTextOld = exports.checkText = void 0;
30
+ const assert_1 = __importDefault(require("assert"));
31
+ const TextDocument_1 = require("../Models/TextDocument");
32
+ const Settings = __importStar(require("../Settings"));
33
+ const spellCheckFile_1 = require("../spellCheckFile");
34
+ const util_1 = require("../util/util");
35
+ const docValidator_1 = require("./docValidator");
36
+ const textValidator_1 = require("./textValidator");
37
+ const validator_1 = require("./validator");
38
+ /**
39
+ * Annotate text with issues and include / exclude zones.
40
+ * @param text - the text to annotate.
41
+ * @param settings - the settings to use.
42
+ * @returns the Check Text result
43
+ * @deprecated
44
+ */
45
+ async function checkText(text, settings) {
46
+ const doc = (0, util_1.clean)({
47
+ uri: '',
48
+ text,
49
+ languageId: settings.languageId || 'plaintext',
50
+ locale: settings.language,
51
+ });
52
+ return checkTextDocument(doc, { noConfigSearch: true }, { loadDefaultConfiguration: false, ...settings });
53
+ }
54
+ exports.checkText = checkText;
55
+ /**
56
+ * Annotate text with issues and include / exclude zones.
57
+ * @param text - the text to annotate.
58
+ * @param settings - the settings to use.
59
+ * @returns the Check Text result
60
+ * @deprecated
61
+ */
62
+ async function checkTextOld(text, settings) {
63
+ const validationResult = (0, validator_1.validateText)(text, settings);
64
+ const finalSettings = Settings.finalizeSettings(settings);
65
+ const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(text, finalSettings);
66
+ const issues = await validationResult;
67
+ return genResult(text, issues, includeRanges);
68
+ }
69
+ exports.checkTextOld = checkTextOld;
70
+ var IncludeExcludeFlag;
71
+ (function (IncludeExcludeFlag) {
72
+ IncludeExcludeFlag["INCLUDE"] = "I";
73
+ IncludeExcludeFlag["EXCLUDE"] = "E";
74
+ })(IncludeExcludeFlag = exports.IncludeExcludeFlag || (exports.IncludeExcludeFlag = {}));
75
+ /**
76
+ * Calculate document issues and include / exclude zones.
77
+ * @param doc - document to check
78
+ * @param options - check options
79
+ * @param settings - optional settings
80
+ * @returns
81
+ */
82
+ async function checkTextDocument(doc, options, settings = {}) {
83
+ doc = (0, TextDocument_1.isTextDocument)(doc) ? doc : await (0, spellCheckFile_1.resolveDocumentToTextDocument)(doc);
84
+ return genCheckText(new docValidator_1.DocumentValidator(doc, options, settings));
85
+ }
86
+ exports.checkTextDocument = checkTextDocument;
87
+ async function genCheckText(docValidator) {
88
+ await docValidator.prepare();
89
+ const issues = docValidator.checkDocument(true);
90
+ const preparations = docValidator._getPreparations();
91
+ (0, assert_1.default)(preparations);
92
+ return genResult(docValidator.document.text, issues, preparations.includeRanges);
93
+ }
94
+ exports.genCheckText = genCheckText;
95
+ function genResult(text, issues, includeRanges) {
96
+ const result = [];
97
+ let lastPos = 0;
98
+ for (const { startPos, endPos } of includeRanges) {
99
+ result.push({
100
+ text: text.slice(lastPos, startPos),
101
+ startPos: lastPos,
102
+ endPos: startPos,
103
+ flagIE: IncludeExcludeFlag.EXCLUDE,
104
+ });
105
+ result.push({
106
+ text: text.slice(startPos, endPos),
107
+ startPos,
108
+ endPos,
109
+ flagIE: IncludeExcludeFlag.INCLUDE,
110
+ });
111
+ lastPos = endPos;
112
+ }
113
+ result.push({
114
+ text: text.slice(lastPos),
115
+ startPos: lastPos,
116
+ endPos: text.length,
117
+ flagIE: IncludeExcludeFlag.EXCLUDE,
118
+ });
119
+ function* merge() {
120
+ let i = 0;
121
+ for (const r of result) {
122
+ if (i >= issues.length || issues[i].offset >= r.endPos) {
123
+ yield r;
124
+ continue;
125
+ }
126
+ const span = { ...r };
127
+ while (i < issues.length && issues[i].offset < span.endPos) {
128
+ const issue = issues[i];
129
+ const endPos = issue.offset;
130
+ const text = span.text.slice(0, endPos - span.startPos);
131
+ const endPosError = issue.offset + issue.text.length;
132
+ yield { ...span, text, endPos };
133
+ yield {
134
+ ...span,
135
+ isError: true,
136
+ startPos: issue.offset,
137
+ endPos: endPosError,
138
+ text: issue.text,
139
+ };
140
+ span.text = span.text.slice(endPosError - span.startPos);
141
+ span.startPos = endPosError;
142
+ i += 1;
143
+ }
144
+ yield span;
145
+ }
146
+ }
147
+ return {
148
+ text,
149
+ items: [...merge()].filter((i) => i.startPos < i.endPos),
150
+ };
151
+ }
152
+ //# sourceMappingURL=checkText.js.map
@@ -1,4 +1,4 @@
1
- import type { CSpellUserSettings, MappedText, ParsedText } from '@cspell/cspell-types';
1
+ import { CSpellUserSettings, MappedText, ParsedText } from '@cspell/cspell-types';
2
2
  import { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef';
3
3
  import { TextDocument } from '../Models/TextDocument';
4
4
  import { SpellingDictionaryCollection } from '../SpellingDictionary';
@@ -47,9 +47,24 @@ export declare class DocumentValidator {
47
47
  * The amount of time in ms to prepare for validation.
48
48
  */
49
49
  get prepTime(): number;
50
+ get validateDirectives(): boolean;
50
51
  checkText(range: SimpleRange, _text: string, scope: string[]): ValidationIssue[];
51
52
  check(parsedText: ParsedText): ValidationIssue[];
53
+ /**
54
+ * Check a Document for Validation Issues.
55
+ * @param forceCheck - force a check even if the document would normally be excluded.
56
+ * @returns the validation issues.
57
+ */
58
+ checkDocumentAsync(forceCheck?: boolean): Promise<ValidationIssue[]>;
59
+ /**
60
+ * Check a Document for Validation Issues.
61
+ *
62
+ * Note: The validator must be prepared before calling this method.
63
+ * @param forceCheck - force a check even if the document would normally be excluded.
64
+ * @returns the validation issues.
65
+ */
52
66
  checkDocument(forceCheck?: boolean): ValidationIssue[];
67
+ checkDocumentDirectives(forceCheck?: boolean): ValidationIssue[];
53
68
  get document(): TextDocument;
54
69
  updateDocumentText(text: string): void;
55
70
  private defaultParser;
@@ -5,11 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DocumentValidator = void 0;
7
7
  const cspell_pipe_1 = require("@cspell/cspell-pipe");
8
+ const cspell_types_1 = require("@cspell/cspell-types");
8
9
  const assert_1 = __importDefault(require("assert"));
9
10
  const cspell_glob_1 = require("cspell-glob");
10
11
  const TextDocument_1 = require("../Models/TextDocument");
11
12
  const Settings_1 = require("../Settings");
12
13
  const configLoader_1 = require("../Settings/Controller/configLoader");
14
+ const InDocSettings_1 = require("../Settings/InDocSettings");
13
15
  const SpellingDictionary_1 = require("../SpellingDictionary");
14
16
  const errors_1 = require("../util/errors");
15
17
  const Memorizer_1 = require("../util/Memorizer");
@@ -162,6 +164,9 @@ class DocumentValidator {
162
164
  get prepTime() {
163
165
  return this._preparationTime;
164
166
  }
167
+ get validateDirectives() {
168
+ return this.options.validateDirectives ?? this._preparations?.config.validateDirectives ?? false;
169
+ }
165
170
  checkText(range, _text, scope) {
166
171
  const text = this._document.text.slice(range[0], range[1]);
167
172
  return this.check({ text, range, scope: scope.join(' ') });
@@ -197,10 +202,47 @@ class DocumentValidator {
197
202
  });
198
203
  return withSugs;
199
204
  }
205
+ /**
206
+ * Check a Document for Validation Issues.
207
+ * @param forceCheck - force a check even if the document would normally be excluded.
208
+ * @returns the validation issues.
209
+ */
210
+ async checkDocumentAsync(forceCheck) {
211
+ await this.prepare();
212
+ return this.checkDocument(forceCheck);
213
+ }
214
+ /**
215
+ * Check a Document for Validation Issues.
216
+ *
217
+ * Note: The validator must be prepared before calling this method.
218
+ * @param forceCheck - force a check even if the document would normally be excluded.
219
+ * @returns the validation issues.
220
+ */
200
221
  checkDocument(forceCheck = false) {
201
222
  (0, assert_1.default)(this._ready);
202
223
  (0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED);
203
- return forceCheck || this.shouldCheckDocument() ? [...this._checkParsedText(this._parse())] : [];
224
+ const spellingIssues = forceCheck || this.shouldCheckDocument() ? [...this._checkParsedText(this._parse())] : [];
225
+ const directiveIssues = this.checkDocumentDirectives();
226
+ const allIssues = spellingIssues.concat(directiveIssues).sort((a, b) => a.offset - b.offset);
227
+ return allIssues;
228
+ }
229
+ checkDocumentDirectives(forceCheck = false) {
230
+ (0, assert_1.default)(this._ready);
231
+ (0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED);
232
+ const validateDirectives = forceCheck || this.validateDirectives;
233
+ if (!validateDirectives)
234
+ return [];
235
+ const document = this.document;
236
+ const issueType = cspell_types_1.IssueType.directive;
237
+ function toValidationIssue(dirIssue) {
238
+ const { text, range, suggestions, message } = dirIssue;
239
+ const offset = range[0];
240
+ const pos = document.positionAt(offset);
241
+ const line = document.getLine(pos.line);
242
+ const issue = { text, offset, line, suggestions, message, issueType };
243
+ return issue;
244
+ }
245
+ return [...(0, InDocSettings_1.validateInDocumentSettings)(this.document.text, this._preparations.config)].map(toValidationIssue);
204
246
  }
205
247
  get document() {
206
248
  return this._document;
@@ -1,8 +1,10 @@
1
- export { calcTextInclusionRanges } from './textValidator';
2
- export type { CheckOptions, IncludeExcludeOptions, ValidationOptions, ValidationResult } from './ValidationTypes';
3
- export { checkText, IncludeExcludeFlag, validateText } from './validator';
4
- export type { CheckTextInfo, TextInfoItem, ValidateTextOptions, ValidationIssue } from './validator';
1
+ export { checkText, checkTextDocument, IncludeExcludeFlag } from './checkText';
2
+ export type { CheckTextInfo, TextInfoItem } from './checkText';
5
3
  export { DocumentValidator } from './docValidator';
6
4
  export type { DocumentValidatorOptions } from './docValidator';
7
5
  export type { Offset, SimpleRange } from './parsedText';
6
+ export { calcTextInclusionRanges } from './textValidator';
7
+ export type { CheckOptions, IncludeExcludeOptions, ValidationOptions, ValidationResult } from './ValidationTypes';
8
+ export { validateText } from './validator';
9
+ export type { ValidateTextOptions, ValidationIssue } from './validator';
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocumentValidator = exports.validateText = exports.IncludeExcludeFlag = exports.checkText = exports.calcTextInclusionRanges = void 0;
3
+ exports.validateText = exports.calcTextInclusionRanges = exports.DocumentValidator = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = void 0;
4
+ var checkText_1 = require("./checkText");
5
+ Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return checkText_1.checkText; } });
6
+ Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return checkText_1.checkTextDocument; } });
7
+ Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return checkText_1.IncludeExcludeFlag; } });
8
+ var docValidator_1 = require("./docValidator");
9
+ Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return docValidator_1.DocumentValidator; } });
4
10
  var textValidator_1 = require("./textValidator");
5
11
  Object.defineProperty(exports, "calcTextInclusionRanges", { enumerable: true, get: function () { return textValidator_1.calcTextInclusionRanges; } });
6
12
  var validator_1 = require("./validator");
7
- Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return validator_1.checkText; } });
8
- Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return validator_1.IncludeExcludeFlag; } });
9
13
  Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_1.validateText; } });
10
- var docValidator_1 = require("./docValidator");
11
- Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return docValidator_1.DocumentValidator; } });
12
14
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { CSpellUserSettings } from '@cspell/cspell-types';
1
+ import { CSpellUserSettings } from '@cspell/cspell-types';
2
2
  import { CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef';
3
3
  import type { ValidationOptions, ValidationResult } from './ValidationTypes';
4
4
  export declare const diagSource = "cSpell Checker";
@@ -6,10 +6,18 @@ export interface ValidationIssue extends ValidationResult {
6
6
  suggestions?: string[];
7
7
  }
8
8
  export interface ValidateTextOptions {
9
- /** Generate suggestions where there are spelling issues. */
9
+ /**
10
+ * Generate suggestions where there are spelling issues.
11
+ */
10
12
  generateSuggestions?: boolean;
11
- /** The number of suggestions to generate. The higher the number the longer it takes. */
13
+ /**
14
+ * The number of suggestions to generate. The higher the number the longer it takes.
15
+ */
12
16
  numSuggestions?: number;
17
+ /**
18
+ * Verify that the in-document directives are correct.
19
+ */
20
+ validateDirectives?: boolean;
13
21
  }
14
22
  /**
15
23
  * @deprecated
@@ -17,20 +25,4 @@ export interface ValidateTextOptions {
17
25
  */
18
26
  export declare function validateText(text: string, settings: CSpellUserSettings, options?: ValidateTextOptions): Promise<ValidationIssue[]>;
19
27
  export declare function settingsToValidateOptions(settings: CSpellSettingsInternalFinalized): ValidationOptions;
20
- export interface CheckTextInfo {
21
- text: string;
22
- items: TextInfoItem[];
23
- }
24
- export interface TextInfoItem {
25
- text: string;
26
- startPos: number;
27
- endPos: number;
28
- flagIE: IncludeExcludeFlag;
29
- isError?: boolean;
30
- }
31
- export declare enum IncludeExcludeFlag {
32
- INCLUDE = "I",
33
- EXCLUDE = "E"
34
- }
35
- export declare function checkText(text: string, settings: CSpellUserSettings): Promise<CheckTextInfo>;
36
28
  //# sourceMappingURL=validator.d.ts.map
@@ -23,8 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.checkText = exports.IncludeExcludeFlag = exports.settingsToValidateOptions = exports.validateText = exports.diagSource = void 0;
26
+ exports.settingsToValidateOptions = exports.validateText = exports.diagSource = void 0;
27
+ const cspell_types_1 = require("@cspell/cspell-types");
28
+ const TextDocument_1 = require("../Models/TextDocument");
27
29
  const Settings = __importStar(require("../Settings"));
30
+ const InDocSettings_1 = require("../Settings/InDocSettings");
28
31
  const SpellingDictionary_1 = require("../SpellingDictionary");
29
32
  const Memorizer_1 = require("../util/Memorizer");
30
33
  const util_1 = require("../util/util");
@@ -37,7 +40,11 @@ exports.diagSource = 'cSpell Checker';
37
40
  async function validateText(text, settings, options = {}) {
38
41
  const finalSettings = Settings.finalizeSettings(settings);
39
42
  const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(finalSettings);
40
- const issues = [...(0, textValidator_1.validateText)(text, dict, settingsToValidateOptions(finalSettings))];
43
+ const spellingIssues = [...(0, textValidator_1.validateText)(text, dict, settingsToValidateOptions(finalSettings))];
44
+ const validationIssues = options.validateDirectives || finalSettings.validateDirectives
45
+ ? (0, InDocSettings_1.validateInDocumentSettings)(text, settings)
46
+ : [];
47
+ const issues = spellingIssues.concat(mapValidationIssues(text, validationIssues));
41
48
  if (!options.generateSuggestions) {
42
49
  return issues;
43
50
  }
@@ -58,6 +65,22 @@ async function validateText(text, settings, options = {}) {
58
65
  return withSugs;
59
66
  }
60
67
  exports.validateText = validateText;
68
+ function mapValidationIssues(text, valIssues) {
69
+ const issues = [...valIssues];
70
+ if (!issues.length)
71
+ return [];
72
+ const document = (0, TextDocument_1.createTextDocument)({ uri: '', content: text });
73
+ const issueType = cspell_types_1.IssueType.directive;
74
+ function toValidationIssue(dirIssue) {
75
+ const { text, range, suggestions, message } = dirIssue;
76
+ const offset = range[0];
77
+ const pos = document.positionAt(offset);
78
+ const line = document.getLine(pos.line);
79
+ const issue = { text, offset, line, suggestions, message, issueType };
80
+ return issue;
81
+ }
82
+ return issues.map(toValidationIssue);
83
+ }
61
84
  function settingsToValidateOptions(settings) {
62
85
  const opt = {
63
86
  ...settings,
@@ -66,71 +89,4 @@ function settingsToValidateOptions(settings) {
66
89
  return opt;
67
90
  }
68
91
  exports.settingsToValidateOptions = settingsToValidateOptions;
69
- var IncludeExcludeFlag;
70
- (function (IncludeExcludeFlag) {
71
- IncludeExcludeFlag["INCLUDE"] = "I";
72
- IncludeExcludeFlag["EXCLUDE"] = "E";
73
- })(IncludeExcludeFlag = exports.IncludeExcludeFlag || (exports.IncludeExcludeFlag = {}));
74
- async function checkText(text, settings) {
75
- const validationResult = validateText(text, settings);
76
- const finalSettings = Settings.finalizeSettings(settings);
77
- const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(text, finalSettings);
78
- const result = [];
79
- let lastPos = 0;
80
- for (const { startPos, endPos } of includeRanges) {
81
- result.push({
82
- text: text.slice(lastPos, startPos),
83
- startPos: lastPos,
84
- endPos: startPos,
85
- flagIE: IncludeExcludeFlag.EXCLUDE,
86
- });
87
- result.push({
88
- text: text.slice(startPos, endPos),
89
- startPos,
90
- endPos,
91
- flagIE: IncludeExcludeFlag.INCLUDE,
92
- });
93
- lastPos = endPos;
94
- }
95
- result.push({
96
- text: text.slice(lastPos),
97
- startPos: lastPos,
98
- endPos: text.length,
99
- flagIE: IncludeExcludeFlag.EXCLUDE,
100
- });
101
- const issues = await validationResult;
102
- function* merge() {
103
- let i = 0;
104
- for (const r of result) {
105
- if (i >= issues.length || issues[i].offset >= r.endPos) {
106
- yield r;
107
- continue;
108
- }
109
- const span = { ...r };
110
- while (i < issues.length && issues[i].offset < span.endPos) {
111
- const issue = issues[i];
112
- const endPos = issue.offset;
113
- const text = span.text.slice(0, endPos - span.startPos);
114
- const endPosError = issue.offset + issue.text.length;
115
- yield { ...span, text, endPos };
116
- yield {
117
- ...span,
118
- isError: true,
119
- startPos: issue.offset,
120
- endPos: endPosError,
121
- text: issue.text,
122
- };
123
- span.text = span.text.slice(endPosError - span.startPos);
124
- span.startPos = endPosError;
125
- i += 1;
126
- }
127
- yield span;
128
- }
129
- }
130
- return {
131
- text,
132
- items: [...merge()].filter((i) => i.startPos < i.endPos),
133
- };
134
- }
135
- exports.checkText = checkText;
136
92
  //# sourceMappingURL=validator.js.map
@@ -1,3 +1,3 @@
1
- export { checkText, IncludeExcludeFlag, validateText } from './textValidation';
1
+ export { checkText, checkTextDocument, IncludeExcludeFlag, validateText } from './textValidation';
2
2
  export type { CheckTextInfo, IncludeExcludeOptions, TextInfoItem, ValidateTextOptions, ValidationIssue, } from './textValidation';
3
3
  //# sourceMappingURL=validator.d.ts.map
package/dist/validator.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateText = exports.IncludeExcludeFlag = exports.checkText = void 0;
3
+ exports.validateText = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = void 0;
4
4
  var textValidation_1 = require("./textValidation");
5
5
  Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return textValidation_1.checkText; } });
6
+ Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return textValidation_1.checkTextDocument; } });
6
7
  Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return textValidation_1.IncludeExcludeFlag; } });
7
8
  Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return textValidation_1.validateText; } });
8
9
  //# sourceMappingURL=validator.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "A library of useful functions used across various cspell tools.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -48,17 +48,17 @@
48
48
  },
49
49
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
50
50
  "dependencies": {
51
- "@cspell/cspell-bundled-dicts": "^6.7.0",
52
- "@cspell/cspell-pipe": "^6.7.0",
53
- "@cspell/cspell-types": "^6.7.0",
51
+ "@cspell/cspell-bundled-dicts": "^6.8.0",
52
+ "@cspell/cspell-pipe": "^6.8.0",
53
+ "@cspell/cspell-types": "^6.8.0",
54
54
  "clear-module": "^4.1.2",
55
55
  "comment-json": "^4.2.3",
56
56
  "configstore": "^5.0.1",
57
57
  "cosmiconfig": "^7.0.1",
58
- "cspell-glob": "^6.7.0",
59
- "cspell-grammar": "^6.7.0",
60
- "cspell-io": "^6.7.0",
61
- "cspell-trie-lib": "^6.7.0",
58
+ "cspell-glob": "^6.8.0",
59
+ "cspell-grammar": "^6.8.0",
60
+ "cspell-io": "^6.8.0",
61
+ "cspell-trie-lib": "^6.8.0",
62
62
  "fast-equals": "^4.0.1",
63
63
  "find-up": "^5.0.0",
64
64
  "fs-extra": "^10.1.0",
@@ -77,21 +77,21 @@
77
77
  "@cspell/dict-csharp": "^3.0.1",
78
78
  "@cspell/dict-css": "^1.0.13",
79
79
  "@cspell/dict-fa-ir": "^2.0.0",
80
- "@cspell/dict-fr-fr": "^2.1.0",
80
+ "@cspell/dict-fr-fr": "^2.1.1",
81
81
  "@cspell/dict-html": "^1.1.9",
82
- "@cspell/dict-nl-nl": "^2.2.5",
82
+ "@cspell/dict-nl-nl": "^2.2.6",
83
83
  "@cspell/dict-python": "^2.0.6",
84
84
  "@types/configstore": "^5.0.1",
85
85
  "@types/fs-extra": "^9.0.13",
86
86
  "@types/jest": "^28.1.7",
87
- "@types/node": "^18.7.6",
87
+ "@types/node": "^18.7.8",
88
88
  "cspell-dict-nl-nl": "^1.1.2",
89
89
  "jest": "^28.1.3",
90
90
  "lorem-ipsum": "^2.0.8",
91
91
  "rimraf": "^3.0.2",
92
- "rollup": "^2.78.0",
92
+ "rollup": "^2.78.1",
93
93
  "rollup-plugin-dts": "^4.2.2",
94
94
  "ts-jest": "^28.0.8"
95
95
  },
96
- "gitHead": "3a7312a15d2df1507d9e01863ec5842f5a99e0cc"
96
+ "gitHead": "8a1bd03222ffc9776c2cdd09180db6150abb3f25"
97
97
  }