Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove vscode-uri shim #4902

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
Jason3S committed Oct 13, 2023
commit 6ebed63e8d2df5d38cc64cd37951c15a6ac028e7
25 changes: 16 additions & 9 deletions packages/cspell-lib/src/lib/Settings/DictionarySettings.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { DictionaryDefinition, DictionaryDefinitionLegacy } from '@cspell/cspell-types';
import assert from 'assert';
import * as fsp from 'fs/promises';
import * as os from 'os';
import * as path from 'path';
import { describe, expect, test } from 'vitest';

import { isDictionaryDefinitionInlineInternal } from '../Models/CSpellSettingsInternalDef.js';
import { isDefined } from '../util/util.js';
import { getDefaultBundledSettings } from './DefaultSettings.js';
import { createDictionaryReferenceCollection as createRefCol } from './DictionaryReferenceCollection.js';
import * as DictSettings from './DictionarySettings.js';
@@ -14,11 +16,12 @@ const oc = expect.objectContaining;

describe('Validate DictionarySettings', () => {
test('expects default to not be empty', () => {
assert(defaultSettings.dictionaryDefinitions);
const mapDefs = DictSettings.filterDictDefsToLoad(
createRefCol(['php', 'wordsEn', 'unknown', 'en_us']),
defaultSettings.dictionaryDefinitions!,
defaultSettings.dictionaryDefinitions,
);
const files = mapDefs.map((def) => def.name!);
const files = mapDefs.map((def) => def.name);
expect(mapDefs).toHaveLength(2);
expect(files.filter((a) => a.includes('php'))).toHaveLength(1);
expect(files.filter((a) => a.includes('wordsEn'))).toHaveLength(0);
@@ -37,8 +40,9 @@ describe('Validate DictionarySettings', () => {
'en_us',
];
const expected = ['php', 'en_us'].sort();
const mapDefs = DictSettings.filterDictDefsToLoad(createRefCol(ids), defaultSettings.dictionaryDefinitions!);
const dicts = mapDefs.map((def) => def.name!).sort();
assert(defaultSettings.dictionaryDefinitions);
const mapDefs = DictSettings.filterDictDefsToLoad(createRefCol(ids), defaultSettings.dictionaryDefinitions);
const dicts = mapDefs.map((def) => def.name).sort();
expect(dicts).toEqual(expected);
});

@@ -50,18 +54,21 @@ describe('Validate DictionarySettings', () => {
`('validate dictionary exclusions $ids', ({ ids, expected }: { ids: string; expected: string }) => {
const dictIds = createRefCol(ids.split(','));
const expectedIds = expected.split(',').map((id) => id.trim());
const mapDefs = DictSettings.filterDictDefsToLoad(dictIds, defaultSettings.dictionaryDefinitions!);
const dicts = mapDefs.map((def) => def.name!).sort();
assert(defaultSettings.dictionaryDefinitions);
const mapDefs = DictSettings.filterDictDefsToLoad(dictIds, defaultSettings.dictionaryDefinitions);
const dicts = mapDefs.map((def) => def.name).sort();
expect(dicts).toEqual(expectedIds);
});

test('tests that the files exist', () => {
const defaultDicts = defaultSettings.dictionaryDefinitions!;
assert(defaultSettings.dictionaryDefinitions);
const defaultDicts = defaultSettings.dictionaryDefinitions;
const dictIds = createRefCol(defaultDicts.map((def) => def.name));
const mapDefs = DictSettings.filterDictDefsToLoad(dictIds, defaultSettings.dictionaryDefinitions!);
const mapDefs = DictSettings.filterDictDefsToLoad(dictIds, defaultSettings.dictionaryDefinitions);
const access = mapDefs
.filter((def) => !isDictionaryDefinitionInlineInternal(def))
.map((def) => def.path!)
.map((def) => def.path)
.filter(isDefined)
.map((path) => fsp.access(path));
expect(mapDefs.length).toBeGreaterThan(0);
return Promise.all(access);
2 changes: 1 addition & 1 deletion packages/cspell-lib/src/lib/Settings/GlobalSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import type { CSpellSettings, CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
import { format } from 'util';

@@ -12,6 +11,7 @@ export interface GlobalSettingsWithSource extends Partial<GlobalCSpellSettings>
source: CSpellSettingsWithSourceTrace['source'];
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface GlobalCSpellSettings extends Required<Pick<CSpellSettings, 'import'>> {}

export function getRawGlobalSettings(): GlobalSettingsWithSource {
4 changes: 2 additions & 2 deletions packages/cspell-lib/src/lib/Settings/LanguageSettings.test.ts
Original file line number Diff line number Diff line change
@@ -36,12 +36,12 @@ describe('Validate LanguageSettings', () => {
const sPython = calcSettingsForLanguage(languageSettings, 'python', 'en');
expect(sPython.allowCompoundWords).toBeUndefined();
expect(sPython.dictionaries).not.toHaveLength(0);
expect(sPython.dictionaries!).toEqual(expect.arrayContaining(['en_us', 'python', 'django']));
expect(sPython.dictionaries).toEqual(expect.arrayContaining(['en_us', 'python', 'django']));

const sPhp = calcSettingsForLanguage(languageSettings, 'php', 'en-gb');
expect(sPhp.allowCompoundWords).toBeUndefined();
expect(sPhp.dictionaries).not.toHaveLength(0);
expect(sPhp.dictionaries!).toEqual(
expect(sPhp.dictionaries).toEqual(
expect.arrayContaining(['en-gb', 'php', 'html', 'npm', 'fonts', 'css', 'typescript', 'fullstack']),
);
});
2 changes: 1 addition & 1 deletion packages/cspell-lib/src/lib/textValidation/checkText.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import type { CSpellUserSettings } from '@cspell/cspell-types';
import assert from 'assert';

@@ -69,6 +68,7 @@ export enum IncludeExcludeFlag {
EXCLUDE = 'E',
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CheckTextOptions extends DocumentValidatorOptions {}

/**
2 changes: 1 addition & 1 deletion packages/cspell-lib/src/lib/util/wordSplitter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
import type { TextOffset } from '@cspell/cspell-types';

import { PairingHeap } from './PairingHeap.js';
@@ -41,6 +40,7 @@ export interface TextOffsetWithValid extends TextOffset {
isFound: boolean;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface SplitOptions extends WordBreakOptions {}

export function split(
1 change: 1 addition & 0 deletions packages/cspell-trie-lib/src/lib/TrieNode/trie-util.ts
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ export function countWords(root: TrieNode): number {

function walk(n: TrieNode) {
if (visited.has(n)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return visited.get(n)!;
}

1 change: 1 addition & 0 deletions packages/cspell-trie-lib/src/lib/convertToTrieRefNodes.ts
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ export function convertToTrieRefNodes(root: TrieNode): IterableIterator<TrieRefN
function* walkByRollup(n: TrieNode): IterableIterator<TrieRefNode> {
if (cached.has(n)) return;
if (n.f && !n.c) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
cached.set(n, cached.get(eow)!);
return;
}
2 changes: 2 additions & 0 deletions packages/cspell-trie-lib/src/lib/utils/secondChanceCache.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export class SecondChanceCache<Key, Value> {
public has(key: Key) {
if (this.map0.has(key)) return true;
if (this.map1.has(key)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.set(key, this.get1(key)!);
return true;
}
@@ -46,6 +47,7 @@ export class SecondChanceCache<Key, Value> {

private get1(key: Key): Value | undefined {
if (this.map1.has(key)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const v = this.map1.get(key)!;
this.map1.delete(key);
this.map0.set(key, v);
3 changes: 1 addition & 2 deletions packages/cspell-trie-lib/src/lib/walker/hintedWalker.ts
Original file line number Diff line number Diff line change
@@ -80,8 +80,7 @@ function* hintedWalkerNext(
.filter((a) => a in c)
.map((letter) => ({
letter,

node: c[letter]!,
node: c[letter],
hintOffset: hintOffset + 1,
}));
// We don't want to suggest the compound character.
4 changes: 2 additions & 2 deletions packages/cspell-types/src/features.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */

/**
* These are experimental features and are subject to change or removal without notice.
*/
@@ -13,12 +11,14 @@ export interface FeaturesExperimental {
/**
* These are the current set of active features
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface FeaturesActive {}

/**
* These are feature settings that have been deprecated or moved elsewhere they will have no
* effect on the code but are here to prevent schema errors. The will get cleaned out on major versions.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface FeaturesDeprecated {}

/**
2 changes: 1 addition & 1 deletion packages/hunspell-reader/src/aff.ts
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ export function processRules(affInfo: AffInfo): Map<string, Rule> {
.map((pfx) => ({ id: pfx.id, type: 'pfx', pfx }));
const flagRules: Sequence<Rule> = GS.sequenceFromObject(affInfo as AffTransformFlags)
.filter(([key, value]) => !!affFlag[key] && !!value)

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.map(([key, value]) => ({ id: value!, type: 'flag', flags: affFlag[key] }));

const rules = sfxRules