Skip to content

Commit 61539b8

Browse files
authored
update: Doctypes api and verification (#13)
* update: Remove scripts since its not yet used * update: New doctypes api and verification
1 parent 140cc65 commit 61539b8

19 files changed

Lines changed: 54 additions & 266 deletions

.eslintrc.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,5 @@ module.exports = {
3737
'@typescript-eslint/no-empty-function': 'off',
3838
},
3939
},
40-
{
41-
files: ['scripts/**/*'],
42-
rules: {
43-
'no-console': 'off',
44-
},
45-
},
4640
],
4741
};

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
collectCoverageFrom: ['packages/*/src/**/*.ts', 'scripts/**/*.ts'],
2+
collectCoverageFrom: ['packages/*/src/**/*.ts'],
33
coverageDirectory: 'coverage',
44
coverageThreshold: {
55
global: {
@@ -14,5 +14,5 @@ module.exports = {
1414
moduleNameMapper: {
1515
'@email-types/(.+)$': '<rootDir>/packages/$1',
1616
},
17-
roots: ['<rootDir>/packages', '<rootDir>/scripts'],
17+
roots: ['<rootDir>/packages'],
1818
};

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"clean": "rm -rf ./packages/*/{*.tsbuildinfo,dist}",
1010
"clean:prune": "rm -rf ./{,*/,**/*/}{node_modules,coverage,*.lock,*.log,*.tsbuildinfo,dist}",
1111
"build": "yarn clean && lerna run build --stream && yarn types",
12-
"gen": "yarn run ts scripts/index.ts",
13-
"ts": "ts-node --project ./tsconfig.node.json",
1412
"test": "yarn build && yarn lint && yarn jest:coverage",
1513
"jest": "jest --colors --logHeapUsage",
1614
"jest:coverage": "yarn run jest --coverage",
@@ -50,7 +48,6 @@
5048
"@types/prettier": "^1.19.0",
5149
"@typescript-eslint/eslint-plugin": "^2.7.0",
5250
"@typescript-eslint/parser": "^2.7.0",
53-
"colors": "^1.4.0",
5451
"conventional-changelog-beemo": "^1.5.3",
5552
"eslint": "^6.6.0",
5653
"eslint-config-prettier": "^6.6.0",
@@ -65,10 +62,8 @@
6562
"jest": "^24.9.0",
6663
"lerna": "^3.18.4",
6764
"lint-staged": "^10.0.0-1",
68-
"mri": "^1.1.4",
6965
"prettier": "^1.19.1",
7066
"react": "^16.12.0",
71-
"ts-node": "^8.5.4",
7267
"typescript": "^3.7.2"
7368
},
7469
"keywords": [

packages/data/doctypes.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from './dist/misc/doctypes';
1+
export * from './dist/html/doctypes';
2+
export * from './dist/html/doctypes.types';

packages/data/doctypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./dist/misc/doctypes');
1+
module.exports = require('./dist/html/doctypes');

packages/data/src/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type Nullable<T> = T | null;
2+
3+
/* Description value type */
4+
export type Description = string;
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
1-
import { create } from '../utils/create';
2-
import { Doctype } from '../types/doctypes';
1+
import { Doctype } from './doctypes.types';
32

4-
const validate = create<Doctype>();
5-
6-
export const doctypes = validate({
7-
'html-5': {
3+
export const doctypes: Doctype[] = [
4+
{
5+
name: 'HTML 5',
86
description:
97
'A doctype declaration which is very short, due to its lack of references to a Document Type Definition (DTD) in the form of a URL or FPI. All it contains is the tag name of the root element of the document, HTML.',
108
element: 'html',
119
keyword: null,
1210
publicIdentifier: null,
1311
systemIdentifier: null,
1412
},
15-
'html-4.01-strict': {
13+
{
14+
name: 'HTML 4.01 Strict',
1615
description:
1716
'A strict doctype declaration which validates against the HTML 4.01 spec, although it doesn\'t allow any presentational markup or deprecated elements (such as `<font>` elements) or framesets to be used. It validates loose HTML style markup, such as minimized attributes and non-quoted attributes (eg required, rather than required="required")',
1817
element: 'HTML',
1918
keyword: 'PUBLIC',
2019
publicIdentifier: '-//W3C//DTD HTML 4.01//EN',
2120
systemIdentifier: 'http://www.w3.org/TR/html4/strict.dtd',
2221
},
23-
'html-4.01-transitional': {
22+
{
23+
name: 'HTML 4.01 Transitional',
2424
description:
2525
'A transitional doctype declaration which validates against the HTML 4.01 spec. It allows some presentational markup and deprecated elements (such as <font> elements) but not framesets. It validates loose HTML style markup, such as minimized attributes and non-quoted attributes (eg required, rather than required="required")',
2626
element: 'HTML',
2727
keyword: 'PUBLIC',
2828
publicIdentifier: '-//W3C//DTD HTML 4.01 Transitional//EN',
2929
systemIdentifier: 'http://www.w3.org/TR/html4/loose.dtd',
3030
},
31-
'xhtml-1.1': {
31+
{
32+
name: 'XHTML 1.1',
3233
description: '',
3334
element: 'html',
3435
keyword: 'PUBLIC',
3536
publicIdentifier: '-//W3C//DTD XHTML 1.1//EN',
3637
systemIdentifier: 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd',
3738
},
38-
'xhtml-1.0-strict': {
39+
{
40+
name: 'XHTML 1.0 Strict',
3941
description:
4042
"A strict doctype declaration which validates against the HTML 4.01 spec, although it doesn't allow any presentational markup or deprecated elements (such as `<font>` elements) or framesets to be used. Unlike the `HTML 4.01 Strict` doctype, it does not validate loose HTML style markup.",
4143
element: 'html',
4244
keyword: 'PUBLIC',
4345
publicIdentifier: '-//W3C//DTD XHTML 1.0 Strict//EN',
4446
systemIdentifier: 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd',
4547
},
46-
'xhtml-1.0-transitional': {
48+
{
49+
name: 'XHTML 1.0 Transitional',
4750
description:
4851
'A transitional doctype declaration which validates against the HTML 4.01 spec. It allows some presentational markup and deprecated elements (such as <font> elements) but not framesets. Unlike the `HTML 4.01 Transitional` doctype, it does not validate loose HTML style markup.',
4952
element: 'html',
5053
keyword: 'PUBLIC',
5154
publicIdentifier: '-//W3C//DTD XHTML 1.0 Transitional//EN',
5255
systemIdentifier: 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd',
5356
},
54-
});
55-
56-
export default doctypes;
57+
];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Nullable, Description } from '../common';
2+
3+
type Name =
4+
| 'HTML 5'
5+
| 'HTML 4.01 Strict'
6+
| 'HTML 4.01 Transitional'
7+
| 'XHTML 1.1'
8+
| 'XHTML 1.0 Strict'
9+
| 'XHTML 1.0 Transitional';
10+
11+
type Element = 'html' | 'HTML';
12+
13+
type Keyword = 'PUBLIC' | 'SYSTEM';
14+
15+
export type Doctype = {
16+
name: Name;
17+
description?: Description;
18+
element: Element;
19+
keyword: Nullable<Keyword>;
20+
publicIdentifier: Nullable<string>;
21+
systemIdentifier: Nullable<string>;
22+
};

packages/data/src/html/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './doctypes';
2+
export * from './doctypes.types';

packages/data/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './mso';
2-
export * from './misc/doctypes';
2+
export * from './html/doctypes';
33
export * from './utils/create';

0 commit comments

Comments
 (0)