Permalink
Browse files

New: Allow hint metadata to be imported separately

Extracts existing `HintMetadata` objects into dedicated files and
adds a new `name` field to the `docs` property.

Allows hint metadata to be imported and bundled separately
from the implementation of a hint, reducing bundle size for
documentation scenarios.

Also updates all hint names for consistency both in the new
metadata and in the title of each associated `README`.
  • Loading branch information...
antross authored and molant committed Nov 20, 2018
1 parent f3d1fab commit d40a0abad01c750174fbb5e41a6168feae5d4fea
Showing with 1,318 additions and 902 deletions.
  1. +1 βˆ’1 packages/hint-amp-validator/README.md
  2. +4 βˆ’16 packages/hint-amp-validator/src/hint.ts
  3. +20 βˆ’0 packages/hint-amp-validator/src/meta.ts
  4. +1 βˆ’1 packages/hint-apple-touch-icons/README.md
  5. +4 βˆ’12 packages/hint-apple-touch-icons/src/hint.ts
  6. +16 βˆ’0 packages/hint-apple-touch-icons/src/meta.ts
  7. +1 βˆ’1 packages/hint-axe/README.md
  8. +4 βˆ’43 packages/hint-axe/src/hint.ts
  9. +47 βˆ’0 packages/hint-axe/src/meta.ts
  10. +1 βˆ’1 packages/hint-babel-config/docs/is-valid.md
  11. +4 βˆ’12 packages/hint-babel-config/src/is-valid.ts
  12. +5 βˆ’0 packages/hint-babel-config/src/meta.ts
  13. +16 βˆ’0 packages/hint-babel-config/src/meta/is-valid.ts
  14. +1 βˆ’1 packages/hint-content-type/README.md
  15. +4 βˆ’16 packages/hint-content-type/src/hint.ts
  16. +20 βˆ’0 packages/hint-content-type/src/meta.ts
  17. +1 βˆ’1 packages/hint-disown-opener/README.md
  18. +4 βˆ’16 packages/hint-disown-opener/src/hint.ts
  19. +20 βˆ’0 packages/hint-disown-opener/src/meta.ts
  20. +1 βˆ’1 packages/hint-doctype/README.md
  21. +4 βˆ’12 packages/hint-doctype/src/hint.ts
  22. +16 βˆ’0 packages/hint-doctype/src/meta.ts
  23. +1 βˆ’1 packages/hint-highest-available-document-mode/README.md
  24. +4 βˆ’16 packages/hint-highest-available-document-mode/src/hint.ts
  25. +20 βˆ’0 packages/hint-highest-available-document-mode/src/meta.ts
  26. +1 βˆ’1 packages/hint-html-checker/README.md
  27. +4 βˆ’28 packages/hint-html-checker/src/hint.ts
  28. +32 βˆ’0 packages/hint-html-checker/src/meta.ts
  29. +1 βˆ’1 packages/hint-http-cache/README.md
  30. +4 βˆ’27 packages/hint-http-cache/src/hint.ts
  31. +31 βˆ’0 packages/hint-http-cache/src/meta.ts
  32. +1 βˆ’1 packages/hint-http-compression/README.md
  33. +5 βˆ’31 packages/hint-http-compression/src/hint.ts
  34. +34 βˆ’0 packages/hint-http-compression/src/meta.ts
  35. +1 βˆ’1 packages/hint-https-only/README.md
  36. +4 βˆ’12 packages/hint-https-only/src/hint.ts
  37. +16 βˆ’0 packages/hint-https-only/src/meta.ts
  38. +1 βˆ’1 packages/hint-image-optimization-cloudinary/README.md
  39. +4 βˆ’20 packages/hint-image-optimization-cloudinary/src/hint.ts
  40. +24 βˆ’0 packages/hint-image-optimization-cloudinary/src/meta.ts
  41. +1 βˆ’1 packages/hint-manifest-app-name/README.md
  42. +4 βˆ’12 packages/hint-manifest-app-name/src/hint.ts
  43. +16 βˆ’0 packages/hint-manifest-app-name/src/meta.ts
  44. +1 βˆ’1 packages/hint-manifest-exists/README.md
  45. +3 βˆ’12 packages/hint-manifest-exists/src/hint.ts
  46. +16 βˆ’0 packages/hint-manifest-exists/src/meta.ts
  47. +1 βˆ’1 packages/hint-manifest-file-extension/README.md
  48. +4 βˆ’12 packages/hint-manifest-file-extension/src/hint.ts
  49. +16 βˆ’0 packages/hint-manifest-file-extension/src/meta.ts
  50. +1 βˆ’1 packages/hint-manifest-is-valid/README.md
  51. +4 βˆ’13 packages/hint-manifest-is-valid/src/hint.ts
  52. +16 βˆ’0 packages/hint-manifest-is-valid/src/meta.ts
  53. +1 βˆ’1 packages/hint-meta-charset-utf-8/README.md
  54. +4 βˆ’12 packages/hint-meta-charset-utf-8/src/hint.ts
  55. +16 βˆ’0 packages/hint-meta-charset-utf-8/src/meta.ts
  56. +1 βˆ’1 packages/hint-meta-theme-color/README.md
  57. +3 βˆ’12 packages/hint-meta-theme-color/src/hint.ts
  58. +16 βˆ’0 packages/hint-meta-theme-color/src/meta.ts
  59. +1 βˆ’1 packages/hint-meta-viewport/README.md
  60. +4 βˆ’12 packages/hint-meta-viewport/src/hint.ts
  61. +16 βˆ’0 packages/hint-meta-viewport/src/meta.ts
  62. +1 βˆ’1 packages/hint-minified-js/README.md
  63. +4 βˆ’15 packages/hint-minified-js/src/hint.ts
  64. +19 βˆ’0 packages/hint-minified-js/src/meta.ts
  65. +1 βˆ’1 packages/hint-no-bom/README.md
  66. +4 βˆ’12 packages/hint-no-bom/src/hint.ts
  67. +16 βˆ’0 packages/hint-no-bom/src/meta.ts
  68. +1 βˆ’1 packages/hint-no-broken-links/README.md
  69. +4 βˆ’20 packages/hint-no-broken-links/src/hint.ts
  70. +24 βˆ’0 packages/hint-no-broken-links/src/meta.ts
  71. +1 βˆ’1 packages/hint-no-disallowed-headers/README.md
  72. +4 βˆ’27 packages/hint-no-disallowed-headers/src/hint.ts
  73. +31 βˆ’0 packages/hint-no-disallowed-headers/src/meta.ts
  74. +1 βˆ’1 packages/hint-no-friendly-error-pages/README.md
  75. +4 βˆ’12 packages/hint-no-friendly-error-pages/src/hint.ts
  76. +16 βˆ’0 packages/hint-no-friendly-error-pages/src/meta.ts
  77. +1 βˆ’1 packages/hint-no-html-only-headers/README.md
  78. +4 βˆ’27 packages/hint-no-html-only-headers/src/hint.ts
  79. +31 βˆ’0 packages/hint-no-html-only-headers/src/meta.ts
  80. +1 βˆ’1 packages/hint-no-http-redirects/README.md
  81. +4 βˆ’25 packages/hint-no-http-redirects/src/hint.ts
  82. +29 βˆ’0 packages/hint-no-http-redirects/src/meta.ts
  83. +1 βˆ’1 packages/hint-no-p3p/README.md
  84. +4 βˆ’12 packages/hint-no-p3p/src/hint.ts
  85. +16 βˆ’0 packages/hint-no-p3p/src/meta.ts
  86. +1 βˆ’1 packages/hint-no-protocol-relative-urls/README.md
  87. +4 βˆ’12 packages/hint-no-protocol-relative-urls/src/hint.ts
  88. +16 βˆ’0 packages/hint-no-protocol-relative-urls/src/meta.ts
  89. +4 βˆ’25 packages/hint-no-vulnerable-javascript-libraries/src/hint.ts
  90. +29 βˆ’0 packages/hint-no-vulnerable-javascript-libraries/src/meta.ts
  91. +4 βˆ’25 packages/hint-performance-budget/src/hint.ts
  92. +31 βˆ’0 packages/hint-performance-budget/src/meta.ts
  93. +1 βˆ’1 packages/hint-sri/README.md
  94. +5 βˆ’27 packages/hint-sri/src/hint.ts
  95. +26 βˆ’0 packages/hint-sri/src/meta.ts
  96. +6 βˆ’0 packages/hint-sri/src/types.ts
  97. +1 βˆ’1 packages/hint-ssllabs/README.md
  98. +4 βˆ’38 packages/hint-ssllabs/src/hint.ts
  99. +42 βˆ’0 packages/hint-ssllabs/src/meta.ts
  100. +1 βˆ’1 packages/hint-strict-transport-security/README.md
  101. +4 βˆ’17 packages/hint-strict-transport-security/src/hint.ts
  102. +21 βˆ’0 packages/hint-strict-transport-security/src/meta.ts
  103. +1 βˆ’1 packages/hint-stylesheet-limits/README.md
  104. +4 βˆ’26 packages/hint-stylesheet-limits/src/hint.ts
  105. +30 βˆ’0 packages/hint-stylesheet-limits/src/meta.ts
  106. +1 βˆ’1 packages/hint-typescript-config/docs/consistent-casing.md
  107. +1 βˆ’1 packages/hint-typescript-config/docs/import-helpers.md
  108. +1 βˆ’1 packages/hint-typescript-config/docs/is-valid.md
  109. +1 βˆ’1 packages/hint-typescript-config/docs/no-comments.md
  110. +1 βˆ’1 packages/hint-typescript-config/docs/strict.md
  111. +1 βˆ’1 packages/hint-typescript-config/docs/target.md
  112. +4 βˆ’12 packages/hint-typescript-config/src/consistent-casing.ts
  113. +4 βˆ’12 packages/hint-typescript-config/src/import-helpers.ts
  114. +4 βˆ’12 packages/hint-typescript-config/src/is-valid.ts
  115. +8 βˆ’0 packages/hint-typescript-config/src/meta.ts
  116. +16 βˆ’0 packages/hint-typescript-config/src/meta/consistent-casing.ts
  117. +16 βˆ’0 packages/hint-typescript-config/src/meta/import-helpers.ts
  118. +16 βˆ’0 packages/hint-typescript-config/src/meta/is-valid.ts
  119. +16 βˆ’0 packages/hint-typescript-config/src/meta/no-comments.ts
  120. +16 βˆ’0 packages/hint-typescript-config/src/meta/strict.ts
  121. +16 βˆ’0 packages/hint-typescript-config/src/meta/target.ts
  122. +4 βˆ’12 packages/hint-typescript-config/src/no-comments.ts
  123. +4 βˆ’12 packages/hint-typescript-config/src/strict.ts
  124. +4 βˆ’12 packages/hint-typescript-config/src/target.ts
  125. +1 βˆ’1 packages/hint-validate-set-cookie-header/README.md
  126. +4 βˆ’13 packages/hint-validate-set-cookie-header/src/hint.ts
  127. +17 βˆ’0 packages/hint-validate-set-cookie-header/src/meta.ts
  128. +1 βˆ’1 packages/hint-webpack-config/docs/config-exists.md
  129. +1 βˆ’1 packages/hint-webpack-config/docs/is-installed.md
  130. +1 βˆ’1 packages/hint-webpack-config/docs/is-valid.md
  131. +1 βˆ’1 packages/hint-webpack-config/docs/module-esnext-typescript.md
  132. +1 βˆ’1 packages/hint-webpack-config/docs/modules-false-babel.md
  133. +1 βˆ’1 packages/hint-webpack-config/docs/no-devtool-in-prod.md
  134. +4 βˆ’12 packages/hint-webpack-config/src/config-exists.ts
  135. +4 βˆ’12 packages/hint-webpack-config/src/is-installed.ts
  136. +4 βˆ’12 packages/hint-webpack-config/src/is-valid.ts
  137. +8 βˆ’0 packages/hint-webpack-config/src/meta.ts
  138. +16 βˆ’0 packages/hint-webpack-config/src/meta/config-exists.ts
  139. +16 βˆ’0 packages/hint-webpack-config/src/meta/is-installed.ts
  140. +16 βˆ’0 packages/hint-webpack-config/src/meta/is-valid.ts
  141. +16 βˆ’0 packages/hint-webpack-config/src/meta/module-esnext-typescript.ts
  142. +16 βˆ’0 packages/hint-webpack-config/src/meta/modules-false-babel.ts
  143. +16 βˆ’0 packages/hint-webpack-config/src/meta/no-devtool-in-prod.ts
  144. +4 βˆ’12 packages/hint-webpack-config/src/module-esnext-typescript.ts
  145. +4 βˆ’12 packages/hint-webpack-config/src/modules-false-babel.ts
  146. +4 βˆ’12 packages/hint-webpack-config/src/no-devtool-in-prod.ts
  147. +1 βˆ’1 packages/hint-x-content-type-options/README.md
  148. +3 βˆ’13 packages/hint-x-content-type-options/src/hint.ts
  149. +16 βˆ’0 packages/hint-x-content-type-options/src/meta.ts
  150. +21 βˆ’0 packages/hint/src/lib/types/hint-meta.ts
  151. +2 βˆ’19 packages/hint/src/lib/types/hints.ts
