Skip to content
Permalink
Browse files

Chore: Update packages to use @hint/utils-json

  • Loading branch information
sarvaje committed Nov 5, 2019
1 parent 99df4ee commit 12f5cbadb989039c352a913629338b37419e749d
Showing with 78 additions and 55 deletions.
  1. +1 βˆ’0 packages/hint-manifest-app-name/package.json
  2. +4 βˆ’3 packages/hint-manifest-app-name/src/hint.ts
  3. +1 βˆ’0 packages/hint-manifest-app-name/tsconfig.json
  4. +1 βˆ’0 packages/hint-manifest-icons/package.json
  5. +6 βˆ’5 packages/hint-manifest-icons/src/hint.ts
  6. +1 βˆ’0 packages/hint-manifest-icons/tsconfig.json
  7. +1 βˆ’0 packages/hint-manifest-is-valid/package.json
  8. +4 βˆ’6 packages/hint-manifest-is-valid/src/hint.ts
  9. +1 βˆ’0 packages/hint-manifest-is-valid/tsconfig.json
  10. +1 βˆ’0 packages/hint-typescript-config/package.json
  11. +3 βˆ’2 packages/hint-typescript-config/src/helpers/config-checker.ts
  12. +1 βˆ’0 packages/hint-typescript-config/tsconfig.json
  13. +1 βˆ’0 packages/hint/package.json
  14. +1 βˆ’1 packages/hint/src/lib/config.ts
  15. +3 βˆ’2 packages/hint/src/lib/config/config-hints.ts
  16. +3 βˆ’2 packages/hint/src/lib/config/config-validator.ts
  17. +1 βˆ’0 packages/hint/tsconfig.json
  18. +1 βˆ’0 packages/parser-babel-config/package.json
  19. +9 βˆ’4 packages/parser-babel-config/src/parser.ts
  20. +3 βˆ’3 packages/parser-babel-config/src/types.ts
  21. +1 βˆ’0 packages/parser-babel-config/tsconfig.json
  22. +1 βˆ’0 packages/parser-manifest/package.json
  23. +4 βˆ’5 packages/parser-manifest/src/parser.ts
  24. +3 βˆ’2 packages/parser-manifest/src/types.ts
  25. +5 βˆ’3 packages/parser-manifest/tests/tests.ts
  26. +1 βˆ’0 packages/parser-manifest/tsconfig.json
  27. +1 βˆ’1 packages/parser-package-json/package.json
  28. +2 βˆ’4 packages/parser-package-json/src/parser.ts
  29. +3 βˆ’2 packages/parser-package-json/src/types.ts
  30. +1 βˆ’1 packages/parser-package-json/tsconfig.json
  31. +1 βˆ’1 packages/parser-typescript-config/package.json
  32. +3 βˆ’4 packages/parser-typescript-config/src/parser.ts
  33. +4 βˆ’3 packages/parser-typescript-config/src/types.ts
  34. +1 βˆ’1 packages/parser-typescript-config/tsconfig.json
@@ -16,6 +16,7 @@
"devDependencies": {
"@hint/parser-manifest": "^2.2.12",
"@hint/utils": "^6.1.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-tests-helpers": "^5.1.0",
"@types/node": "^12.7.5",
"@typescript-eslint/eslint-plugin": "^1.13.0",
@@ -11,7 +11,8 @@

import { ucs2 } from 'punycode';

import { IHint, IJSONLocationFunction } from 'hint/dist/src/lib/types';
import { IHint } from 'hint/dist/src/lib/types';
import { JSONLocationFunction } from '@hint/utils-json/dist/src/types';
import { ManifestEvents, ManifestParsed } from '@hint/parser-manifest';
import { HintContext } from 'hint/dist/src/lib/hint-context';

@@ -36,7 +37,7 @@ export default class ManifestAppNameHint implements IHint {
}
};

