Skip to content
Permalink
Browse files

New: Add `schema-validation` and `json-parser` to utils

It was in `hint` where it does not make too much sense. While `hint`
will continue to `export` the types and functions so it is not a
breaking, some references had to be updated because of bundling among
other things.
  • Loading branch information...
molant committed May 6, 2019
1 parent 7514bbf commit a17d29aac9bcd31fe640547efc8f2e785eaea5a4
Showing with 63 additions and 57 deletions.
  1. +1 βˆ’1 packages/extension-browser/src/devtools/views/pages/results/problem.tsx
  2. +0 βˆ’1 packages/hint/package.json
  3. +1 βˆ’1 packages/hint/src/lib/analyzer.ts
  4. +1 βˆ’2 packages/hint/src/lib/cli/analyze.ts
  5. +2 βˆ’2 packages/hint/src/lib/config/config-hints.ts
  6. +2 βˆ’2 packages/hint/src/lib/config/config-validator.ts
  7. +1 βˆ’1 packages/hint/src/lib/config/normalize-hints.ts
  8. +4 βˆ’2 packages/hint/src/lib/engine.ts
  9. +1 βˆ’11 packages/hint/src/lib/enums/category.ts
  10. +1 βˆ’1 packages/hint/src/lib/enums/index.ts
  11. +2 βˆ’3 packages/hint/src/lib/hint-context.ts
  12. +4 βˆ’4 packages/hint/src/lib/types.ts
  13. +1 βˆ’1 packages/hint/src/lib/types/analyzer.ts
  14. +1 βˆ’1 packages/hint/src/lib/types/events.ts
  15. +1 βˆ’1 packages/hint/src/lib/types/formatters.ts
  16. +1 βˆ’1 packages/hint/src/lib/types/hint-meta.ts
  17. +2 βˆ’2 packages/hint/src/lib/utils/index.ts
  18. +1 βˆ’1 packages/hint/tests/lib/analyzer.ts
  19. +1 βˆ’2 packages/hint/tests/lib/cli/analyze.ts
  20. +3 βˆ’2 packages/hint/tests/lib/engine.ts
  21. +1 βˆ’1 packages/hint/tests/lib/hint-context.ts
  22. +3 βˆ’3 packages/parser-manifest/src/parser.ts
  23. +1 βˆ’1 packages/parser-manifest/src/types.ts
  24. +3 βˆ’1 packages/parser-package-json/src/parser.ts
  25. +2 βˆ’1 packages/parser-typescript-config/src/parser.ts
  26. +1 βˆ’0 packages/utils/package.json
  27. +2 βˆ’1 packages/{hint/src/lib/utils β†’ utils/src}/json-parser.ts
  28. +1 βˆ’1 packages/{hint/src/lib/types β†’ utils/src/schema-validation}/schema-validation-result.ts
  29. +2 βˆ’1 packages/{hint/src/lib/utils β†’ utils/src/schema-validation}/schema-validator.ts
  30. +11 βˆ’0 packages/utils/src/types/category.ts
  31. +1 βˆ’1 packages/{hint/src/lib β†’ utils/src}/types/json-parser.ts
  32. +2 βˆ’2 packages/{hint/src/lib β†’ utils/src}/types/problems.ts
  33. +2 βˆ’2 packages/{hint/tests/lib/utils β†’ utils/tests/schema-validation}/schema-validator.ts
@@ -5,7 +5,7 @@ import css from 'react-syntax-highlighter/dist/esm/languages/hljs/css';
import javascript from 'react-syntax-highlighter/dist/esm/languages/hljs/javascript';
import xml from 'react-syntax-highlighter/dist/esm/languages/hljs/xml';

import { Problem as ProblemData } from 'hint/dist/src/lib/types/problems';
import { Problem as ProblemData } from '@hint/utils/dist/src/types/problems';

import { browser } from '../../../../shared/globals';