@@ -1,4 +1,4 @@
# AMP HTML Validator (`amp-validator`)
# AMP HTML validator (`amp-validator`)
> AMP HTML is a way to build web pages that render with reliable and
fast performance. It is our attempt at fixing what many perceive as
@@ -4,11 +4,11 @@
import * as amphtmlValidator from 'amphtml-validator';
import { Category } from 'hint/dist/src/lib/enums/category';
import { debug as d } from 'hint/dist/src/lib/utils/debug';
import { IHint, HintMetadata, FetchEnd } from 'hint/dist/src/lib/types';
import { IHint, FetchEnd } from 'hint/dist/src/lib/types';
import { HintContext } from 'hint/dist/src/lib/hint-context';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import meta from './meta';
const debug: debug.IDebugger = d(__filename);
@@ -19,19 +19,7 @@ const debug: debug.IDebugger = d(__filename);
*/
export default class AmpValidatorHint implements IHint {
public static readonly meta: HintMetadata = {
docs: {
category: Category.performance,
description: `Require HTML page to be AMP valid.`
},
id: 'amp-validator',
schema: [{
additionalProperties: false,
properties: { 'errors-only': { type: 'boolean' } },
type: 'object'
}],
scope: HintScope.any
}
public static readonly meta = meta;
public constructor(context: HintContext) {
let validPromise: Promise<amphtmlValidator.Validator>;
@@ -0,0 +1,20 @@
import { Category } from 'hint/dist/src/lib/enums/category';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { HintMetadata } from 'hint/dist/src/lib/types';
const meta: HintMetadata = {
docs: {
category: Category.performance,
description: `Require HTML page to be AMP valid.`,
name: 'AMP HTML validator'
},
id: 'amp-validator',
schema: [{
additionalProperties: false,
properties: { 'errors-only': { type: 'boolean' } },
type: 'object'
}],
scope: HintScope.any
};
export default meta;
@@ -1,4 +1,4 @@
# Require an apple touch icon (`apple-touch-icons`)
# Use Apple touch icon (`apple-touch-icons`)
`apple-touch-icons` requires that a single `180Γ—180px` PNG
`apple-touch-icon` is used.
@@ -6,13 +6,13 @@ import { URL } from 'url';
import * as getImageData from 'image-size';
import { Category } from 'hint/dist/src/lib/enums/category';
import { debug as d } from 'hint/dist/src/lib/utils/debug';
import isRegularProtocol from 'hint/dist/src/lib/utils/network/is-regular-protocol';
import normalizeString from 'hint/dist/src/lib/utils/misc/normalize-string';
import { IAsyncHTMLDocument, IAsyncHTMLElement, IHint, TraverseEnd, NetworkData, HintMetadata } from 'hint/dist/src/lib/types';
import { IAsyncHTMLDocument, IAsyncHTMLElement, IHint, TraverseEnd, NetworkData } from 'hint/dist/src/lib/types';
import { HintContext } from 'hint/dist/src/lib/hint-context';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import meta from './meta';
const debug: debug.IDebugger = d(__filename);
@@ -24,15 +24,7 @@ const debug: debug.IDebugger = d(__filename);
export default class AppleTouchIconsHint implements IHint {
public static readonly meta: HintMetadata = {
docs: {
category: Category.pwa,
description: `Require an 'apple-touch-icon'`
},
id: 'apple-touch-icons',
schema: [],
scope: HintScope.any
}
public static readonly meta = meta;
public constructor(context: HintContext) {
@@ -0,0 +1,16 @@
import { Category } from 'hint/dist/src/lib/enums/category';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { HintMetadata } from 'hint/dist/src/lib/types';
const meta: HintMetadata = {
docs: {
category: Category.pwa,
description: `Require an 'apple-touch-icon'`,
name: 'Use Apple touch icon'
},
id: 'apple-touch-icons',
schema: [],
scope: HintScope.any
};
export default meta;
@@ -1,4 +1,4 @@
# Accessibility assessment with aXe (`axe`)
# aXe accessibility check (`axe`)
`aXe` is the accessibility engine for automated testing of HTML-based
user interfaces. This hint performs the default accessibility tests
@@ -11,12 +11,12 @@
import { AxeResults, Result as AxeResult, NodeResult as AxeNodeResult } from 'axe-core';
import { Category } from 'hint/dist/src/lib/enums/category';
import { debug as d } from 'hint/dist/src/lib/utils/debug';
import { IAsyncHTMLElement, IHint, Severity, CanEvaluateScript, HintMetadata } from 'hint/dist/src/lib/types';
import { IAsyncHTMLElement, IHint, Severity, CanEvaluateScript } from 'hint/dist/src/lib/types';
import readFileAsync from 'hint/dist/src/lib/utils/fs/read-file-async';
import { HintContext } from 'hint/dist/src/lib/hint-context';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import meta from './meta';
const debug = d(__filename);
@@ -28,46 +28,7 @@ const debug = d(__filename);
export default class AxeHint implements IHint {
public static readonly meta: HintMetadata = {
docs: {
category: Category.accessibility,
description: 'Runs axe-core tests in the target'
},
id: 'axe',
schema: [{
additionalProperties: false,
properties: {
rules: {
patternProperties: {
'^.+$': {
additionalProperties: false,
properties: { enabled: { type: 'boolean' } },
required: ['enabled'],
type: 'object'
}
},
type: 'object'
},
runOnly: {
additionalProperties: false,
properties: {
type: { type: 'string' },
values: {
items: { type: 'string' },
minItems: 1,
type: 'array',
uniqueItems: true
}
},
type: 'object'
}
}
}],
/*
* axe can not analize a file itself, it needs a connector.
*/
scope: HintScope.any
}
public static readonly meta = meta;
public constructor(context: HintContext) {
@@ -0,0 +1,47 @@
import { Category } from 'hint/dist/src/lib/enums/category';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { HintMetadata } from 'hint/dist/src/lib/types';
const meta: HintMetadata = {
docs: {
category: Category.accessibility,
description: 'Runs axe-core tests in the target',
name: 'aXe accessibility check'
},
id: 'axe',
schema: [{
additionalProperties: false,
properties: {
rules: {
patternProperties: {
'^.+$': {
additionalProperties: false,
properties: { enabled: { type: 'boolean' } },
required: ['enabled'],
type: 'object'
}
},
type: 'object'
},
runOnly: {
additionalProperties: false,
properties: {
type: { type: 'string' },
values: {
items: { type: 'string' },
minItems: 1,
type: 'array',
uniqueItems: true
}
},
type: 'object'
}
}
}],
/*
* axe can not analize a file itself, it needs a connector.
*/
scope: HintScope.any
};
export default meta;
@@ -1,4 +1,4 @@
# Babel configuration is valid (`is-valid`)
# Valid Babel configuration (`is-valid`)
## Why is this important?
@@ -1,14 +1,14 @@
/**
* @fileoverview `babel-config/is-valid` warns against providing an invalid babel configuration file.
*/
import { Category } from 'hint/dist/src/lib/enums/category';
import { debug as d } from 'hint/dist/src/lib/utils/debug';
import { IHint, HintMetadata } from 'hint/dist/src/lib/types';
import { IHint } from 'hint/dist/src/lib/types';
import { HintContext } from 'hint/dist/src/lib/hint-context';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { BabelConfigEvents, BabelConfigInvalidJSON, BabelConfigInvalidSchema } from '@hint/parser-babel-config';
import meta from './meta/is-valid';
const debug: debug.IDebugger = d(__filename);
/*
@@ -17,15 +17,7 @@ const debug: debug.IDebugger = d(__filename);
* ------------------------------------------------------------------------------
*/
export default class BabelConfigIsValidHint implements IHint {
public static readonly meta: HintMetadata = {
docs: {
category: Category.development,
description: `'babel-config/is-valid' warns against providing an invalid babel configuration file \`.babelrc\``
},
id: 'babel-config/is-valid',
schema: [],
scope: HintScope.local
}
public static readonly meta = meta;
public constructor(context: HintContext<BabelConfigEvents>) {
const invalidJSONFile = async (babelConfigInvalid: BabelConfigInvalidJSON, event: string) => {
@@ -0,0 +1,5 @@
/**
* @fileoverview Verify that the babel config is valid.
*/
module.exports = { 'is-valid': require('./meta/is-valid') };
@@ -0,0 +1,16 @@
import { Category } from 'hint/dist/src/lib/enums/category';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { HintMetadata } from 'hint/dist/src/lib/types';
const meta: HintMetadata = {
docs: {
category: Category.development,
description: `'babel-config/is-valid' warns against providing an invalid babel configuration file \`.babelrc\``,
name: 'Valid Babel configuration'
},
id: 'babel-config/is-valid',
schema: [],
scope: HintScope.local
};
export default meta;
@@ -1,4 +1,4 @@
# Require `Content-Type` HTTP response header with appropriate value (`content-type`)
# Correct `Content-Type` header (`content-type`)
`content-type` warns against not serving resources with the
`Content-Type` HTTP response header with a value containing
@@ -11,15 +11,15 @@
import { MediaType, parse } from 'content-type';
import { Category } from 'hint/dist/src/lib/enums/category';
import { debug as d } from 'hint/dist/src/lib/utils/debug';
import { IHint, FetchEnd, HintMetadata } from 'hint/dist/src/lib/types';
import { IHint, FetchEnd } from 'hint/dist/src/lib/types';
import getHeaderValueNormalized from 'hint/dist/src/lib/utils/network/normalized-header-value';
import isDataURI from 'hint/dist/src/lib/utils/network/is-data-uri';
import normalizeString from 'hint/dist/src/lib/utils/misc/normalize-string';
import { isTextMediaType } from 'hint/dist/src/lib/utils/content-type';
import { HintContext } from 'hint/dist/src/lib/hint-context';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import meta from './meta';
const debug = d(__filename);
@@ -31,19 +31,7 @@ const debug = d(__filename);
export default class ContentTypeHint implements IHint {
public static readonly meta: HintMetadata = {
docs: {
category: Category.interoperability,
description: 'Require `Content-Type` header with appropriate value'
},
id: 'content-type',
schema: [{
items: { type: 'string' },
type: ['object', 'null'],
uniqueItems: true
}],
scope: HintScope.site
}
public static readonly meta = meta;
public constructor(context: HintContext) {
@@ -0,0 +1,20 @@
import { Category } from 'hint/dist/src/lib/enums/category';
import { HintScope } from 'hint/dist/src/lib/enums/hintscope';
import { HintMetadata } from 'hint/dist/src/lib/types';
const meta: HintMetadata = {
docs: {
category: Category.interoperability,
description: 'Require `Content-Type` header with appropriate value',
name: 'Correct `Content-Type` header'
},
id: 'content-type',
schema: [{
items: { type: 'string' },
type: ['object', 'null'],
uniqueItems: true
}],
scope: HintScope.site
};
export default meta;
@@ -1,4 +1,4 @@
# Require external links to disown opener (`disown-opener`)
# External links disown opener (`disown-opener`)
`disown-opener` checks if the `rel` attribute is specified with both
the `noopener` and `noreferrer` values (or only `noopener` if all the
Oops, something went wrong.

0 comments on commit d40a0ab

Please sign in to comment.