Skip to content

Commit

Permalink
Merge branch 'master' into more-info-for-object-properties
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/ValidationError.js
#	test/__snapshots__/index.test.js.snap
  • Loading branch information
vankop committed Nov 26, 2019
2 parents cea95fb + 3a4f74a commit 7a2b2df
Show file tree
Hide file tree
Showing 23 changed files with 2,281 additions and 1,104 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ yarn-debug.log*

.eslintcache

/dist
/local
/reports
/coverage
Expand All @@ -27,3 +26,6 @@ DS_Store
.DS_Store
Thumbs.db
*.iml

#build
dist
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.5.0](https://github.com/webpack/schema-utils/compare/v2.4.1...v2.5.0) (2019-10-15)


### Bug Fixes

* rework format for maxLength, minLength ([#67](https://github.com/webpack/schema-utils/issues/67)) ([0d12259](https://github.com/webpack/schema-utils/commit/0d12259))
* support all cases with one number in range ([#64](https://github.com/webpack/schema-utils/issues/64)) ([7fc8069](https://github.com/webpack/schema-utils/commit/7fc8069))
* typescript definition and export naming ([#69](https://github.com/webpack/schema-utils/issues/69)) ([a435b79](https://github.com/webpack/schema-utils/commit/a435b79))


### Features

* "smart" numbers range ([62fb107](https://github.com/webpack/schema-utils/commit/62fb107))

### [2.4.1](https://github.com/webpack/schema-utils/compare/v2.4.0...v2.4.1) (2019-09-27)


Expand Down
62 changes: 43 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ trigger:
- master
- next

variables:
npm_config_cache: $(Pipeline.Workspace)/.npm

jobs:
- job: Lint
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
Expand All @@ -20,24 +23,35 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@0
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run lint
displayName: 'Run lint'
- script: npm run build:types
displayName: 'Build declarations'
- task: Bash@3
inputs:
targetType: 'inline'
script: 'if [ -n "$(git status declarations --porcelain)" ]; then echo "Missing declarations in git"; exit 1; else echo "All declarations are valid"; fi'
displayName: 'Run lint declarations'
- script: npm run security
displayName: 'Run NPM audit'
- script: ./node_modules/.bin/commitlint-azure-pipelines
displayName: 'Run lint commit message'

- job: Linux
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-latest
strategy:
maxParallel: 3
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
node-12:
node_version: ^12.0.0
node-10:
Expand All @@ -58,10 +72,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@0
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
displayName: 'Run tests with coverage'
Expand All @@ -77,10 +93,12 @@ jobs:

- job: macOS
pool:
vmImage: macOS-10.14
vmImage: macOS-latest
strategy:
maxParallel: 3
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
node-12:
node_version: ^12.0.0
node-10:
Expand All @@ -101,10 +119,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@0
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
displayName: 'Run tests with coverage'
Expand All @@ -120,10 +140,12 @@ jobs:

- job: Windows
pool:
vmImage: windows-2019
vmImage: windows-latest
strategy:
maxParallel: 3
maxParallel: 4
matrix:
node-13:
node_version: ^13.0.0
node-12:
node_version: ^12.0.0
node-10:
Expand All @@ -147,10 +169,12 @@ jobs:
node -v
npm -v
displayName: 'Print versions'
- task: Npm@1
- task: CacheBeta@0
inputs:
command: custom
customCommand: ci
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
displayName: 'Cache npm'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit"
displayName: 'Run tests with coverage'
Expand Down
115 changes: 115 additions & 0 deletions declarations/ValidationError.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
export default ValidationError;
export type JSONSchema6 = import('json-schema').JSONSchema6;
export type JSONSchema7 = import('json-schema').JSONSchema7;
export type Schema =
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7;
export type ValidationErrorConfiguration = {
name?: string | undefined;
baseDataPath?: string | undefined;
postFormatter?: import('./validate').PostFormatter | undefined;
};
export type PostFormatter = (
formattedError: string,
error: import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
}
) => string;
export type SchemaUtilErrorObject = import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
};
export type SPECIFICITY = number;
declare class ValidationError extends Error {
/**
* @param {Array<SchemaUtilErrorObject>} errors
* @param {Schema} schema
* @param {ValidationErrorConfiguration} configuration
*/
constructor(
errors: (import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
})[],
schema:
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7,
configuration?: import('./validate').ValidationErrorConfiguration
);
/** @type {Array<SchemaUtilErrorObject>} */
errors: Array<SchemaUtilErrorObject>;
/** @type {Schema} */
schema: Schema;
/** @type {string} */
headerName: string;
/** @type {string} */
baseDataPath: string;
/** @type {PostFormatter | null} */
postFormatter: PostFormatter | null;
/**
* @param {string} path
* @returns {Schema}
*/
getSchemaPart(
path: string
):
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7;
/**
* @param {Schema} schema
* @param {Array<Object>} prevSchemas
* @returns {string}
*/
formatSchema(
schema:
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7,
prevSchemas?: Object[]
): string;
/**
* @param {Schema=} schemaPart
* @param {(boolean | Array<string>)=} additionalPath
* @param {boolean=} needDot
* @returns {string}
*/
getSchemaPartText(
schemaPart?:
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7
| undefined,
additionalPath?: boolean | string[] | undefined,
needDot?: boolean | undefined
): string;
/**
* @param {Schema=} schemaPart
* @returns {string}
*/
getSchemaPartDescription(
schemaPart?:
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7
| undefined
): string;
/**
* @param {SchemaUtilErrorObject} error
* @returns {string}
*/
formatValidationError(
error: import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
}
): string;
/**
* @param {Array<SchemaUtilErrorObject>} errors
* @returns {string}
*/
formatValidationErrors(
errors: (import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
})[]
): string;
}
2 changes: 2 additions & 0 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _exports: typeof import('./validate').default;
export = _exports;
13 changes: 13 additions & 0 deletions declarations/keywords/absolutePath.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default addAbsolutePathKeyword;
export type Ajv = import('ajv').Ajv;
export type SchemaUtilErrorObject = import('ajv').ErrorObject & {
children?: import('ajv').ErrorObject[] | undefined;
};
/**
*
* @param {Ajv} ajv
* @returns {Ajv}
*/
declare function addAbsolutePathKeyword(
ajv: import('ajv').Ajv
): import('ajv').Ajv;
43 changes: 43 additions & 0 deletions declarations/util/Range.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export = Range;
/**
* @typedef {[number, boolean]} RangeValue
*/
/**
* @callback RangeValueCallback
* @param {RangeValue} rangeValue
* @returns {boolean}
*/
declare class Range {
/** @type {Array<RangeValue>} */
_left: Array<RangeValue>;
/** @type {Array<RangeValue>} */
_right: Array<RangeValue>;
/**
* @param {number} value
* @param {boolean=} exclusive
*/
left(value: number, exclusive?: boolean | undefined): void;
/**
* @param {number} value
* @param {boolean=} exclusive
*/
right(value: number, exclusive?: boolean | undefined): void;
/**
* @param {boolean} logic is not logic applied
* @return {string} "smart" range string representation
*/
format(logic?: boolean): string;
}
declare namespace Range {
export {
getOperator,
formatRight,
formatLeft,
formatRange,
getRangeValue,
RangeValue,
RangeValueCallback,
};
}
type RangeValue = [number, boolean];
type RangeValueCallback = (rangeValue: [number, boolean]) => boolean;
41 changes: 41 additions & 0 deletions declarations/validate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export default validate;
export type JSONSchema4 = import('json-schema').JSONSchema4;
export type JSONSchema6 = import('json-schema').JSONSchema6;
export type JSONSchema7 = import('json-schema').JSONSchema7;
export type ErrorObject = Ajv.ErrorObject;
export type Schema =
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7;
export type SchemaUtilErrorObject = Ajv.ErrorObject & {
children?: Ajv.ErrorObject[] | undefined;
};
export type PostFormatter = (
formattedError: string,
error: Ajv.ErrorObject & {
children?: Ajv.ErrorObject[] | undefined;
}
) => string;
export type ValidationErrorConfiguration = {
name?: string | undefined;
baseDataPath?: string | undefined;
postFormatter?: PostFormatter | undefined;
};
/**
* @param {Schema} schema
* @param {Array<object> | object} options
* @param {ValidationErrorConfiguration=} configuration
* @returns {void}
*/
declare function validate(
schema:
| import('json-schema').JSONSchema4
| import('json-schema').JSONSchema6
| import('json-schema').JSONSchema7,
options: any,
configuration?: ValidationErrorConfiguration | undefined
): void;
declare namespace validate {
export { _default as ValidationError, _default as ValidateError };
}
import Ajv from 'ajv';
Loading

0 comments on commit 7a2b2df

Please sign in to comment.