Skip to content

Commit

Permalink
Merge d041b6c into 4db7285
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Aug 7, 2023
2 parents 4db7285 + d041b6c commit 1e8c746
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 82 deletions.
1 change: 1 addition & 0 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"devDependencies": {
"@cspell/cspell-bundled-dicts": "workspace:*",
"@cspell/dict-de-de": "^3.1.0",
"@types/jest": "^29.5.3",
"@types/shelljs": "^0.8.12",
"cspell": "workspace:*",
"jest": "^29.6.2"
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"@tsconfig/node16": "^16.1.0",
"@types/jest": "^29.5.3",
"@types/node": "^18.17.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
Expand All @@ -113,7 +112,6 @@
"eslint-plugin-unicorn": "^48.0.1",
"globcat": "^2.0.1",
"inject-markdown": "^1.5.0",
"jest": "^29.6.2",
"nyc": "^15.1.0",
"prettier": "^3.0.1",
"rollup": "^3.27.1",
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-code-snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"node": ">=16"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"jest": "^29.6.2"
}
}
1 change: 1 addition & 0 deletions packages/cspell-config-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"yaml": "^1.10.2"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"jest": "^29.6.2"
}
}
115 changes: 115 additions & 0 deletions packages/cspell-eslint-plugin/assets/options.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,135 @@
"additionalProperties": false,
"description": "CSpell options to pass to the spell checker.",
"properties": {
"allowCompoundWords": {
"default": false,
"description": "True to enable compound word checking. See [Case Sensitivity](https://cspell.org/docs/case-sensitive/) for more details.",
"type": "boolean"
},
"dictionaries": {
"description": "Optional list of dictionaries to use. Each entry should match the name of the dictionary.\n\nTo remove a dictionary from the list, add `!` before the name.\n\nFor example, `!typescript` will turn off the dictionary with the name `typescript`.\n\nSee the [Dictionaries](https://cspell.org/docs/dictionaries/) and [Custom Dictionaries](https://cspell.org/docs/dictionaries-custom/) for more details.",
"items": {
"description": "Reference to a dictionary by name. One of:\n- {@link DictionaryRef } \n- {@link DictionaryNegRef }",
"type": "string"
},
"type": "array"
},
"dictionaryDefinition": {
"additionalProperties": false,
"properties": {
"description": {
"description": "Optional description.",
"type": "string"
},
"name": {
"description": "This is the name of a dictionary.\n\nName Format:\n- Must contain at least 1 number or letter.\n- Spaces are allowed.\n- Leading and trailing space will be removed.\n- Names ARE case-sensitive.\n- Must not contain `*`, `!`, `;`, `,`, `{`, `}`, `[`, `]`, `~`.",
"pattern": "^(?=[^!*,;{}[\\]~\\n]+$)(?=(.*\\w)).+$",
"type": "string"
},
"noSuggest": {
"description": "Indicate that suggestions should not come from this dictionary. Words in this dictionary are considered correct, but will not be used when making spell correction suggestions.\n\nNote: if a word is suggested by another dictionary, but found in this dictionary, it will be removed from the set of possible suggestions.",
"type": "boolean"
},
"path": {
"description": "Path to the file.",
"pattern": "^.*\\.(?:txt|trie)(?:\\.gz)?$",
"type": "string"
},
"repMap": {
"description": "Replacement pairs.",
"items": {
"items": {
"type": "string"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"type": "array"
},
"type": {
"default": "S",
"description": "Type of file: S - single word per line, W - each line can contain one or more words separated by space, C - each line is treated like code (Camel Case is allowed). Default is S. C is the slowest to load due to the need to split each line based upon code splitting rules.",
"enum": [
"S",
"W",
"C",
"T"
],
"type": "string"
},
"useCompounds": {
"description": "Use Compounds.",
"type": "boolean"
}
},
"required": [
"name",
"path"
],
"type": "object"
},
"enableFiletypes": {
"items": {
"description": "This can be '*', 'typescript', 'cpp', 'json', etc.",
"pattern": "^(!?[-\\w_\\s]+)|(\\*)$",
"type": "string"
},
"title": "File Types to Check",
"type": "array",
"uniqueItems": true
},
"enabled": {
"default": true,
"description": "Is the spell checker enabled.",
"type": "boolean"
},
"flagWords": {
"description": "List of words to always be considered incorrect. Words found in `flagWords` override `words`.\n\nFormat of `flagWords`\n- single word entry - `word`\n- with suggestions - `word:suggestion` or `word->suggestion, suggestions`\n\nExample: ```ts \"flagWords\": [ \"color: colour\", \"incase: in case, encase\", \"canot->cannot\", \"cancelled->canceled\" ] ```",
"items": {
"type": "string"
},
"type": "array"
},
"ignoreRegExpList": {
"description": "List of regular expression patterns or pattern names to exclude from spell checking.\n\nExample: `[\"href\"]` - to exclude html href pattern.\n\nRegular expressions use JavaScript regular expression syntax.\n\nExample: to ignore ALL-CAPS words\n\nJSON ```json \"ignoreRegExpList\": [\"/\\\\b[A-Z]+\\\\b/g\"] ```\n\nYAML ```yaml ignoreRegExpList: - >- /\\b[A-Z]+\\b/g ```\n\nBy default, several patterns are excluded. See [Configuration](https://cspell.org/configuration/patterns) for more details.\n\nWhile you can create your own patterns, you can also leverage several patterns that are [built-in to CSpell](https://cspell.org/types/cspell-types/types/PredefinedPatterns.html).",
"items": {
"description": "A PatternRef is a Pattern or PatternId.",
"type": "string"
},
"type": "array"
},
"ignoreWords": {
"description": "List of words to be ignored. An ignored word will not show up as an error, even if it is also in the `flagWords`.",
"items": {
"type": "string"
},
"type": "array"
},
"import": {
"anyOf": [
{
"description": "A File System Path. Relative paths are relative to the configuration file.",
"type": "string"
},
{
"items": {
"description": "A File System Path. Relative paths are relative to the configuration file.",
"type": "string"
},
"type": "array"
}
],
"description": "Allows this configuration to inherit configuration for one or more other files.\n\nSee [Importing / Extending Configuration](https://cspell.org/configuration/imports/) for more details."
},
"includeRegExpList": {
"description": "List of regular expression patterns or defined pattern names to match for spell checking.\n\nIf this property is defined, only text matching the included patterns will be checked.\n\nWhile you can create your own patterns, you can also leverage several patterns that are [built-in to CSpell](https://cspell.org/types/cspell-types/types/PredefinedPatterns.html).",
"items": {
"description": "A PatternRef is a Pattern or PatternId.",
"type": "string"
},
"type": "array"
},
"words": {
"description": "List of words to be considered correct.",
"items": {
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"devDependencies": {
"@types/eslint": "^8.44.1",
"@types/estree": "^1.0.1",
"@types/mocha": "^10.0.1",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/types": "^6.2.1",
"@typescript-eslint/typescript-estree": "^5.62.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/cspell-eslint-plugin/src/common/options.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, test } from 'mocha';

import { defaultOptions, type Options } from './options.js';
import type { CSpellSettings } from '@cspell/cspell-types';
import assert from 'assert';

describe('options', () => {
test('Options are compatible with cspell-types', () => {
const options: Options = { ...defaultOptions, cspell: { words: ['word'] } };
assert(options.cspell);
const settings: CSpellSettings = options.cspell;
assert(true, 'it is expected to compile.');
});
});
29 changes: 27 additions & 2 deletions packages/cspell-eslint-plugin/src/common/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CSpellSettings } from '@cspell/cspell-types';
import type { CSpellSettings, DictionaryDefinitionPreferred } from '@cspell/cspell-types';

export interface Options extends Check {
/**
Expand Down Expand Up @@ -27,6 +27,25 @@ export interface Options extends Check {
debugMode?: boolean;
}

type DictionaryDefinition = DictionaryDefinitionPreferred;

export type CSpellOptions = Pick<
CSpellSettings,
// | 'languageSettings'
// | 'overrides'
| 'allowCompoundWords'
| 'dictionaries'
| 'enabled'
| 'flagWords'
| 'ignoreWords'
| 'ignoreRegExpList'
| 'includeRegExpList'
| 'import'
| 'words'
> & {
dictionaryDefinition?: DictionaryDefinition;
};

export type RequiredOptions = Required<Options>;

export interface Check {
Expand Down Expand Up @@ -76,7 +95,7 @@ export interface Check {
/**
* CSpell options to pass to the spell checker.
*/
cspell?: Pick<CSpellSettings, 'words' | 'ignoreWords' | 'flagWords'>;
cspell?: CSpellOptions;
/**
* Specify a path to a custom word list file.
*
Expand All @@ -102,3 +121,9 @@ export interface CustomWordListFile {
}

export type WorkerOptions = RequiredOptions & { cwd: string };

export const defaultOptions: Options = {
numSuggestions: 8,
generateSuggestions: true,
autoFix: false,
};
3 changes: 2 additions & 1 deletion packages/cspell-eslint-plugin/src/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"tsBuildInfoFile": "../../dist/common/compile.tsbuildInfo",
"rootDir": ".",
"outDir": "../../dist/common"
"outDir": "../../dist/common",
"skipLibCheck": true
},
"include": ["."]
}
Loading

0 comments on commit 1e8c746

Please sign in to comment.