@@ -22,7 +22,6 @@
"globby": "^9.2.0",
"is-ci": "^2.0.0",
"is-svg": "^4.1.0",
"jsonc-parser": "^2.1.0",
"lodash": "^4.17.11",
"optionator": "^0.8.2",
"ora": "^3.4.0",
@@ -9,7 +9,6 @@ import {
FormatterOptions,
HintResources,
IFormatter,
Problem,
Target,
UserConfig,
Endpoint,
@@ -21,6 +20,7 @@ import { IFormatterConstructor } from './types/formatters';
import { loadResources } from './utils/resource-loader';

import { fs, logger, misc } from '@hint/utils';
import { Problem } from '@hint/utils/dist/src/types/problems';

const { cutString } = misc;
const { cwd, isFile } = fs;
@@ -13,11 +13,10 @@ import {
CLIOptions,
CreateAnalyzerOptions,
HintResources,
Problem,
Severity,
UserConfig
} from '../types';
import { loadHintPackage } from '../utils/packages/load-hint-package';
import { Problem, Severity } from '@hint/utils/dist/src/types/problems';

import { createAnalyzer, getUserConfig } from '../';
import { Analyzer } from '../analyzer';
@@ -10,9 +10,9 @@

import { debug as d } from '@hint/utils/dist/src/debug';

import { validate as schemaValidator } from '../utils/schema-validator';
import { validate as schemaValidator } from '@hint/utils/dist/src/schema-validation/schema-validator';
import { HintMetadata, HintConfig } from '../types';
import { Severity } from '../types/problems';
import { Severity } from '@hint/utils/dist/src/types/problems';

const debug = d(__filename);

@@ -11,9 +11,9 @@

import { debug as d, logger } from '@hint/utils';

import { validate } from '../utils/schema-validator';
import { validate } from '@hint/utils/dist/src/schema-validation/schema-validator';
import { UserConfig } from '../types';
import { SchemaValidationResult, GroupedError } from '../types/schema-validation-result';
import { SchemaValidationResult, GroupedError } from '@hint/utils/dist/src/schema-validation/schema-validation-result';

const debug = d(__filename);
const schema = require('./config-schema.json');
@@ -1,5 +1,5 @@
import { HintsConfigObject, HintSeverity } from '../types';
import { Severity } from '../types/problems';
import { Severity } from '@hint/utils/dist/src/types/problems';

/**
* @fileoverview Used for normalizing hints that are passed as configuration.
@@ -33,13 +33,15 @@ import {
IHintConstructor,
NetworkData,
Parser,
Problem,
Severity,
StringKeyOf
} from './types';
import { HintContext } from './hint-context';
import { HintScope } from './enums/hint-scope';
import { Configuration } from './config';
import {
Problem,
Severity
} from '@hint/utils/dist/src/types/problems';

const debug: debug.IDebugger = d(__filename);

@@ -1,11 +1 @@
export enum Category {
accessibility = 'accessibility',
development = 'development',
compatibility = 'compatibility',
interoperability = 'interoperability', // Deprecated, to be removed in the next major release
other = 'other',
pwa = 'pwa',
performance = 'performance',
pitfalls = 'pitfalls',
security = 'security'
}
export * from '@hint/utils/dist/src/types/category';
@@ -1,4 +1,4 @@
export * from './category';
export * from '@hint/utils/dist/src/types/category';
export * from './error-status';
export * from './hint-scope';
export * from './resource-type';
@@ -13,11 +13,10 @@ import {
Events,
HintMetadata,
NetworkData,
ProblemLocation,
Severity,
StringKeyOf
} from './types';
import { Category } from './enums/category';
import { ProblemLocation, Severity } from '@hint/utils/dist/src/types/problems';
import { Category } from '@hint/utils/dist/src/types/category';

export type ReportOptions = {
/** The source code to display (defaults to the `outerHTML` of `element`). */
@@ -2,17 +2,17 @@ import { IFormatterConstructor } from './types/formatters';
import { IConnectorConstructor } from './types/connector';
import { IParserConstructor } from './types/parser';
import { IHintConstructor } from './types/hints';
import { Severity } from './types/problems';
import { Severity } from '@hint/utils/dist/src/types/problems';

export * from './types/connector';
export * from './types/events';
export * from './types/formatters';
export * from './types/json-parser';
export * from '@hint/utils/dist/src/types/json-parser';
export * from './types/network';
export * from './types/problems';
export * from '@hint/utils/dist/src/types/problems';
export * from './types/hints';
export * from './types/parser';
export * from './types/schema-validation-result';
export * from '@hint/utils/dist/src/schema-validation/schema-validation-result';
export * from './types/analyzer';
export * from './types/analyzer-error';

@@ -1,4 +1,4 @@
import { Problem } from './problems';
import { Problem } from '@hint/utils/dist/src/types/problems';

export type CreateAnalyzerOptions = {
watch?: boolean;
@@ -1,7 +1,7 @@
import { HTMLElement } from '@hint/utils/dist/src/dom/html';
import { Event } from './event';
import { ElementEvents } from './element-events';
import { Problem } from './problems';
import { Problem } from '@hint/utils/dist/src/types/problems';
import { Request, Response } from './network';

export * from './event';
@@ -1,4 +1,4 @@
import { Problem } from './problems';
import { Problem } from '@hint/utils/dist/src/types/problems';
import { UserConfig, HintResources } from '../types';

export type FormatterOptions = {
@@ -1,4 +1,4 @@
import { Category } from '../enums/category';
import { Category } from '@hint/utils/dist/src/types/category';
import { HintScope } from '../enums/hint-scope';

export type MetadataDocs = {
@@ -1,7 +1,7 @@
import * as packagesUtils from './packages';
import * as resourceLoaderUtils from './resource-loader';
import * as schemaValidatorUtils from './schema-validator';
import * as jsonParserUtils from './json-parser';
import * as schemaValidatorUtils from '@hint/utils/dist/src/schema-validation/schema-validator';
import * as jsonParserUtils from '@hint/utils/dist/src/json-parser';

export * from './resource-loader';

@@ -9,11 +9,11 @@ import {
ConnectorConfig,
HintResources,
IFetchOptions,
Problem,
IFormatter,
UserConfig
} from '../../src/lib/types';
import { AnalyzerErrorStatus } from '../../src/lib/enums/error-status';
import { Problem } from '@hint/utils/dist/src/types/problems';

type Logger = {
warn: () => void;
@@ -3,6 +3,7 @@ import * as sinon from 'sinon';
import anyTest, { TestInterface, ExecutionContext } from 'ava';

import * as utils from '@hint/utils';
import { Problem, Severity } from '@hint/utils/dist/src/types/problems';

import {
AnalyzeOptions,
@@ -11,8 +12,6 @@ import {
CLIOptions,
CreateAnalyzerOptions,
Endpoint,
Problem,
Severity,
UserConfig
} from '../../../src/lib/types';
import { AnalyzerErrorStatus } from '../../../src/lib/enums/error-status';
@@ -9,8 +9,9 @@ import { misc } from '@hint/utils';

import { HintScope } from '../../src/lib/enums/hint-scope';
import { Configuration } from '../../src/lib/config';
import { HintResources, IFormatter, IConnector, IFetchOptions, IHint, HintMetadata, Problem } from '../../src/lib/types';
import { Category } from '../../src/lib/enums/category';
import { HintResources, IFormatter, IConnector, IFetchOptions, IHint, HintMetadata } from '../../src/lib/types';
import { Problem } from '@hint/utils/dist/src/types/problems';
import { Category } from '@hint/utils/dist/src/types/category';
import { HintContext } from '../../src/lib/hint-context';

const { delay } = misc;
@@ -1,7 +1,7 @@
import test from 'ava';
import * as sinon from 'sinon';

import { Severity } from '../../src/lib/types';
import { Severity } from '@hint/utils/dist/src/types/problems';

const engine = {

@@ -3,7 +3,6 @@ import { URL } from 'url';
import {
ElementFound,
FetchEnd,
IJSONResult,
NetworkData,
Parser,
SchemaValidationResult
@@ -14,8 +13,9 @@ import { isHTTP } from '@hint/utils/dist/src/network/is-http';
import { isHTTPS } from '@hint/utils/dist/src/network/is-https';
import { ManifestEvents } from './types';
import { Engine } from 'hint/dist/src/lib/engine';
import { parseJSON } from 'hint/dist/src/lib/utils/json-parser';
import { validate } from 'hint/dist/src/lib/utils/schema-validator';
import { parseJSON } from '@hint/utils/dist/src/json-parser';
import { IJSONResult } from '@hint/utils/dist/src/types/json-parser';
import { validate } from '@hint/utils/dist/src/schema-validation/schema-validator';

export * from './types';

@@ -1,4 +1,4 @@
import { FetchEnd, FetchError, FetchStart, ISchemaValidationError, IJSONLocationFunction, Event, ErrorEvent, Events, GroupedError } from 'hint/dist/src/lib/types';
import { FetchEnd, FetchError, FetchStart, IJSONLocationFunction, ISchemaValidationError, Event, ErrorEvent, Events, GroupedError } from 'hint';

/* eslint-disable camelcase */

@@ -1,11 +1,13 @@
import * as path from 'path';

import { fs } from '@hint/utils';
import { Engine, FetchEnd, IJSONResult, Parser, SchemaValidationResult, utils } from 'hint';
import { Engine, FetchEnd, Parser, SchemaValidationResult, utils } from 'hint';

import { PackageJsonEvents } from './types';
import { IJsonSchemaForNpmPackageJsonFiles } from './schema';

import { IJSONResult } from '@hint/utils/dist/src/types/json-parser';

export * from './types';

const { jsonParser: { parseJSON }, schemaValidator: { validate } } = utils;
@@ -5,7 +5,8 @@ import { promisify } from 'util';
import { cloneDeep } from 'lodash';

import { debug as d, fs as fsUtils, network } from '@hint/utils';
import { Engine, FetchEnd, IJSONResult, Parser, SchemaValidationResult, utils } from 'hint';
import { IJSONResult } from '@hint/utils/dist/src/types/json-parser';
import { Engine, FetchEnd, Parser, SchemaValidationResult, utils } from 'hint';

import { TypeScriptConfig, TypeScriptConfigEvents } from './types';

@@ -13,6 +13,7 @@
"debug": "^4.1.1",
"file-url": "^3.0.0",
"is-wsl": "^2.0.0",
"jsonc-parser": "^2.1.0",
"lodash": "^4.17.11",
"npm-registry-fetch": "^3.9.0",
"parse5": "^5.1.0",
@@ -1,5 +1,6 @@
import { findNodeAtLocation, Node, parse, parseTree, Segment } from 'jsonc-parser';
import { IJSONLocationOptions, IJSONResult, ProblemLocation } from '../types';
import { IJSONLocationOptions, IJSONResult } from './types/json-parser';
import { ProblemLocation} from './types/problem-location';

const rxIsNumber = /^[0-9]+$/;

@@ -1,5 +1,5 @@
import * as ajv from 'ajv';
import { ProblemLocation } from './problems';
import { ProblemLocation } from '../types/problems';

export interface ISchemaValidationError extends ajv.ErrorObject {
location?: ProblemLocation;
@@ -5,7 +5,8 @@ import groupBy = require('lodash/groupBy');
import reduce = require('lodash/reduce');
import without = require('lodash/without');

import { GroupedError, IJSONLocationFunction, ISchemaValidationError, SchemaValidationResult } from '../types';
import { GroupedError, ISchemaValidationError, SchemaValidationResult } from './schema-validation-result';
import { IJSONLocationFunction } from '../types/json-parser';

/*
* If we want to use the ajv types in TypeScript, we need to import
@@ -0,0 +1,11 @@
export enum Category {
accessibility = 'accessibility',
development = 'development',
compatibility = 'compatibility',
interoperability = 'interoperability', // Deprecated, to be removed in the next major release
other = 'other',
pwa = 'pwa',
performance = 'performance',
pitfalls = 'pitfalls',
security = 'security'
}
@@ -1,4 +1,4 @@
import { ProblemLocation } from './problems';
import { ProblemLocation } from './problem-location';

export interface IJSONLocationOptions {
at?: 'name' | 'value';
@@ -1,5 +1,5 @@
import { ProblemLocation } from '@hint/utils';
import { Category } from '../enums/category';
import { ProblemLocation } from './problem-location';
import { Category } from './category';

export { ProblemLocation };

@@ -1,7 +1,7 @@
import test from 'ava';

import { SchemaValidationResult } from '../../../src/lib/types';
import { validate } from '../../../src/lib/utils/schema-validator';
import { SchemaValidationResult } from '../../src/schema-validation/schema-validation-result';
import { validate } from '../../src/schema-validation/schema-validator';

const baseSchema = {
$schema: 'http://json-schema.org/draft-04/schema#',

0 comments on commit a17d29a

Please sign in to comment.
You can’t perform that action at this time.