Skip to content

Commit

Permalink
fix: Fix schema generation to use deprecatedMessage (#972)
Browse files Browse the repository at this point in the history
* test: load the Dutch dictionary in the samples

* Update CHANGELOG.md

* dev: Have the issues display after the file progress.

* dev: do not add `./` to relative paths in progress output

* fix: Fix schema generation to use `deprecatedMessage`

* dev: allow the `deprecatedMessage` keyword

* dev: make ajv aware of `deprecatedMessage`

* Revert "dev: do not add `./` to relative paths in progress output"

This reverts commit 5b9a992.
  • Loading branch information
Jason3S authored Feb 19, 2021
1 parent 068424a commit 492dca9
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 112 deletions.
11 changes: 11 additions & 0 deletions ajv.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const keywords = ['deprecatedMessage'];

function addKeywords(ajv) {
for (const keyword of keywords) {
ajv.addKeyword(keyword);
}
}

module.exports = addKeywords;
3 changes: 2 additions & 1 deletion cspell.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@
"type": "array"
}
],
"description": "The locale filter, matches against the language. This can be a comma separated list. \"*\" will match all locales."
"deprecatedMessage": "Use `locale` instead",
"description": "Deprecated - The locale filter, matches against the language. This can be a comma separated list. \"*\" will match all locales."
},
"locale": {
"anyOf": [
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"pub-next": "npm install && npm test && lerna publish from-git --dist-tag next",
"symlink": "node build_tools/bin/symlink.js packages test-packages",
"test-watch": "lerna run --parallel test-watch",
"test": "lerna run test && ajv -s ./cspell.schema.json -d cspell.json",
"test": "lerna run test && npm run test-schema",
"test-integrations": "cd ./integration-tests && npm run integration-tests",
"test-schema": "ajv -s ./cspell.schema.json -d cspell.json -c ./ajv.config.js",
"update-packages": "lerna exec \"npm update -S && rimraf node_modules package-lock.json && npm i\" && lerna bootstrap --no-ci",
"update-snapshots": "lerna run update-snapshots --scope cspell-integration-tests"
},
Expand All @@ -53,7 +54,7 @@
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"ajv-cli": "^4.0.1",
"ajv-cli": "^4.1.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.22.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/cspell-lib/samples/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
"language": "nl",
"filename": "**/dutch/*.txt"
}
],
"import": [
"@cspell/dict-nl-nl/cspell-ext.json"
]
}
3 changes: 2 additions & 1 deletion packages/cspell-types/cspell.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@
"type": "array"
}
],
"description": "The locale filter, matches against the language. This can be a comma separated list. \"*\" will match all locales."
"deprecatedMessage": "Use `locale` instead",
"description": "Deprecated - The locale filter, matches against the language. This can be a comma separated list. \"*\" will match all locales."
},
"locale": {
"anyOf": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"clean": "rimraf dist coverage",
"build": "npm run compile && npm run build-schema",
"build-schema": "ts-json-schema-generator --no-top-ref --path src/settings/CSpellSettingsDef.ts --type CSpellSettings --validation-keywords markdownDescription --validation-keywords scope --validation-keywords deprecationMessage -o ./cspell.schema.json && cp ./cspell.schema.json ../..",
"build-schema": "ts-json-schema-generator --no-top-ref --path src/settings/CSpellSettingsDef.ts --type CSpellSettings --validation-keywords markdownDescription --validation-keywords scope --validation-keywords deprecated --validation-keywords deprecatedMessage -o ./cspell.schema.json && cp ./cspell.schema.json ../..",
"clean-build": "npm run clean && npm run build",
"compile": "tsc -p .",
"test": "jest"
Expand Down
12 changes: 9 additions & 3 deletions packages/cspell-types/src/settings/CSpellSettingsDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ export interface DictionaryDefinitionAlternate extends DictionaryDefinitionBase
export interface DictionaryDefinitionLegacy extends DictionaryDefinitionBase {
/** Path to the file, if undefined the path to the extension dictionaries is assumed */
path?: FsPath;
/** File name @deprecated use path */
/**
* File name
* @deprecated
* @deprecatedMessage Use path instead.
*/
file: FsPath;
/**
* Type of file:
Expand Down Expand Up @@ -288,8 +292,9 @@ export interface LanguageSettingFilterFieldsDeprecated {
/** The language id. Ex: "typescript", "html", or "php". "*" -- will match all languages */
languageId: LanguageId | LanguageId[];
/**
* The locale filter, matches against the language. This can be a comma separated list. "*" will match all locales.
* @deprecated use `locale`
* Deprecated - The locale filter, matches against the language. This can be a comma separated list. "*" will match all locales.
* @deprecated
* @deprecatedMessage Use `locale` instead
*/
local?: LocaleId | LocaleId[];
}
Expand Down Expand Up @@ -336,6 +341,7 @@ export type DictionaryId = string;
export type LocaleId = string;

/**
* @deprecated
* @deprecatedMessage Use LocaleId instead
*/
export type LocalId = LocaleId;
Expand Down
113 changes: 14 additions & 99 deletions packages/cspell/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,187 +5,102 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

# [5.3.0-alpha.0](https://github.com/streetsidesoftware/cspell/compare/v5.2.4...v5.3.0-alpha.0) (2021-02-18)


### Features

* Be able to specify files to spell check within the config. ([#948](https://github.com/streetsidesoftware/cspell/issues/948)) ([23f7a48](https://github.com/streetsidesoftware/cspell/commit/23f7a488ef500fb1df5cd234c7d3c2ab4ec02961)), closes [#571](https://github.com/streetsidesoftware/cspell/issues/571)
* Part 1 - glob patterns are relative to the config file. ([#921](https://github.com/streetsidesoftware/cspell/issues/921)) ([a250448](https://github.com/streetsidesoftware/cspell/commit/a2504484ec38f15804cc0a203317266f83566b7c))
* Support local configuration files ([#966](https://github.com/streetsidesoftware/cspell/issues/966)) ([0ccc5fe](https://github.com/streetsidesoftware/cspell/commit/0ccc5fe9eb70ca3a4c6e5a3fc0b653465e76983c))




- Be able to specify files to spell check within the config. ([#948](https://github.com/streetsidesoftware/cspell/issues/948)) ([23f7a48](https://github.com/streetsidesoftware/cspell/commit/23f7a488ef500fb1df5cd234c7d3c2ab4ec02961)), closes [#571](https://github.com/streetsidesoftware/cspell/issues/571)
- Glob patterns are relative to the config file. ([#921](https://github.com/streetsidesoftware/cspell/issues/921)) ([a250448](https://github.com/streetsidesoftware/cspell/commit/a2504484ec38f15804cc0a203317266f83566b7c))
- Support local configuration files ([#966](https://github.com/streetsidesoftware/cspell/issues/966)) ([0ccc5fe](https://github.com/streetsidesoftware/cspell/commit/0ccc5fe9eb70ca3a4c6e5a3fc0b653465e76983c))

## [5.2.4](https://github.com/streetsidesoftware/cspell/compare/v5.2.3...v5.2.4) (2021-01-28)

**Note:** Version bump only for package cspell





## [5.2.3](https://github.com/streetsidesoftware/cspell/compare/v5.2.2...v5.2.3) (2021-01-27)

**Note:** Version bump only for package cspell





## [5.2.2](https://github.com/streetsidesoftware/cspell/compare/v5.2.1...v5.2.2) (2021-01-26)

**Note:** Version bump only for package cspell





## [5.2.1](https://github.com/streetsidesoftware/cspell/compare/v5.2.0...v5.2.1) (2021-01-23)


### Bug Fixes

* make sure version and help do not exit with non-zero code. ([#883](https://github.com/streetsidesoftware/cspell/issues/883)) ([b8e91f3](https://github.com/streetsidesoftware/cspell/commit/b8e91f35e2cdebc14dda9b73de1dd31183f5d91d)), closes [#880](https://github.com/streetsidesoftware/cspell/issues/880)




- make sure version and help do not exit with non-zero code. ([#883](https://github.com/streetsidesoftware/cspell/issues/883)) ([b8e91f3](https://github.com/streetsidesoftware/cspell/commit/b8e91f35e2cdebc14dda9b73de1dd31183f5d91d)), closes [#880](https://github.com/streetsidesoftware/cspell/issues/880)

# [5.2.0](https://github.com/streetsidesoftware/cspell/compare/v5.1.3...v5.2.0) (2021-01-23)


### Features

* Add options --show-context and --relative ([#878](https://github.com/streetsidesoftware/cspell/issues/878)) ([1fddaac](https://github.com/streetsidesoftware/cspell/commit/1fddaac4d80f8a28e12677e0953e8443116c24c2))
* support .yaml and .js configuration files ([#875](https://github.com/streetsidesoftware/cspell/issues/875)) ([4a07acc](https://github.com/streetsidesoftware/cspell/commit/4a07acc507f3106e1f09805b8ee019ea200ae08f))
* support displaying suggestions ([#881](https://github.com/streetsidesoftware/cspell/issues/881)) ([e3f207f](https://github.com/streetsidesoftware/cspell/commit/e3f207f802231cc7915015d2c2924e08745e4f8e))




- Add options --show-context and --relative ([#878](https://github.com/streetsidesoftware/cspell/issues/878)) ([1fddaac](https://github.com/streetsidesoftware/cspell/commit/1fddaac4d80f8a28e12677e0953e8443116c24c2))
- support .yaml and .js configuration files ([#875](https://github.com/streetsidesoftware/cspell/issues/875)) ([4a07acc](https://github.com/streetsidesoftware/cspell/commit/4a07acc507f3106e1f09805b8ee019ea200ae08f))
- support displaying suggestions ([#881](https://github.com/streetsidesoftware/cspell/issues/881)) ([e3f207f](https://github.com/streetsidesoftware/cspell/commit/e3f207f802231cc7915015d2c2924e08745e4f8e))

## [5.1.3](https://github.com/streetsidesoftware/cspell/compare/v5.1.2...v5.1.3) (2021-01-05)

**Note:** Version bump only for package cspell





## [5.1.2](https://github.com/streetsidesoftware/cspell/compare/v5.1.1...v5.1.2) (2020-12-31)

**Note:** Version bump only for package cspell





## [5.1.1](https://github.com/streetsidesoftware/cspell/compare/v5.1.0...v5.1.1) (2020-12-28)


### Bug Fixes

* remove dependency upon `@types/glob` ([#810](https://github.com/streetsidesoftware/cspell/issues/810)) ([03fab52](https://github.com/streetsidesoftware/cspell/commit/03fab5288d971ced4c49da6765194653d8f73f96))




- remove dependency upon `@types/glob` ([#810](https://github.com/streetsidesoftware/cspell/issues/810)) ([03fab52](https://github.com/streetsidesoftware/cspell/commit/03fab5288d971ced4c49da6765194653d8f73f96))

# [5.1.0](https://github.com/streetsidesoftware/cspell/compare/v5.0.8...v5.1.0) (2020-12-27)


### Features

* improve spell checking speed and allow multiple exclude arguments ([#806](https://github.com/streetsidesoftware/cspell/issues/806)) ([7a4c8f8](https://github.com/streetsidesoftware/cspell/commit/7a4c8f8d968aba520122ad94feb21096e8190898))




- improve spell checking speed and allow multiple exclude arguments ([#806](https://github.com/streetsidesoftware/cspell/issues/806)) ([7a4c8f8](https://github.com/streetsidesoftware/cspell/commit/7a4c8f8d968aba520122ad94feb21096e8190898))

## [5.0.8](https://github.com/streetsidesoftware/cspell/compare/v5.0.7...v5.0.8) (2020-12-17)


### Bug Fixes

* Docs and minor edits ([#757](https://github.com/streetsidesoftware/cspell/issues/757)) ([e5f4567](https://github.com/streetsidesoftware/cspell/commit/e5f4567f25a90ee52105e50c99c7ad90cfb9fdb0))
* issue with importing cspell ([ff32d0c](https://github.com/streetsidesoftware/cspell/commit/ff32d0cab987026e13d131961667e10b6cd83831))




- Docs and minor edits ([#757](https://github.com/streetsidesoftware/cspell/issues/757)) ([e5f4567](https://github.com/streetsidesoftware/cspell/commit/e5f4567f25a90ee52105e50c99c7ad90cfb9fdb0))
- issue with importing cspell ([ff32d0c](https://github.com/streetsidesoftware/cspell/commit/ff32d0cab987026e13d131961667e10b6cd83831))

## [5.0.7](https://github.com/streetsidesoftware/cspell/compare/v5.0.6...v5.0.7) (2020-12-16)

**Note:** Version bump only for package cspell





## [5.0.6](https://github.com/streetsidesoftware/cspell/compare/v5.0.5...v5.0.6) (2020-12-15)

**Note:** Version bump only for package cspell





## [5.0.5](https://github.com/streetsidesoftware/cspell/compare/v5.0.4...v5.0.5) (2020-12-15)

**Note:** Version bump only for package cspell





## [5.0.4](https://github.com/streetsidesoftware/cspell/compare/v5.0.3...v5.0.4) (2020-12-15)

**Note:** Version bump only for package cspell





## [5.0.3](https://github.com/streetsidesoftware/cspell/compare/v5.0.2...v5.0.3) (2020-12-04)


### Bug Fixes

* Expose Emitter types ([#718](https://github.com/streetsidesoftware/cspell/issues/718)) ([3ef9030](https://github.com/streetsidesoftware/cspell/commit/3ef903097de0819025ba74eb9bf978eb1f57fc12))




- Expose Emitter types ([#718](https://github.com/streetsidesoftware/cspell/issues/718)) ([3ef9030](https://github.com/streetsidesoftware/cspell/commit/3ef903097de0819025ba74eb9bf978eb1f57fc12))

## [5.0.2](https://github.com/streetsidesoftware/cspell/compare/v5.0.2-alpha.1...v5.0.2) (2020-11-26)

**Note:** Version bump only for package cspell





## [5.0.1](https://github.com/streetsidesoftware/cspell/compare/v5.0.1-alpha.15...v5.0.1) (2020-11-20)


### Bug Fixes

* make sure the error code is correctly set ([#619](https://github.com/streetsidesoftware/cspell/issues/619)) ([09e358c](https://github.com/streetsidesoftware/cspell/commit/09e358c3b7d3c485df92d7d9c5a652cf6a85f635))




- make sure the error code is correctly set ([#619](https://github.com/streetsidesoftware/cspell/issues/619)) ([09e358c](https://github.com/streetsidesoftware/cspell/commit/09e358c3b7d3c485df92d7d9c5a652cf6a85f635))

## [5.0.1-alpha.15](https://github.com/streetsidesoftware/cspell/compare/v5.0.1-alpha.14...v5.0.1-alpha.15) (2020-11-18)


### Bug Fixes

* force new version ([3ab08ab](https://github.com/streetsidesoftware/cspell/commit/3ab08ab5ae1939d934b2f0fb23d33defc60c1a7f))




- force new version ([3ab08ab](https://github.com/streetsidesoftware/cspell/commit/3ab08ab5ae1939d934b2f0fb23d33defc60c1a7f))

## 5.0.1-alpha.14 (2020-11-17)

Expand Down
6 changes: 3 additions & 3 deletions packages/cspell/samples/.cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// cSpell Settings
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
// Version of the setting file. Always 0.1
"version": "0.1",
"version": "0.2",
// language - current active spelling language
"language": "en",
"allowCompoundWords": false,
Expand Down Expand Up @@ -35,7 +35,7 @@
// "allowCompoundWords": false,
// Language locale. i.e. en-US, de-AT, or ru. * will match all locales.
// Multiple locales can be specified like: "en, en-US" to match both English and English US.
"local": "*",
"locale": "*",
// By default the whole text of a file is included for spell checking
// Adding patterns to the "includeRegExpList" to only include matching patterns
"includeRegExpList": [
Expand Down
10 changes: 8 additions & 2 deletions packages/cspell/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function runLint(cfg: CSpellApplicationConfiguration): Promise<RunResult>

const startTime = Date.now();
let spellResult: Partial<cspell.SpellCheckFileResult> = {};
cfg.info(
`Checking: ${filename}, File type: ${doc.languageId ?? 'auto'}, Language: ${doc.locale ?? 'default'}`,
MessageTypes.Info
);
try {
const r = await cspell.spellCheckDocument(doc, {}, configInfo.config);
spellResult = r;
Expand All @@ -66,11 +70,10 @@ export function runLint(cfg: CSpellApplicationConfiguration): Promise<RunResult>
const elapsed = result.elapsedTimeMs / 1000.0;
const dictionaries = config.dictionaries || [];
cfg.info(
`Checking: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`,
`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`,
MessageTypes.Info
);
cfg.info(`Dictionaries Used: ${dictionaries.join(', ')}`, MessageTypes.Info);
result.issues.filter(cfg.uniqueFilter).forEach((issue) => cfg.logIssue(issue));
return result;
}

Expand Down Expand Up @@ -116,7 +119,10 @@ export function runLint(cfg: CSpellApplicationConfiguration): Promise<RunResult>
}
const p = processFile(file, configInfo);
const { elapsedTimeMs } = await measurePromise(p);
const result = await p;
emitProgress(elapsedTimeMs);
// Show the spelling errors after emitting the progress.
result.issues.filter(cfg.uniqueFilter).forEach((issue) => cfg.logIssue(issue));
const r = await p;
status.files += 1;
if (r.issues.length || r.errors) {
Expand Down

0 comments on commit 492dca9

Please sign in to comment.