Skip to content

Commit

Permalink
feat(lint): Implement front matter validator and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkarRuikar committed Apr 25, 2023
1 parent c495a1e commit 59a28b8
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 0 deletions.
155 changes: 155 additions & 0 deletions front-matter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"lineWidth": 80,
"schema": {
"title": "Front matter schema",
"type": "object",
"additionalProperties": false,
"required": ["title", "slug"],
"properties": {
"title": {
"title": "Title",
"description": "Rendered page title and for SEO",
"type": "string",
"maxLength": 120
},
"short-title": {
"title": "Short Title",
"description": "To be used in sidebars",
"type": "string",
"maxLength": 60
},
"slug": {
"title": "slug",
"description": "URL path of the page",
"type": "string"
},
"page-type": {
"title": "Page Type",
"description": "Type of the page",
"type": "string"
},
"status": {
"title": "Status",
"description": "Browser compatibility status",
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"enum": ["deprecated", "experimental", "non-standard"]
}
},
"browser-compat": {
"title": "Browser Compatibility",
"description": "Browser compatibility location",
"type": ["array", "string"]
},
"spec-urls": {
"title": "Specification URLs",
"description": "Specification locations",
"type": ["array", "string"],
"format": "uri",
"items": {
"type": "string",
"format": "uri"
}
}
}
},
"attribute-order": [
"title",
"short-title",
"slug",
"page-type",
"status",
"browser-compat",
"spec-urls"
],
"allowedPageTypes": {
"Glossary": ["glossary-definition", "glossary-disambiguation"],
"MDN/": ["landing-page", "mdn-community-guide", "mdn-writing-guide"],
"Web/SVG/": ["guide", "landing-page", "svg-attribute", "svg-element"],
"Web/HTML/": [
"guide",
"landing-page",
"html-attribute",
"html-attribute-value",
"html-element"
],
"Mozilla/Add-ons/WebExtensions/": [
"guide",
"landing-page",
"webextension-api-function",
"webextension-api",
"webextension-api-event",
"webextension-api-property",
"webextension-api-type",
"webextension-manifest-key"
],
"Web/API/": [
"guide",
"landing-page",
"web-api-overview",
"web-api-global-function",
"web-api-global-property",
"web-api-interface",
"web-api-constructor",
"web-api-instance-method",
"web-api-instance-property",
"web-api-instance-event",
"web-api-static-method",
"web-api-static-property",
"web-api-event",
"webgl-extension",
"webgl-extension-method"
],
"Web/CSS/": [
"guide",
"landing-page",
"css-at-rule",
"css-at-rule-descriptor",
"css-combinator",
"css-function",
"css-keyword",
"css-media-feature",
"css-module",
"css-property",
"css-pseudo-class",
"css-pseudo-element",
"css-selector",
"css-shorthand-property",
"css-type"
],
"Web/JavaScript/": [
"guide",
"landing-page",
"javascript-class",
"javascript-constructor",
"javascript-error",
"javascript-function",
"javascript-global-property",
"javascript-instance-accessor-property",
"javascript-instance-data-property",
"javascript-instance-method",
"javascript-language-feature",
"javascript-namespace",
"javascript-operator",
"javascript-statement",
"javascript-static-accessor-property",
"javascript-static-data-property",
"javascript-static-method"
],
"Web/HTTP/Headers/Content-Security-Policy/": ["http-csp-directive"],
"Web/HTTP/Headers/Permissions-Policy/": [
"http-permissions-policy-directive"
],
"Web/HTTP/Headers/": ["guide", "http-header"],
"Web/HTTP/Methods/": ["http-method"],
"Web/HTTP/Status/": ["http-status-code"],
"Web/MathML/Element/": ["mathml-element"],
"Web/MathML/Global_attributes/": ["mathml-attribute"],
"Web/Accessibility/ARIA/Attributes/": ["aria-attribute"],
"Web/Accessibility/ARIA/Roles/": ["aria-role"],
"Web/HTTP/CORS/Errors/": ["http-cors-error"],
"global": ["guide", "landing-page"]
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"build": "env-cmd --silent cross-env CONTENT_ROOT=files BUILD_OUT_ROOT=build yari-build",
"content": "env-cmd --silent cross-env CONTENT_ROOT=files yari-tool",
"filecheck": "env-cmd --silent cross-env CONTENT_ROOT=files yari-filecheck --cwd=.",
"fix:fm": "node scripts/front-matter-linter.js --fix true",
"fix:js": "prettier -w \"**/*.(m)?js\"",
"fix:json": "prettier -w \"**/*.json(c)?\"",
"fix:md": "markdownlint-cli2-fix \"**/*.md\"",
"fix:yml": "prettier -w \"**/*.yml\"",
"lint:fm": "node scripts/front-matter-linter.js",
"lint:js": "prettier -c \"**/*.(m)?js\"",
"lint:json": "prettier -c \"**/*.json(c)?\"",
"lint:md": "markdownlint-cli2 \"**/*.md\"",
Expand All @@ -24,6 +26,9 @@
"up-to-date-check": "node scripts/up-to-date-check.js"
},
"dependencies": {
"@apideck/better-ajv-errors": "^0.3.6",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"@mdn/yari": "2.18.1",
"cross-env": "7.0.3",
"env-cmd": "10.1.0",
Expand Down
Loading

0 comments on commit 59a28b8

Please sign in to comment.