const checkIfPropertyValueIsNotEmpty = (resource: string, content: string | undefined, propertyName: string, getLocation: IJSONLocationFunction) => {
const checkIfPropertyValueIsNotEmpty = (resource: string, content: string | undefined, propertyName: string, getLocation: JSONLocationFunction) => {
if (typeof content === 'string' && (content.trim() === '')) {
const message = getMessage('shouldHaveNonEmptyProperty', context.language, propertyName);
const location = getLocation(propertyName, { at: 'value' });
@@ -45,7 +46,7 @@ export default class ManifestAppNameHint implements IHint {
}
};

const checkIfPropertyValueIsUnderLimit = (resource: string, content: string | undefined, propertyName: string, shortNameLengthLimit: number, getLocation: IJSONLocationFunction) => {
const checkIfPropertyValueIsUnderLimit = (resource: string, content: string | undefined, propertyName: string, shortNameLengthLimit: number, getLocation: JSONLocationFunction) => {
if (content && (ucs2.decode(content).length > shortNameLengthLimit)) {
const message = getMessage('shouldHavePropertyShort', context.language, [propertyName, shortNameLengthLimit.toString()]);
const location = getLocation(propertyName, { at: 'value' });
@@ -17,6 +17,7 @@
{ "path": "../parser-manifest" },
{ "path": "../utils" },
{ "path": "../utils-i18n" },
{ "path": "../utils-json" },
{ "path": "../utils-tests-helpers" },
{ "path": "../utils-types" }
]
@@ -18,6 +18,7 @@
},
"devDependencies": {
"@hint/parser-manifest": "^2.2.12",
"@hint/utils-json": "^1.0.0",
"@hint/utils-tests-helpers": "^5.1.0",
"@types/node": "^12.7.5",
"@typescript-eslint/eslint-plugin": "^1.13.0",
@@ -4,7 +4,8 @@
import { URL } from 'url';
import { imageSize as getImageData } from 'image-size';
import imageType from 'image-type';
import { IHint, NetworkData, HintContext, IJSONLocationFunction } from 'hint';
import { IHint, NetworkData, HintContext } from 'hint';
import { JSONLocationFunction } from '@hint/utils-json';
import { ManifestEvents, ManifestParsed, ManifestImageResource } from '@hint/parser-manifest';
import { ProblemLocation } from '@hint/utils-types';
import { debug as d } from '@hint/utils-debug';
@@ -29,7 +30,7 @@ export default class ManifestIconHint implements IHint {
* See if the `icon` file actually
* exists and is accessible.
*/
const iconExists = async (iconPath: string, resource: string, index: number, getLocation: IJSONLocationFunction): Promise<{ iconRawData: Buffer | null; mediaType: string } | null> => {
const iconExists = async (iconPath: string, resource: string, index: number, getLocation: JSONLocationFunction): Promise<{ iconRawData: Buffer | null; mediaType: string } | null> => {
let networkData: NetworkData;

const iconSrcLocation = getLocation(`icons[${index}].src`, { at: 'value' });
@@ -65,7 +66,7 @@ export default class ManifestIconHint implements IHint {
* @param rawContent raw datastream
* @param iconPath icon resource path
*/
const validateImageType = (icon: ManifestImageResource, mediaType: string, rawContent: Buffer | null, resource: string, index: number, getLocation: IJSONLocationFunction): boolean => {
const validateImageType = (icon: ManifestImageResource, mediaType: string, rawContent: Buffer | null, resource: string, index: number, getLocation: JSONLocationFunction): boolean => {
const allowedTypes = ['png', 'jpg'];
const iconTypeLocation = getLocation(`icons[${index}].type`, { at: 'value' });
const { src, type: iconType } = icon;
@@ -123,7 +124,7 @@ export default class ManifestIconHint implements IHint {
* @param iconRawData
* @param iconPath full path to the icon file
*/
const validateSizes = (iconSizes: string | undefined, iconRawData: Buffer | null, resource: string, index: number, getLocation: IJSONLocationFunction): boolean => {
const validateSizes = (iconSizes: string | undefined, iconRawData: Buffer | null, resource: string, index: number, getLocation: JSONLocationFunction): boolean => {
const iconSizelocation = getLocation(`icons[${index}].sizes`, { at: 'value' });

if (!iconSizes) {
@@ -189,7 +190,7 @@ export default class ManifestIconHint implements IHint {
* @param icons array of the icons properties
* @param hostnameWithProtocol
*/
const validateIcons = async (icons: ManifestImageResource[], hostnameWithProtocol: string, resource: string, getLocation: IJSONLocationFunction): Promise<string[]> => {
const validateIcons = async (icons: ManifestImageResource[], hostnameWithProtocol: string, resource: string, getLocation: JSONLocationFunction): Promise<string[]> => {
const validSizes: string[] = [];

for (let index = 0; index < icons.length; index++) {
@@ -18,6 +18,7 @@
{ "path": "../utils" },
{ "path": "../utils-debug" },
{ "path": "../utils-i18n" },
{ "path": "../utils-json" },
{ "path": "../utils-tests-helpers" },
{ "path": "../utils-types" }
]
@@ -18,6 +18,7 @@
"description": "hint that that checks if the web app manifest file is valid",
"devDependencies": {
"@hint/parser-manifest": "^2.2.12",
"@hint/utils-json": "^1.0.0",
"@hint/utils-tests-helpers": "^5.1.0",
"@types/color-string": "^1.5.0",
"@types/node": "^12.7.5",
@@ -11,10 +11,8 @@
import { parse as bcp47 } from 'bcp47';
import { get as parseColor, ColorDescriptor } from 'color-string';

import {
IHint,
IJSONLocationFunction
} from 'hint/dist/src/lib/types';
import { IHint } from 'hint/dist/src/lib/types';
import { JSONLocationFunction } from '@hint/utils-json/dist/src/types';
import { isSupported } from '@hint/utils-compat-data';
import { normalizeString } from '@hint/utils/dist/src/misc/normalize-string';
import {
@@ -72,7 +70,7 @@ export default class ManifestIsValidHint implements IHint {
color.model === 'hwb';
};

const checkColors = (resource: string, manifest: Manifest, getLocation: IJSONLocationFunction) => {
const checkColors = (resource: string, manifest: Manifest, getLocation: JSONLocationFunction) => {
const colorProperties = [
'background_color',
'theme_color'
@@ -106,7 +104,7 @@ export default class ManifestIsValidHint implements IHint {
}
};

const checkLang = (resource: string, manifest: Manifest, getLocation: IJSONLocationFunction) => {
const checkLang = (resource: string, manifest: Manifest, getLocation: JSONLocationFunction) => {
const lang = manifest.lang;

if (lang && !bcp47(lang)) {
@@ -18,6 +18,7 @@
{ "path": "../utils" },
{ "path": "../utils-compat-data" },
{ "path": "../utils-i18n" },
{ "path": "../utils-json" },
{ "path": "../utils-tests-helpers" },
{ "path": "../utils-types" }
]
@@ -16,6 +16,7 @@
"description": "hint that that checks if the TypeScript configuration is valid.",
"devDependencies": {
"@hint/parser-typescript-config": "^2.4.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-tests-helpers": "^5.1.0",
"@types/node": "^12.7.5",
"@typescript-eslint/eslint-plugin": "^1.13.0",
@@ -1,5 +1,6 @@
import { TypeScriptConfigParse, TypeScriptConfig } from '@hint/parser-typescript-config';
import { HintContext, IJSONLocationFunction } from 'hint';
import { HintContext } from 'hint';
import { JSONLocationFunction } from '@hint/utils-json/dist/src/types';

import { getMessage, MessageName } from '../i18n.import';

@@ -15,7 +16,7 @@ const findValue = (property: string, config: TypeScriptConfig) => {
return current;
};

const findLocation = (propertyPath: string, mergedConfig: TypeScriptConfig, originalConfig: TypeScriptConfig, getLocation: IJSONLocationFunction) => {
const findLocation = (propertyPath: string, mergedConfig: TypeScriptConfig, originalConfig: TypeScriptConfig, getLocation: JSONLocationFunction) => {
const valueInOriginal = findValue(propertyPath, originalConfig);

if (typeof valueInOriginal !== 'undefined') {
@@ -18,6 +18,7 @@
{ "path": "../utils" },
{ "path": "../utils-debug" },
{ "path": "../utils-i18n" },
{ "path": "../utils-json" },
{ "path": "../utils-tests-helpers" },
{ "path": "../utils-types" }
]
@@ -12,6 +12,7 @@
"@hint/utils": "^6.1.0",
"@hint/utils-debug": "^1.0.0",
"@hint/utils-fs": "^1.0.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-network": "^1.0.0",
"@hint/utils-types": "^1.0.0",
"boxen": "^4.1.0",
@@ -26,7 +26,7 @@ import {
loadJSONFile
} from '@hint/utils-fs';
import { debug as d } from '@hint/utils-debug';
import { validate as schemaValidator } from '@hint/utils/dist/src/schema-validation/schema-validator';
import { validate as schemaValidator } from '@hint/utils-json/dist/src/schema-validator';

import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types';
import { validateConfig } from './config/config-validator';
@@ -10,10 +10,11 @@

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

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

import { HintMetadata, HintConfig } from '../types';

const debug = d(__filename);

/*
@@ -12,9 +12,10 @@
import { logger } from '@hint/utils';
import { debug as d } from '@hint/utils-debug';

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

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

const debug = d(__filename);
const schema = require('./config-schema.json');
@@ -17,6 +17,7 @@
{ "path": "../utils-debug" },
{ "path": "../utils-dom" },
{ "path": "../utils-fs" },
{ "path": "../utils-json" },
{ "path": "../utils-network" },
{ "path": "../utils-types" }
]
@@ -10,6 +10,7 @@
"description": "webhint parser to analyze babel config",
"dependencies": {
"@hint/utils-fs": "^1.0.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-network": "^1.0.0",
"lodash": "^4.17.15"
},
@@ -2,15 +2,20 @@ import * as path from 'path';

import cloneDeep = require('lodash/cloneDeep');

import { Engine, FetchEnd, IJSONResult, Parser, SchemaValidationResult, utils } from 'hint';
import { Engine, FetchEnd, Parser } from 'hint';
import {
finalConfig as calculateFinalConfig,
IJSONResult,
parseJSON,
SchemaValidationResult,
validate
} from '@hint/utils-json';
import { loadJSONFile } from '@hint/utils-fs';

import { BabelConfig, BabelConfigEvents } from './types';

export * from './types';

const { jsonParser: { parseJSON }, schemaValidator: { validate } } = utils;

export default class BabelConfigParser extends Parser<BabelConfigEvents> {
private schema: any;

@@ -71,7 +76,7 @@ export default class BabelConfigParser extends Parser<BabelConfigEvents> {

const originalConfig: BabelConfig = cloneDeep(config);

const finalConfig = await this.finalConfig<BabelConfig>(config, resource);
const finalConfig = calculateFinalConfig<BabelConfig>(config, resource);

if (finalConfig instanceof Error) {
await this.engine.emitAsync(`parse::error::babel-config::extends`,
@@ -1,5 +1,5 @@
import { Event, ErrorEvent, Events } from 'hint/dist/src/lib/types/events';
import { IJSONLocationFunction, ISchemaValidationError, GroupedError } from 'hint/dist/src/lib/types';
import { JSONLocationFunction, ISchemaValidationError, GroupedError } from '@hint/utils-json/dist/src/types';

export type BabelConfig = {
ast: boolean;
@@ -39,7 +39,7 @@ export type BabelConfigParsed = Event & {
/** The babel config parsed */
config: BabelConfig;
/** Find the location of a path within the original JSON source */
getLocation: IJSONLocationFunction;
getLocation: JSONLocationFunction;
/** The original babel config */
originalConfig: BabelConfig;
};
@@ -51,7 +51,7 @@ export type BabelConfigInvalidSchema = ErrorEvent & {
};

export type BabelConfigExtendsError = ErrorEvent & {
getLocation: IJSONLocationFunction;
getLocation: JSONLocationFunction;
}

export type BabelConfigEvents = Events & {
@@ -15,6 +15,7 @@
"references": [
{ "path": "../hint" },
{ "path": "../utils-fs" },
{ "path": "../utils-json" },
{ "path": "../utils-network" }
]
}
@@ -9,6 +9,7 @@
},
"dependencies": {
"@hint/utils": "^6.1.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-network": "^1.0.0",
"@hint/utils-types": "^1.0.0"
},
@@ -2,18 +2,17 @@ import {
ElementFound,
FetchEnd,
NetworkData,
Parser,
SchemaValidationResult
Parser
} from 'hint/dist/src/lib/types';

import { normalizeString } from '@hint/utils/dist/src/misc/normalize-string';
import { isHTTP } from '@hint/utils-network/dist/src/is-http';
import { isHTTPS } from '@hint/utils-network/dist/src/is-https';
import { ManifestEvents } from './types';
import { Engine } from 'hint/dist/src/lib/engine';
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';
import { parseJSON } from '@hint/utils-json/dist/src/parse-json';
import { IJSONResult, SchemaValidationResult } from '@hint/utils-json/dist/src/types';
import { validate } from '@hint/utils-json/dist/src/schema-validator';

export * from './types';

@@ -1,4 +1,5 @@
import { FetchEnd, FetchError, FetchStart, IJSONLocationFunction, ISchemaValidationError, Event, ErrorEvent, Events, GroupedError } from 'hint';
import { FetchEnd, FetchError, FetchStart, Event, ErrorEvent, Events } from 'hint';
import { JSONLocationFunction, ISchemaValidationError, GroupedError } from '@hint/utils-json';

/* eslint-disable camelcase */

@@ -154,7 +155,7 @@ export type ManifestInvalidSchema = ErrorEvent & {

export type ManifestParsed = Event & {
/** Find the location of a path within the original JSON source */
getLocation: IJSONLocationFunction;
getLocation: JSONLocationFunction;
/** The content of manifest parsed */
parsedContent: Manifest;
};
@@ -4,10 +4,12 @@ import test, { ExecutionContext } from 'ava';
import { EventEmitter2 } from 'eventemitter2';
import * as sinon from 'sinon';

import Parser from '../src/parser';
import { Manifest, ManifestInvalidJSON, ManifestInvalidSchema, ManifestParsed, ManifestEvents } from '../src/types';
import { Engine, ISchemaValidationError, NetworkData, ElementFound } from 'hint';
import { Engine, NetworkData, ElementFound } from 'hint';
import { ProblemLocation } from '@hint/utils-types';
import { ISchemaValidationError } from '@hint/utils-json';

import { Manifest, ManifestInvalidJSON, ManifestInvalidSchema, ManifestParsed, ManifestEvents } from '../src/types';
import Parser from '../src/parser';

const elementLinkEventName = 'element::link';
const getElementLinkEventValue = (relAttribute: string = 'manifest', hrefAttribute: string = 'site.webmanifest') => {
@@ -15,6 +15,7 @@
"references": [
{ "path": "../hint" },
{ "path": "../utils" },
{ "path": "../utils-json" },
{ "path": "../utils-network" },
{ "path": "../utils-types" }
]
@@ -9,7 +9,7 @@
},
"description": "webhint parser to analyze the package.json file",
"dependencies": {
"@hint/utils": "^6.1.0",
"@hint/utils-json": "^1.0.0",
"@hint/utils-fs": "^1.0.0",
"@hint/utils-network": "^1.0.0"
},

0 comments on commit 12f5cba

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