Skip to content

Commit

Permalink
fix: Update CSpell and use Vitest (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Mar 27, 2023
1 parent 08d8658 commit 6afcb3c
Show file tree
Hide file tree
Showing 77 changed files with 696 additions and 517 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ const config = {
},
},
{
files: ['**/*.test.*', '**/__mocks__/**'],
files: ['**/*.test.*', '**/__mocks__/**', '**/test/**', '**/test.*'],
rules: {
'node/no-extraneous-import': 'off',
},
},
{
files: ['vitest.config.*'],
rules: {
'node/no-extraneous-import': 'off',
'import/no-unresolved': 'off',
},
},
{
files: ['**/jest.config.js'],
rules: {
Expand Down
10 changes: 5 additions & 5 deletions modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"dependencies": {
"gensequence": "^4.0.3",
"@types/fs-extra": "^11.0.1",
"@cspell/cspell-types": "^6.30.2",
"cspell-glob": "^6.30.2",
"cspell-lib": "^6.30.2",
"@cspell/cspell-types": "^6.31.0",
"cspell-glob": "^6.31.0",
"cspell-lib": "^6.31.0",
"fs-extra": "^11.1.0",
"node-watch": "^0.7.3",
"rxjs": "^7.8.0",
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.8",
"vscode-uri": "^3.0.7",
"@cspell/cspell-bundled-dicts": "^6.30.2",
"cspell-gitignore": "^6.30.2"
"@cspell/cspell-bundled-dicts": "^6.31.0",
"cspell-gitignore": "^6.31.0"
},
"engines": {
"node": ">16.0.0"
Expand Down
44 changes: 32 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://streetsidesoftware.github.io/vscode-spell-checker",
"engines": {
"node": ">16.0.0",
"vscode": "^1.67.0"
"vscode": "^1.76.0"
},
"sponsor": {
"url": "https://github.com/sponsors/streetsidesoftware"
Expand Down Expand Up @@ -723,8 +723,30 @@
"type": "string"
},
"languageId": {
"description": "Sets the programming language id.",
"type": "string"
"anyOf": [
{
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
{
"description": "This can be 'typescript,cpp,json,literal haskell', etc.",
"pattern": "^([-\\w_\\s]+)(,[-\\w_\\s]+)*$",
"type": "string"
},
{
"description": "This can be 'typescript,cpp,json,literal haskell', etc.",
"pattern": "^(![-\\w_\\s]+)(,![-\\w_\\s]+)*$",
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "Sets the programming language id to match file type."
},
"languageSettings": {
"description": "Additional settings for individual programming languages and locales.",
Expand Down Expand Up @@ -903,8 +925,6 @@
},
{
"items": {
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -1697,8 +1717,6 @@
},
{
"items": {
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -2540,6 +2558,8 @@
"@types/jest": "^29.5.0",
"@types/jest-when": "^3.5.2",
"@types/node": "^18.15.3",
"@types/vscode": "^1.76.0",
"@types/vscode-webview": "^1.57.1",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@vscode/vsce": "^2.18.0",
Expand All @@ -2561,16 +2581,16 @@
"prettier": "^2.8.4",
"shx": "^0.3.4",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5",
"typescript": "^5.0.2",
"vite": "^4.2.0",
"vitest": "^0.29.3"
"vitest": "^0.29.7"
},
"dependencies": {
"@cspell/cspell-bundled-dicts": "^6.30.2",
"@cspell/cspell-types": "^6.30.2",
"@cspell/cspell-bundled-dicts": "^6.31.0",
"@cspell/cspell-types": "^6.31.0",
"@types/react": "^17.0.53",
"cosmiconfig": "^8.1.2",
"cspell": "^6.30.2",
"cspell": "^6.31.0",
"regexp-worker": "^2.0.1"
},
"comment-resolutions": {
Expand Down
5 changes: 2 additions & 3 deletions packages/_integrationTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@cspell/cspell-types": "^6.30.2",
"@cspell/cspell-types": "^6.31.0",
"@types/chai": "^4.3.4",
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.1",
Expand All @@ -35,8 +35,7 @@
"cross-env": "^7.0.3",
"glob": "^8.1.0",
"kefir": "^3.8.8",
"mocha": "^10.2.0",
"typescript": "^4.9.5"
"mocha": "^10.2.0"
},
"peerDependenciesMeta": {},
"dependencies": {},
Expand Down
11 changes: 0 additions & 11 deletions packages/_server/jest.config.js

This file was deleted.

19 changes: 7 additions & 12 deletions packages/_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,31 @@
}
},
"devDependencies": {
"@cspell/cspell-types": "^6.30.2",
"@cspell/cspell-types": "^6.31.0",
"@types/fs-extra": "^11.0.1",
"@types/jest": "^29.5.0",
"@types/micromatch": "^4.0.2",
"@types/node": "^18.15.3",
"common-utils": "1.0.0",
"cspell-glob": "^6.30.2",
"cspell-lib": "^6.30.2",
"cspell-glob": "^6.31.0",
"cspell-lib": "^6.31.0",
"fs-extra": "^11.1.0",
"gensequence": "^4.0.3",
"iconv-lite": "^0.6.3",
"jest": "^29.5.0",
"lorem-ipsum": "^2.0.8",
"micromatch": "^4.0.5",
"minimatch": "^7.4.2",
"node-watch": "^0.7.3",
"rxjs": "^7.8.0",
"ts-jest": "^29.0.5",
"ts-json-schema-generator": "^1.2.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.5",
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.8",
"vscode-uri": "^3.0.7",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1"
},
"dependencies": {
"@cspell/cspell-bundled-dicts": "^6.30.2",
"cspell-gitignore": "^6.30.2"
"@cspell/cspell-bundled-dicts": "^6.31.0",
"cspell-gitignore": "^6.31.0"
},
"scripts": {
"clean": "shx rm -rf dist temp out coverage",
Expand All @@ -66,7 +61,7 @@
"watch": "yarn run compile --watch",
"webpack": "webpack -c webpack.prod.js",
"webpack-dev": "webpack -c webpack.dev.js",
"test-watch": "jest --watch",
"test": "jest"
"test-watch": "vitest",
"test": "vitest run"
}
}
30 changes: 24 additions & 6 deletions packages/_server/spell-checker-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,30 @@
"type": "string"
},
"languageId": {
"description": "Sets the programming language id.",
"type": "string"
"anyOf": [
{
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
{
"description": "This can be 'typescript,cpp,json,literal haskell', etc.",
"pattern": "^([-\\w_\\s]+)(,[-\\w_\\s]+)*$",
"type": "string"
},
{
"description": "This can be 'typescript,cpp,json,literal haskell', etc.",
"pattern": "^(![-\\w_\\s]+)(,![-\\w_\\s]+)*$",
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "Sets the programming language id to match file type."
},
"languageSettings": {
"description": "Additional settings for individual programming languages and locales.",
Expand Down Expand Up @@ -438,8 +460,6 @@
},
{
"items": {
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -1163,8 +1183,6 @@
},
{
"items": {
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
"type": "array"
Expand Down
43 changes: 26 additions & 17 deletions packages/_server/src/SuggestionsGenerator.test.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import * as cspell from 'cspell-lib';
import { describe, expect, test } from 'vitest';

import { maxNumberOfSuggestionsForLongWords, SuggestionGenerator } from './SuggestionsGenerator';

jest.setTimeout(30000);
const timeout = 30000;

describe('Validate Suggestions', () => {
interface DocInfo {
languageId: string;
text?: string;
}

test('genWordSuggestions', async () => {
const gen = new SuggestionGenerator(getSettings);
const doc = { languageId: 'typescript', text: '' };
const { settings } = await getSettings(doc);
const result = await gen.genWordSuggestions(doc, 'code');
const resultWords = result.map((s) => s.word);
expect(resultWords).toContain('code');
expect(result).toHaveLength(settings.numSuggestions || 0);
});
test(
'genWordSuggestions',
async () => {
const gen = new SuggestionGenerator(getSettings);
const doc = { languageId: 'typescript', text: '' };
const { settings } = await getSettings(doc);
const result = await gen.genWordSuggestions(doc, 'code');
const resultWords = result.map((s) => s.word);
expect(resultWords).toContain('code');
expect(result).toHaveLength(settings.numSuggestions || 0);
},
timeout
);

test('genWordSuggestions for long words', async () => {
const gen = new SuggestionGenerator(getSettings);
const doc = { languageId: 'typescript', text: '' };
const result = await gen.genWordSuggestions(doc, 'Acknowledgements');
expect(result).toHaveLength(maxNumberOfSuggestionsForLongWords);
expect(result.map((s) => s.word)).toContain('acknowledgements');
});
test(
'genWordSuggestions for long words',
async () => {
const gen = new SuggestionGenerator(getSettings);
const doc = { languageId: 'typescript', text: '' };
const result = await gen.genWordSuggestions(doc, 'Acknowledgements');
expect(result).toHaveLength(maxNumberOfSuggestionsForLongWords);
expect(result.map((s) => s.word)).toContain('acknowledgements');
},
timeout
);

async function getSettings(doc: DocInfo) {
const settings = await cspell.constructSettingsForText(cspell.getDefaultSettings(), doc.text || '', doc.languageId);
Expand Down

0 comments on commit 6afcb3c

Please sign in to comment.