diff --git a/.eslintrc.js b/.eslintrc.js index be9be32a..8e608c0b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1 +1 @@ -module.exports = require("./eslint.config")(); +module.exports = require("./eslint.config")(); diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 22dd342e..3b90dca5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,25 +1,25 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "[Bug] " -labels: "bug" -assignees: "" ---- - -### What versions am I using of... - -- `nodejs`: x.x.x -- `npm`/`yarn`: x.x.x -- `postdfm`: x.x.x - -### What did I do? - -### What was I expecting? - -### What happened instead? - -### What do I think is the problem? - -### Am I willing to make a pull request with failing tests to help speed up the fix? - -### Am I willing to make a pull request with the fix as well? +--- +name: Bug report +about: Create a report to help us improve +title: "[Bug] " +labels: "bug" +assignees: "" +--- + +### What versions am I using of... + +- `nodejs`: x.x.x +- `npm`/`yarn`: x.x.x +- `postdfm`: x.x.x + +### What did I do? + +### What was I expecting? + +### What happened instead? + +### What do I think is the problem? + +### Am I willing to make a pull request with failing tests to help speed up the fix? + +### Am I willing to make a pull request with the fix as well? diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index e08b4fca..28743099 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,11 +1,11 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: "[Feature] " -labels: "feature" -assignees: "" ---- - -### What doesn't `postdfm` do that I would like it to? - -### Am I willing to make a pull request with an implementation of the feature? +--- +name: Feature request +about: Suggest an idea for this project +title: "[Feature] " +labels: "feature" +assignees: "" +--- + +### What doesn't `postdfm` do that I would like it to? + +### Am I willing to make a pull request with an implementation of the feature? diff --git a/README.md b/README.md index 3f9ad465..b6f1b517 100644 --- a/README.md +++ b/README.md @@ -51,16 +51,16 @@ const cisDfm = fs.readFileSync( const runner = postdfm({ transformers: [ - function(ast) { + function (ast) { //transform and return the ast return transformedAst; - } - ] + }, + ], }); const transDfm = runner.processSync(dfm, { //filename used for reporting errors - from: "cis.dfm" + from: "cis.dfm", }); fs.writeFileSync("trans.dfm", transDfm); diff --git a/__test__/__fixtures__/parse/boundary-keyword/ast.json b/__test__/__fixtures__/parse/boundary-keyword/ast.json index c1a076a2..0671a904 100644 --- a/__test__/__fixtures__/parse/boundary-keyword/ast.json +++ b/__test__/__fixtures__/parse/boundary-keyword/ast.json @@ -1,67 +1,67 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "kind": "object", - "name": "Outer", - "type": "TOuter", - "properties": [], - "children": [ - { - "astType": "object", - "kind": "object", - "name": "Problem", - "type": "TProblem", - "properties": [ - { - "astType": "property", - "name": "ProblemProperty", - "value": { - "astType": "identifier", - "value": "ErrorEnd" - }, - "raws": { - "afterName": " ", - "beforeValue": " " - } - } - ], - "children": [ - { - "astType": "object", - "kind": "object", - "name": "Inner", - "type": "TInner", - "properties": [], - "children": [], - "raws": { - "afterName": "", - "beforeType": " ", - "beforeName": " ", - "beforeEnd": "\r\n " - } - } - ], - "raws": { - "afterName": "", - "beforeType": " ", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n " - } - } - ], - "raws": { - "afterName": "", - "beforeType": " ", - "beforeName": " ", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n" - } - }, - "raws": { - "before": "", - "after": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "kind": "object", + "name": "Outer", + "type": "TOuter", + "properties": [], + "children": [ + { + "astType": "object", + "kind": "object", + "name": "Problem", + "type": "TProblem", + "properties": [ + { + "astType": "property", + "name": "ProblemProperty", + "value": { + "astType": "identifier", + "value": "ErrorEnd" + }, + "raws": { + "afterName": " ", + "beforeValue": " " + } + } + ], + "children": [ + { + "astType": "object", + "kind": "object", + "name": "Inner", + "type": "TInner", + "properties": [], + "children": [], + "raws": { + "afterName": "", + "beforeType": " ", + "beforeName": " ", + "beforeEnd": "\r\n " + } + } + ], + "raws": { + "afterName": "", + "beforeType": " ", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n " + } + } + ], + "raws": { + "afterName": "", + "beforeType": " ", + "beforeName": " ", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n" + } + }, + "raws": { + "before": "", + "after": "" + } +} diff --git a/__test__/__fixtures__/parse/empty-file/ast.json b/__test__/__fixtures__/parse/empty-file/ast.json index 66c77dc9..c5a6828b 100644 --- a/__test__/__fixtures__/parse/empty-file/ast.json +++ b/__test__/__fixtures__/parse/empty-file/ast.json @@ -1,6 +1,6 @@ -{ - "astType": "root", - "raws": { - "before": "" - } -} +{ + "astType": "root", + "raws": { + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/empty-object/ast.json b/__test__/__fixtures__/parse/empty-object/ast.json index 2ee1d055..bde6ead2 100644 --- a/__test__/__fixtures__/parse/empty-object/ast.json +++ b/__test__/__fixtures__/parse/empty-object/ast.json @@ -1,21 +1,21 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [], - "kind": "object", - "name": "Empty", - "properties": [], - "raws": { - "afterName": "", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeType": " " - }, - "type": "TEmpty" - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [], + "kind": "object", + "name": "Empty", + "properties": [], + "raws": { + "afterName": "", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeType": " " + }, + "type": "TEmpty" + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/lists/ast.json b/__test__/__fixtures__/parse/lists/ast.json index 91963fea..b7584246 100644 --- a/__test__/__fixtures__/parse/lists/ast.json +++ b/__test__/__fixtures__/parse/lists/ast.json @@ -1,428 +1,428 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [], - "kind": "object", - "name": "ListForm", - "properties": [ - { - "astType": "property", - "name": "Options", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "identifierList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": "\r\n " - }, - "values": [ - { - "astType": "identifier", - "raws": { - "after": "" - }, - "value": "dgTitles" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "\r\n " - }, - "value": "dg_Indicator" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgColumnResize" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "\r\n " - }, - "value": "dgColLines" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgRowLines" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "\r\n " - }, - "value": "dgTabs" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgRowSelect" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "\r\n " - }, - "value": "dgConfirmDelete" - }, - { - "astType": "identifier", - "raws": { - "before": "\r\n " - }, - "value": "dgCancelOnExit" - } - ] - } - }, - { - "astType": "property", - "name": "EmptyOptions", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "identifierList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - }, - { - "astType": "property", - "name": "Strings", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "variantList", - "raws": { - "afterOpen": " ", - "beforeClose": "\r\n " - }, - "values": [ - { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "this is string." - } - ] - }, - { - "astType": "string", - "raws": { - "before": "\r\n " - }, - "value": [ - { - "astType": "literalString", - "value": "and another one..." - }, - { - "astType": "literalString", - "raws": { - "before": "\r\n + " - }, - "value": "and another one..." - }, - { - "astType": "literalString", - "raws": { - "before": "\r\n + " - }, - "value": "now with apostrophe '" - }, - { - "astType": "controlString", - "value": "\r" - }, - { - "astType": "controlString", - "value": "\n" - }, - { - "astType": "literalString", - "value": "how fancy" - } - ] - } - ] - } - }, - { - "astType": "property", - "name": "Variants", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "variantList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": "" - }, - "values": [ - { - "astType": "integer", - "value": "255" - }, - { - "astType": "integer", - "raws": { - "before": "\r\n " - }, - "value": "255" - }, - { - "astType": "integer", - "raws": { - "before": "\r\n " - }, - "value": "255" - }, - { - "astType": "boolean", - "raws": { - "before": "\r\n " - }, - "value": true - }, - { - "astType": "string", - "raws": { - "before": "\r\n " - }, - "value": [ - { - "astType": "literalString", - "value": "Hello World!" - } - ] - }, - { - "astType": "double", - "raws": { - "before": "\r\n " - }, - "value": { - "exponent": "22", - "integer": "45" - } - } - ] - } - }, - { - "astType": "property", - "name": "EmptyVariants", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "variantList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - }, - { - "astType": "property", - "name": "Items", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "itemList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": "" - }, - "values": [ - { - "astType": "item", - "properties": [ - { - "astType": "property", - "name": "Expanded", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": false - } - }, - { - "astType": "property", - "name": "Visible", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - } - ], - "raws": { - "afterItem": "\r\n ", - "beforeEnd": "\r\n " - } - }, - { - "astType": "item", - "properties": [], - "raws": { - "afterItem": "\r\n ", - "before": "\r\n " - } - }, - { - "astType": "item", - "properties": [ - { - "astType": "property", - "name": "Expanded", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": false - } - }, - { - "astType": "property", - "name": "Visible", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - } - ], - "raws": { - "afterItem": "\r\n ", - "before": "\r\n ", - "beforeEnd": "\r\n " - } - } - ] - } - }, - { - "astType": "property", - "name": "EmptyItems", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "itemList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - }, - { - "astType": "property", - "name": "BinaryData", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "binaryStringList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": "\r\n " - }, - "values": [ - { - "astType": "binaryString", - "value": "07544269746D617036550000424D365500000000000036000000280000005500" - }, - { - "astType": "binaryString", - "raws": { - "before": "\r\n " - }, - "value": "000055000000010018000000000000550000C40E0000C40E0000000000000000" - } - ] - } - }, - { - "astType": "property", - "name": "EmptyBinaryData", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "binaryStringList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - } - ], - "raws": { - "afterName": "", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TForm" - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [], + "kind": "object", + "name": "ListForm", + "properties": [ + { + "astType": "property", + "name": "Options", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "identifierList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": "\r\n " + }, + "values": [ + { + "astType": "identifier", + "raws": { + "after": "" + }, + "value": "dgTitles" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "\r\n " + }, + "value": "dg_Indicator" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgColumnResize" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "\r\n " + }, + "value": "dgColLines" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgRowLines" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "\r\n " + }, + "value": "dgTabs" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgRowSelect" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "\r\n " + }, + "value": "dgConfirmDelete" + }, + { + "astType": "identifier", + "raws": { + "before": "\r\n " + }, + "value": "dgCancelOnExit" + } + ] + } + }, + { + "astType": "property", + "name": "EmptyOptions", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "identifierList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + }, + { + "astType": "property", + "name": "Strings", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "variantList", + "raws": { + "afterOpen": " ", + "beforeClose": "\r\n " + }, + "values": [ + { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "this is string." + } + ] + }, + { + "astType": "string", + "raws": { + "before": "\r\n " + }, + "value": [ + { + "astType": "literalString", + "value": "and another one..." + }, + { + "astType": "literalString", + "raws": { + "before": "\r\n + " + }, + "value": "and another one..." + }, + { + "astType": "literalString", + "raws": { + "before": "\r\n + " + }, + "value": "now with apostrophe '" + }, + { + "astType": "controlString", + "value": "\r" + }, + { + "astType": "controlString", + "value": "\n" + }, + { + "astType": "literalString", + "value": "how fancy" + } + ] + } + ] + } + }, + { + "astType": "property", + "name": "Variants", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "variantList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": "" + }, + "values": [ + { + "astType": "integer", + "value": "255" + }, + { + "astType": "integer", + "raws": { + "before": "\r\n " + }, + "value": "255" + }, + { + "astType": "integer", + "raws": { + "before": "\r\n " + }, + "value": "255" + }, + { + "astType": "boolean", + "raws": { + "before": "\r\n " + }, + "value": true + }, + { + "astType": "string", + "raws": { + "before": "\r\n " + }, + "value": [ + { + "astType": "literalString", + "value": "Hello World!" + } + ] + }, + { + "astType": "double", + "raws": { + "before": "\r\n " + }, + "value": { + "exponent": "22", + "integer": "45" + } + } + ] + } + }, + { + "astType": "property", + "name": "EmptyVariants", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "variantList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + }, + { + "astType": "property", + "name": "Items", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "itemList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": "" + }, + "values": [ + { + "astType": "item", + "properties": [ + { + "astType": "property", + "name": "Expanded", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": false + } + }, + { + "astType": "property", + "name": "Visible", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + } + ], + "raws": { + "afterItem": "\r\n ", + "beforeEnd": "\r\n " + } + }, + { + "astType": "item", + "properties": [], + "raws": { + "afterItem": "\r\n ", + "before": "\r\n " + } + }, + { + "astType": "item", + "properties": [ + { + "astType": "property", + "name": "Expanded", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": false + } + }, + { + "astType": "property", + "name": "Visible", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + } + ], + "raws": { + "afterItem": "\r\n ", + "before": "\r\n ", + "beforeEnd": "\r\n " + } + } + ] + } + }, + { + "astType": "property", + "name": "EmptyItems", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "itemList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + }, + { + "astType": "property", + "name": "BinaryData", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "binaryStringList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": "\r\n " + }, + "values": [ + { + "astType": "binaryString", + "value": "07544269746D617036550000424D365500000000000036000000280000005500" + }, + { + "astType": "binaryString", + "raws": { + "before": "\r\n " + }, + "value": "000055000000010018000000000000550000C40E0000C40E0000000000000000" + } + ] + } + }, + { + "astType": "property", + "name": "EmptyBinaryData", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "binaryStringList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + } + ], + "raws": { + "afterName": "", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TForm" + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/no-type/ast.json b/__test__/__fixtures__/parse/no-type/ast.json index f492c9d8..f3557fec 100644 --- a/__test__/__fixtures__/parse/no-type/ast.json +++ b/__test__/__fixtures__/parse/no-type/ast.json @@ -1,18 +1,18 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [], - "kind": "object", - "name": "Empty", - "properties": [], - "raws": { - "beforeEnd": "\r\n", - "beforeName": " " - } - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [], + "kind": "object", + "name": "Empty", + "properties": [], + "raws": { + "beforeEnd": "\r\n", + "beforeName": " " + } + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/objects/ast.json b/__test__/__fixtures__/parse/objects/ast.json index 13178fdc..854d1d94 100644 --- a/__test__/__fixtures__/parse/objects/ast.json +++ b/__test__/__fixtures__/parse/objects/ast.json @@ -1,261 +1,261 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [], - "kind": "object", - "name": "Edit1", - "properties": [], - "raws": { - "afterName": "", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TEdit" - }, - { - "astType": "object", - "children": [], - "kind": "inline", - "name": "Edit2", - "properties": [], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TEdit" - }, - { - "astType": "object", - "children": [], - "kind": "inherited", - "name": "Edit3", - "properties": [], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TEdit" - }, - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [], - "kind": "object", - "name": "DeepTree10", - "properties": [], - "raws": { - "afterName": "", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree9", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree8", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree7", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree6", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree5", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree4", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree3", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree2", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "DeepTree1", - "properties": [], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "TComponent" - } - ], - "kind": "object", - "name": "_Under_Score", - "properties": [], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeType": " " - }, - "type": "_TUnder_Score" - } - ], - "kind": "object", - "name": "BasicForm", - "properties": [ - { - "astType": "property", - "name": "Caption", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Basic Form" - } - ] - } - } - ], - "raws": { - "afterName": "", - "beforeChildren": "\r\n ", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TForm" - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [], + "kind": "object", + "name": "Edit1", + "properties": [], + "raws": { + "afterName": "", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TEdit" + }, + { + "astType": "object", + "children": [], + "kind": "inline", + "name": "Edit2", + "properties": [], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TEdit" + }, + { + "astType": "object", + "children": [], + "kind": "inherited", + "name": "Edit3", + "properties": [], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TEdit" + }, + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [], + "kind": "object", + "name": "DeepTree10", + "properties": [], + "raws": { + "afterName": "", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree9", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree8", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree7", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree6", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree5", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree4", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree3", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree2", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "DeepTree1", + "properties": [], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "TComponent" + } + ], + "kind": "object", + "name": "_Under_Score", + "properties": [], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeType": " " + }, + "type": "_TUnder_Score" + } + ], + "kind": "object", + "name": "BasicForm", + "properties": [ + { + "astType": "property", + "name": "Caption", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Basic Form" + } + ] + } + } + ], + "raws": { + "afterName": "", + "beforeChildren": "\r\n ", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TForm" + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/properties/ast.json b/__test__/__fixtures__/parse/properties/ast.json index 46c84938..ab686091 100644 --- a/__test__/__fixtures__/parse/properties/ast.json +++ b/__test__/__fixtures__/parse/properties/ast.json @@ -1,320 +1,320 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [], - "kind": "object", - "name": "Form", - "properties": [ - { - "astType": "property", - "name": "BooleanProperty", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - }, - { - "astType": "property", - "name": "BooleanProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": false - } - }, - { - "astType": "property", - "name": "IntegerProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "integer", - "value": "123456" - } - }, - { - "astType": "property", - "name": "IntegerProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "integer", - "value": "-123456" - } - }, - { - "astType": "property", - "name": "FloatProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "fraction": "456", - "integer": "123" - } - } - }, - { - "astType": "property", - "name": "FloatProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "fraction": "456", - "integer": "-123" - } - } - }, - { - "astType": "property", - "name": "FloatProperty3", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "456", - "integer": "123" - } - } - }, - { - "astType": "property", - "name": "FloatProperty4", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "456", - "integer": "-123" - } - } - }, - { - "astType": "property", - "name": "FloatProperty5", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "56", - "fraction": "34", - "integer": "12" - } - } - }, - { - "astType": "property", - "name": "FloatProperty6", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "56", - "fraction": "34", - "integer": "-12" - } - } - }, - { - "astType": "property", - "name": "SingleProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "single", - "value": { - "integer": "2" - } - } - }, - { - "astType": "property", - "name": "SingleProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "single", - "value": { - "exponent": "5", - "fraction": "4", - "integer": "-2" - } - } - }, - { - "astType": "property", - "name": "DateTimeProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "dateTime", - "value": { - "integer": "3" - } - } - }, - { - "astType": "property", - "name": "DateTimeProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "dateTime", - "value": { - "exponent": "5", - "fraction": "4", - "integer": "-2" - } - } - }, - { - "astType": "property", - "name": "CurrencyProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "currency", - "value": { - "integer": "4" - } - } - }, - { - "astType": "property", - "name": "CurrencyProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "currency", - "value": { - "exponent": "5", - "fraction": "4", - "integer": "-2" - } - } - }, - { - "astType": "property", - "name": "ColorProperty", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "hexCode", - "value": "7F7F7F" - } - }, - { - "astType": "property", - "name": "QualifiedValue", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "identifier", - "value": "TEnum.enEnum" - } - }, - { - "astType": "property", - "name": "Qualified.Property", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - }, - { - "astType": "property", - "name": "Border.Bottom.Style", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "identifier", - "value": "bsSolid" - } - } - ], - "raws": { - "afterName": "", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TForm" - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [], + "kind": "object", + "name": "Form", + "properties": [ + { + "astType": "property", + "name": "BooleanProperty", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + }, + { + "astType": "property", + "name": "BooleanProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": false + } + }, + { + "astType": "property", + "name": "IntegerProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "integer", + "value": "123456" + } + }, + { + "astType": "property", + "name": "IntegerProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "integer", + "value": "-123456" + } + }, + { + "astType": "property", + "name": "FloatProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "fraction": "456", + "integer": "123" + } + } + }, + { + "astType": "property", + "name": "FloatProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "fraction": "456", + "integer": "-123" + } + } + }, + { + "astType": "property", + "name": "FloatProperty3", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "456", + "integer": "123" + } + } + }, + { + "astType": "property", + "name": "FloatProperty4", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "456", + "integer": "-123" + } + } + }, + { + "astType": "property", + "name": "FloatProperty5", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "56", + "fraction": "34", + "integer": "12" + } + } + }, + { + "astType": "property", + "name": "FloatProperty6", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "56", + "fraction": "34", + "integer": "-12" + } + } + }, + { + "astType": "property", + "name": "SingleProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "single", + "value": { + "integer": "2" + } + } + }, + { + "astType": "property", + "name": "SingleProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "single", + "value": { + "exponent": "5", + "fraction": "4", + "integer": "-2" + } + } + }, + { + "astType": "property", + "name": "DateTimeProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "dateTime", + "value": { + "integer": "3" + } + } + }, + { + "astType": "property", + "name": "DateTimeProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "dateTime", + "value": { + "exponent": "5", + "fraction": "4", + "integer": "-2" + } + } + }, + { + "astType": "property", + "name": "CurrencyProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "currency", + "value": { + "integer": "4" + } + } + }, + { + "astType": "property", + "name": "CurrencyProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "currency", + "value": { + "exponent": "5", + "fraction": "4", + "integer": "-2" + } + } + }, + { + "astType": "property", + "name": "ColorProperty", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "hexCode", + "value": "7F7F7F" + } + }, + { + "astType": "property", + "name": "QualifiedValue", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "identifier", + "value": "TEnum.enEnum" + } + }, + { + "astType": "property", + "name": "Qualified.Property", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + }, + { + "astType": "property", + "name": "Border.Bottom.Style", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "identifier", + "value": "bsSolid" + } + } + ], + "raws": { + "afterName": "", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TForm" + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/strings/ast.json b/__test__/__fixtures__/parse/strings/ast.json index bf0438d6..5b2b2022 100644 --- a/__test__/__fixtures__/parse/strings/ast.json +++ b/__test__/__fixtures__/parse/strings/ast.json @@ -1,164 +1,164 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [], - "kind": "object", - "name": "Form", - "properties": [ - { - "astType": "property", - "name": "StringProperty", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "" - } - ] - } - }, - { - "astType": "property", - "name": "StringProperty2", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Hello world!" - } - ] - } - }, - { - "astType": "property", - "name": "StringProperty3", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Hello'world!" - } - ] - } - }, - { - "astType": "property", - "name": "StringProperty3", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Hello" - }, - { - "astType": "literalString", - "raws": { - "before": " + " - }, - "value": "world!" - } - ] - } - }, - { - "astType": "property", - "name": "StringProperty4", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Hello" - }, - { - "astType": "controlString", - "value": "\r" - }, - { - "astType": "controlString", - "value": "\n" - }, - { - "astType": "literalString", - "value": "world!" - } - ] - } - }, - { - "astType": "property", - "name": "StringProperty5", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Hello'" - }, - { - "astType": "controlString", - "value": "\r" - }, - { - "astType": "controlString", - "value": "\n" - }, - { - "astType": "literalString", - "raws": { - "before": " + " - }, - "value": "world!" - } - ] - } - } - ], - "raws": { - "afterName": "", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TForm" - }, - "raws": { - "after": "", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [], + "kind": "object", + "name": "Form", + "properties": [ + { + "astType": "property", + "name": "StringProperty", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "" + } + ] + } + }, + { + "astType": "property", + "name": "StringProperty2", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Hello world!" + } + ] + } + }, + { + "astType": "property", + "name": "StringProperty3", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Hello'world!" + } + ] + } + }, + { + "astType": "property", + "name": "StringProperty3", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Hello" + }, + { + "astType": "literalString", + "raws": { + "before": " + " + }, + "value": "world!" + } + ] + } + }, + { + "astType": "property", + "name": "StringProperty4", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Hello" + }, + { + "astType": "controlString", + "value": "\r" + }, + { + "astType": "controlString", + "value": "\n" + }, + { + "astType": "literalString", + "value": "world!" + } + ] + } + }, + { + "astType": "property", + "name": "StringProperty5", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Hello'" + }, + { + "astType": "controlString", + "value": "\r" + }, + { + "astType": "controlString", + "value": "\n" + }, + { + "astType": "literalString", + "raws": { + "before": " + " + }, + "value": "world!" + } + ] + } + } + ], + "raws": { + "afterName": "", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TForm" + }, + "raws": { + "after": "", + "before": "" + } +} diff --git a/__test__/__fixtures__/parse/weird-spacing/ast.json b/__test__/__fixtures__/parse/weird-spacing/ast.json index 5be78851..a7a37e3c 100644 --- a/__test__/__fixtures__/parse/weird-spacing/ast.json +++ b/__test__/__fixtures__/parse/weird-spacing/ast.json @@ -1,822 +1,822 @@ -{ - "astType": "root", - "child": { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [], - "kind": "object", - "name": "Image1", - "properties": [ - { - "astType": "property", - "name": "Picture.Data", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "binaryStringList", - "raws": { - "afterOpen": "\r\n\r\n ", - "beforeClose": "\r\n " - }, - "values": [ - { - "astType": "binaryString", - "value": "07544269746D617036550000424D365500000000000036000000280000005500" - }, - { - "astType": "binaryString", - "raws": { - "before": "\r\n\r\n " - }, - "value": "000055000000010018000000000000550000C40E0000C40E0000000000000000" - } - ] - } - }, - { - "astType": "property", - "name": "Picture.MoreData", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "binaryStringList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - } - ], - "raws": { - "afterName": "", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TImage" - }, - { - "astType": "object", - "children": [], - "kind": "inherited", - "name": "ListBox1", - "order": "2", - "properties": [ - { - "astType": "property", - "name": "Items.Strings", - "raws": { - "afterName": " ", - "beforeValue": "\r\n " - }, - "value": { - "astType": "variantList", - "raws": { - "afterOpen": " ", - "beforeClose": "\r\n " - }, - "values": [ - { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "this is string." - } - ] - }, - { - "astType": "string", - "raws": { - "before": " " - }, - "value": [ - { - "astType": "literalString", - "value": "and another one..." - }, - { - "astType": "literalString", - "raws": { - "before": " + " - }, - "value": "and another one..." - }, - { - "astType": "literalString", - "raws": { - "before": "+ " - }, - "value": "now with apostrophe '" - }, - { - "astType": "controlString", - "value": "\r" - }, - { - "astType": "controlString", - "value": "\n" - }, - { - "astType": "literalString", - "value": "how fancy" - } - ] - } - ] - } - }, - { - "astType": "property", - "name": "Items.MoreStrings", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "variantList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - } - ], - "raws": { - "afterName": "", - "afterOrder": "", - "afterType": " ", - "before": "\r\n\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeOrder": "", - "beforeProperties": "\r\n\r\n ", - "beforeType": " " - }, - "type": "TListBox" - }, - { - "astType": "object", - "children": [], - "kind": "object", - "name": "DBGrid1", - "properties": [ - { - "astType": "property", - "name": "Options", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "identifierList", - "raws": { - "afterOpen": "", - "beforeClose": "" - }, - "values": [ - { - "astType": "identifier", - "raws": { - "after": "" - }, - "value": "dgTitles" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dg_Indicator" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "" - }, - "value": "dgColumnResize" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "" - }, - "value": "dgColLines" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": "" - }, - "value": "dgRowLines" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgTabs" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgRowSelect" - }, - { - "astType": "identifier", - "raws": { - "after": "", - "before": " " - }, - "value": "dgConfirmDelete" - }, - { - "astType": "identifier", - "raws": { - "before": " " - }, - "value": "dgCancelOnExit" - } - ] - } - }, - { - "astType": "property", - "name": "MoreOptions", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "identifierList", - "raws": { - "beforeClose": "\r\n\r\n\r\n " - }, - "values": [] - } - }, - { - "astType": "property", - "name": "Columns", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "itemList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": "" - }, - "values": [ - { - "astType": "item", - "properties": [ - { - "astType": "property", - "name": "Expanded", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": false - } - }, - { - "astType": "property", - "name": "Visible", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - } - ], - "raws": { - "afterItem": "\r\n ", - "beforeEnd": "\r\n " - } - }, - { - "astType": "item", - "properties": [], - "raws": { - "afterItem": "\r\n ", - "before": "\r\n " - } - }, - { - "astType": "item", - "properties": [ - { - "astType": "property", - "name": "Expanded", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": false - } - }, - { - "astType": "property", - "name": "Visible", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "boolean", - "value": true - } - } - ], - "raws": { - "afterItem": "\r\n ", - "before": "\r\n ", - "beforeEnd": "\r\n " - } - } - ] - } - }, - { - "astType": "property", - "name": "MoreColumns", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "itemList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - } - ], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TDBGrid" - }, - { - "astType": "object", - "children": [], - "kind": "inline", - "name": "Edit1", - "properties": [ - { - "astType": "property", - "name": "MaxLength", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "20", - "integer": "6" - } - } - }, - { - "astType": "property", - "name": "MinLength", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "1", - "integer": "-20" - } - } - }, - { - "astType": "property", - "name": "SomeOtherLength", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "double", - "value": { - "exponent": "20", - "fraction": "333", - "integer": "45" - } - } - }, - { - "astType": "property", - "name": "Color", - "raws": { - "afterName": " ", - "before": "\r\n\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "hexCode", - "value": "FF0000" - } - }, - { - "astType": "property", - "name": "BackgroundColorStreamer", - "raws": { - "afterName": " ", - "before": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "variantList", - "raws": { - "afterOpen": "\r\n ", - "beforeClose": " " - }, - "values": [ - { - "astType": "integer", - "value": "255" - }, - { - "astType": "integer", - "raws": { - "before": " " - }, - "value": "255" - }, - { - "astType": "integer", - "raws": { - "before": " " - }, - "value": "255" - }, - { - "astType": "boolean", - "raws": { - "before": " " - }, - "value": true - } - ] - } - } - ], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TEdit" - }, - { - "astType": "object", - "children": [], - "kind": "object", - "name": "MyContainer", - "properties": [ - { - "astType": "property", - "name": "Cost", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "currency", - "value": { - "fraction": "5", - "integer": "32" - } - } - }, - { - "astType": "property", - "name": "MinCost", - "raws": { - "afterName": " ", - "before": " ", - "beforeValue": " " - }, - "value": { - "astType": "currency", - "value": { - "integer": "0" - } - } - }, - { - "astType": "property", - "name": "Multiplier", - "raws": { - "afterName": " ", - "before": " ", - "beforeValue": " " - }, - "value": { - "astType": "single", - "value": { - "fraction": "5", - "integer": "12" - } - } - }, - { - "astType": "property", - "name": "Date", - "raws": { - "afterName": " ", - "before": " ", - "beforeValue": " " - }, - "value": { - "astType": "dateTime", - "value": { - "fraction": "1", - "integer": "47000" - } - } - } - ], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": " ", - "beforeName": " ", - "beforeProperties": " ", - "beforeType": " " - }, - "type": "TContainer" - }, - { - "astType": "object", - "children": [], - "kind": "object", - "name": "Edit2", - "properties": [ - { - "astType": "property", - "name": "Value", - "raws": { - "afterName": " ", - "beforeValue": "\r\n " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "Some 'multi' line " - }, - { - "astType": "literalString", - "raws": { - "before": " +\r\n " - }, - "value": "string" - }, - { - "astType": "controlString", - "value": "\r" - }, - { - "astType": "controlString", - "value": "\n" - }, - { - "astType": "controlString", - "raws": { - "before": " +\r\n " - }, - "value": "%" - }, - { - "astType": "literalString", - "value": "hello" - }, - { - "astType": "controlString", - "value": "-" - }, - { - "astType": "literalString", - "value": "world" - } - ] - } - } - ], - "raws": { - "afterName": "", - "before": "\r\n ", - "beforeEnd": "\r\n ", - "beforeName": " ", - "beforeProperties": "\r\n\r\n\r\n ", - "beforeType": " " - }, - "type": "TEdit" - }, - { - "astType": "object", - "children": [ - { - "astType": "object", - "children": [], - "kind": "inline", - "name": "SubEdit", - "properties": [ - { - "astType": "property", - "name": "Value", - "raws": { - "afterName": " ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "" - } - ] - } - }, - { - "astType": "property", - "name": "EditType", - "raws": { - "afterName": " ", - "before": "\r\n", - "beforeValue": " " - }, - "value": { - "astType": "identifier", - "value": "TEdit.TypeEnum.PASSWORD" - } - } - ], - "raws": { - "afterName": "", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeProperties": "\r\n", - "beforeType": " " - }, - "type": "TEdit" - } - ], - "kind": "object", - "name": "SubForm", - "properties": [], - "raws": { - "afterName": "", - "before": "\r\n", - "beforeChildren": "\r\n", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeType": " " - }, - "type": "TForm2" - }, - { - "astType": "object", - "children": [], - "kind": "object", - "name": "Nothing", - "properties": [], - "raws": { - "afterName": "", - "before": "\r\n", - "beforeEnd": "\r\n", - "beforeName": " ", - "beforeType": " " - }, - "type": "_TNothing" - } - ], - "kind": "object", - "name": "Form1", - "properties": [ - { - "astType": "property", - "name": "Left", - "raws": { - "afterName": " ", - "beforeValue": "\r\n\r\n\r\n\r\n " - }, - "value": { - "astType": "integer", - "value": "192" - } - }, - { - "astType": "property", - "name": "Font.Name", - "raws": { - "afterName": " ", - "before": "\r\n ", - "beforeValue": " " - }, - "value": { - "astType": "string", - "value": [ - { - "astType": "literalString", - "value": "MS Sans Serif" - } - ] - } - }, - { - "astType": "property", - "name": "Font.Style", - "raws": { - "afterName": " ", - "before": " ", - "beforeValue": " " - }, - "value": { - "astType": "identifierList", - "raws": { - "beforeClose": "" - }, - "values": [] - } - }, - { - "astType": "property", - "name": "Border.Bottom.Style", - "raws": { - "afterName": " ", - "before": " ", - "beforeValue": " " - }, - "value": { - "astType": "identifier", - "value": "bdSolid" - } - } - ], - "raws": { - "afterName": "", - "beforeChildren": " ", - "beforeEnd": "\r\n", - "beforeName": "\r\n\r\n\r\n\r\n ", - "beforeProperties": "\r\n ", - "beforeType": " " - }, - "type": "TForm1" - }, - "raws": { - "after": "\r\n", - "before": "" - } -} +{ + "astType": "root", + "child": { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [], + "kind": "object", + "name": "Image1", + "properties": [ + { + "astType": "property", + "name": "Picture.Data", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "binaryStringList", + "raws": { + "afterOpen": "\r\n\r\n ", + "beforeClose": "\r\n " + }, + "values": [ + { + "astType": "binaryString", + "value": "07544269746D617036550000424D365500000000000036000000280000005500" + }, + { + "astType": "binaryString", + "raws": { + "before": "\r\n\r\n " + }, + "value": "000055000000010018000000000000550000C40E0000C40E0000000000000000" + } + ] + } + }, + { + "astType": "property", + "name": "Picture.MoreData", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "binaryStringList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + } + ], + "raws": { + "afterName": "", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TImage" + }, + { + "astType": "object", + "children": [], + "kind": "inherited", + "name": "ListBox1", + "order": "2", + "properties": [ + { + "astType": "property", + "name": "Items.Strings", + "raws": { + "afterName": " ", + "beforeValue": "\r\n " + }, + "value": { + "astType": "variantList", + "raws": { + "afterOpen": " ", + "beforeClose": "\r\n " + }, + "values": [ + { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "this is string." + } + ] + }, + { + "astType": "string", + "raws": { + "before": " " + }, + "value": [ + { + "astType": "literalString", + "value": "and another one..." + }, + { + "astType": "literalString", + "raws": { + "before": " + " + }, + "value": "and another one..." + }, + { + "astType": "literalString", + "raws": { + "before": "+ " + }, + "value": "now with apostrophe '" + }, + { + "astType": "controlString", + "value": "\r" + }, + { + "astType": "controlString", + "value": "\n" + }, + { + "astType": "literalString", + "value": "how fancy" + } + ] + } + ] + } + }, + { + "astType": "property", + "name": "Items.MoreStrings", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "variantList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + } + ], + "raws": { + "afterName": "", + "afterOrder": "", + "afterType": " ", + "before": "\r\n\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeOrder": "", + "beforeProperties": "\r\n\r\n ", + "beforeType": " " + }, + "type": "TListBox" + }, + { + "astType": "object", + "children": [], + "kind": "object", + "name": "DBGrid1", + "properties": [ + { + "astType": "property", + "name": "Options", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "identifierList", + "raws": { + "afterOpen": "", + "beforeClose": "" + }, + "values": [ + { + "astType": "identifier", + "raws": { + "after": "" + }, + "value": "dgTitles" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dg_Indicator" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "" + }, + "value": "dgColumnResize" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "" + }, + "value": "dgColLines" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": "" + }, + "value": "dgRowLines" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgTabs" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgRowSelect" + }, + { + "astType": "identifier", + "raws": { + "after": "", + "before": " " + }, + "value": "dgConfirmDelete" + }, + { + "astType": "identifier", + "raws": { + "before": " " + }, + "value": "dgCancelOnExit" + } + ] + } + }, + { + "astType": "property", + "name": "MoreOptions", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "identifierList", + "raws": { + "beforeClose": "\r\n\r\n\r\n " + }, + "values": [] + } + }, + { + "astType": "property", + "name": "Columns", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "itemList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": "" + }, + "values": [ + { + "astType": "item", + "properties": [ + { + "astType": "property", + "name": "Expanded", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": false + } + }, + { + "astType": "property", + "name": "Visible", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + } + ], + "raws": { + "afterItem": "\r\n ", + "beforeEnd": "\r\n " + } + }, + { + "astType": "item", + "properties": [], + "raws": { + "afterItem": "\r\n ", + "before": "\r\n " + } + }, + { + "astType": "item", + "properties": [ + { + "astType": "property", + "name": "Expanded", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": false + } + }, + { + "astType": "property", + "name": "Visible", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "boolean", + "value": true + } + } + ], + "raws": { + "afterItem": "\r\n ", + "before": "\r\n ", + "beforeEnd": "\r\n " + } + } + ] + } + }, + { + "astType": "property", + "name": "MoreColumns", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "itemList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + } + ], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TDBGrid" + }, + { + "astType": "object", + "children": [], + "kind": "inline", + "name": "Edit1", + "properties": [ + { + "astType": "property", + "name": "MaxLength", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "20", + "integer": "6" + } + } + }, + { + "astType": "property", + "name": "MinLength", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "1", + "integer": "-20" + } + } + }, + { + "astType": "property", + "name": "SomeOtherLength", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "double", + "value": { + "exponent": "20", + "fraction": "333", + "integer": "45" + } + } + }, + { + "astType": "property", + "name": "Color", + "raws": { + "afterName": " ", + "before": "\r\n\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "hexCode", + "value": "FF0000" + } + }, + { + "astType": "property", + "name": "BackgroundColorStreamer", + "raws": { + "afterName": " ", + "before": "\r\n\r\n\r\n\r\n\r\n\r\n\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "variantList", + "raws": { + "afterOpen": "\r\n ", + "beforeClose": " " + }, + "values": [ + { + "astType": "integer", + "value": "255" + }, + { + "astType": "integer", + "raws": { + "before": " " + }, + "value": "255" + }, + { + "astType": "integer", + "raws": { + "before": " " + }, + "value": "255" + }, + { + "astType": "boolean", + "raws": { + "before": " " + }, + "value": true + } + ] + } + } + ], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TEdit" + }, + { + "astType": "object", + "children": [], + "kind": "object", + "name": "MyContainer", + "properties": [ + { + "astType": "property", + "name": "Cost", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "currency", + "value": { + "fraction": "5", + "integer": "32" + } + } + }, + { + "astType": "property", + "name": "MinCost", + "raws": { + "afterName": " ", + "before": " ", + "beforeValue": " " + }, + "value": { + "astType": "currency", + "value": { + "integer": "0" + } + } + }, + { + "astType": "property", + "name": "Multiplier", + "raws": { + "afterName": " ", + "before": " ", + "beforeValue": " " + }, + "value": { + "astType": "single", + "value": { + "fraction": "5", + "integer": "12" + } + } + }, + { + "astType": "property", + "name": "Date", + "raws": { + "afterName": " ", + "before": " ", + "beforeValue": " " + }, + "value": { + "astType": "dateTime", + "value": { + "fraction": "1", + "integer": "47000" + } + } + } + ], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": " ", + "beforeName": " ", + "beforeProperties": " ", + "beforeType": " " + }, + "type": "TContainer" + }, + { + "astType": "object", + "children": [], + "kind": "object", + "name": "Edit2", + "properties": [ + { + "astType": "property", + "name": "Value", + "raws": { + "afterName": " ", + "beforeValue": "\r\n " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "Some 'multi' line " + }, + { + "astType": "literalString", + "raws": { + "before": " +\r\n " + }, + "value": "string" + }, + { + "astType": "controlString", + "value": "\r" + }, + { + "astType": "controlString", + "value": "\n" + }, + { + "astType": "controlString", + "raws": { + "before": " +\r\n " + }, + "value": "%" + }, + { + "astType": "literalString", + "value": "hello" + }, + { + "astType": "controlString", + "value": "-" + }, + { + "astType": "literalString", + "value": "world" + } + ] + } + } + ], + "raws": { + "afterName": "", + "before": "\r\n ", + "beforeEnd": "\r\n ", + "beforeName": " ", + "beforeProperties": "\r\n\r\n\r\n ", + "beforeType": " " + }, + "type": "TEdit" + }, + { + "astType": "object", + "children": [ + { + "astType": "object", + "children": [], + "kind": "inline", + "name": "SubEdit", + "properties": [ + { + "astType": "property", + "name": "Value", + "raws": { + "afterName": " ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "" + } + ] + } + }, + { + "astType": "property", + "name": "EditType", + "raws": { + "afterName": " ", + "before": "\r\n", + "beforeValue": " " + }, + "value": { + "astType": "identifier", + "value": "TEdit.TypeEnum.PASSWORD" + } + } + ], + "raws": { + "afterName": "", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeProperties": "\r\n", + "beforeType": " " + }, + "type": "TEdit" + } + ], + "kind": "object", + "name": "SubForm", + "properties": [], + "raws": { + "afterName": "", + "before": "\r\n", + "beforeChildren": "\r\n", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeType": " " + }, + "type": "TForm2" + }, + { + "astType": "object", + "children": [], + "kind": "object", + "name": "Nothing", + "properties": [], + "raws": { + "afterName": "", + "before": "\r\n", + "beforeEnd": "\r\n", + "beforeName": " ", + "beforeType": " " + }, + "type": "_TNothing" + } + ], + "kind": "object", + "name": "Form1", + "properties": [ + { + "astType": "property", + "name": "Left", + "raws": { + "afterName": " ", + "beforeValue": "\r\n\r\n\r\n\r\n " + }, + "value": { + "astType": "integer", + "value": "192" + } + }, + { + "astType": "property", + "name": "Font.Name", + "raws": { + "afterName": " ", + "before": "\r\n ", + "beforeValue": " " + }, + "value": { + "astType": "string", + "value": [ + { + "astType": "literalString", + "value": "MS Sans Serif" + } + ] + } + }, + { + "astType": "property", + "name": "Font.Style", + "raws": { + "afterName": " ", + "before": " ", + "beforeValue": " " + }, + "value": { + "astType": "identifierList", + "raws": { + "beforeClose": "" + }, + "values": [] + } + }, + { + "astType": "property", + "name": "Border.Bottom.Style", + "raws": { + "afterName": " ", + "before": " ", + "beforeValue": " " + }, + "value": { + "astType": "identifier", + "value": "bdSolid" + } + } + ], + "raws": { + "afterName": "", + "beforeChildren": " ", + "beforeEnd": "\r\n", + "beforeName": "\r\n\r\n\r\n\r\n ", + "beforeProperties": "\r\n ", + "beforeType": " " + }, + "type": "TForm1" + }, + "raws": { + "after": "\r\n", + "before": "" + } +} diff --git a/__test__/__fixtures__/transform/hello-world/transformer.js b/__test__/__fixtures__/transform/hello-world/transformer.js index 31ccd8f4..51a3ef43 100644 --- a/__test__/__fixtures__/transform/hello-world/transformer.js +++ b/__test__/__fixtures__/transform/hello-world/transformer.js @@ -1,7 +1,7 @@ function gatherObjects(object) { return [].concat( object, - object.children.map(child => gatherObjects(child)) + object.children.map((child) => gatherObjects(child)) ); } @@ -14,15 +14,12 @@ function gatherProperties(object) { } function visitProperties(object, callback) { - gatherProperties(object).forEach(property => callback(property)); + gatherProperties(object).forEach((property) => callback(property)); } -module.exports = ast => { - visitProperties(ast.child, property => { - property.name = property.name - .split("") - .reverse() - .join(""); +module.exports = (ast) => { + visitProperties(ast.child, (property) => { + property.name = property.name.split("").reverse().join(""); }); return ast; diff --git a/commitlint.config.js b/commitlint.config.js index 207b59fd..69b4242c 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1,3 @@ -module.exports = { - extends: ["@commitlint/config-conventional"] -}; +module.exports = { + extends: ["@commitlint/config-conventional"], +}; diff --git a/eslint.config.js b/eslint.config.js index 6779929f..43a5ab0b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,45 +1,45 @@ -module.exports = function getConfig(enableTypeChecking) { - return { - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint"], - settings: { - node: { - allowModules: ["@postdfm/ast2dfm", "@postdfm/ast", "@postdfm/dfm2ast"], - tryExtensions: [".js", ".ts", ".json", ".node"] - } - }, - parserOptions: { - project: "./tsconfig.json" - }, - extends: [ - "eslint:recommended", - "plugin:node/recommended", - "plugin:jest/recommended", - "prettier" - ], - overrides: [ - { - files: ["*.ts"], - extends: [ - "eslint:recommended", - "plugin:node/recommended", - "plugin:jest/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - enableTypeChecking && - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "prettier", - "prettier/@typescript-eslint" - ].filter(v => !!v), - rules: { - "node/no-unsupported-features/es-syntax": [ - "error", - { - ignores: ["modules"] - } - ] - } - } - ] - }; -}; +module.exports = function getConfig(enableTypeChecking) { + return { + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + settings: { + node: { + allowModules: ["@postdfm/ast2dfm", "@postdfm/ast", "@postdfm/dfm2ast"], + tryExtensions: [".js", ".ts", ".json", ".node"], + }, + }, + parserOptions: { + project: "./tsconfig.json", + }, + extends: [ + "eslint:recommended", + "plugin:node/recommended", + "plugin:jest/recommended", + "prettier", + ], + overrides: [ + { + files: ["*.ts"], + extends: [ + "eslint:recommended", + "plugin:node/recommended", + "plugin:jest/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + enableTypeChecking && + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier", + "prettier/@typescript-eslint", + ].filter((v) => !!v), + rules: { + "node/no-unsupported-features/es-syntax": [ + "error", + { + ignores: ["modules"], + }, + ], + }, + }, + ], + }; +}; diff --git a/jest.config.js b/jest.config.js index d3be67fc..2365bf1e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,21 +8,21 @@ module.exports = { classNameTemplate: "[{classname}]", titleTemplate: "{title}", outputDirectory: "test-results/jest", - outputName: "./report.xml" - } - ] + outputName: "./report.xml", + }, + ], ], transform: { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.tsx?$": "ts-jest", }, collectCoverage: true, collectCoverageFrom: [ "**/*.ts", "!**/node_modules/**", "!**/dist/**", - "!packages/@postdfm/dfm2ast/src/grammar.ts" + "!packages/@postdfm/dfm2ast/src/grammar.ts", ], coverageReporters: ["lcov", "text"], coverageDirectory: "coverage", - rootDir: "./" + rootDir: "./", }; diff --git a/packages/@postdfm/ast/.eslintrc.js b/packages/@postdfm/ast/.eslintrc.js index d177fd35..dad6750a 100644 --- a/packages/@postdfm/ast/.eslintrc.js +++ b/packages/@postdfm/ast/.eslintrc.js @@ -1 +1 @@ -module.exports = require("../../../eslint.config.js")(true); +module.exports = require("../../../eslint.config.js")(true); diff --git a/packages/@postdfm/ast/README.md b/packages/@postdfm/ast/README.md index a4e22016..e6943463 100644 --- a/packages/@postdfm/ast/README.md +++ b/packages/@postdfm/ast/README.md @@ -1,12 +1,12 @@ -# @postdfm/ast - -[![npm](https://img.shields.io/npm/v/@postdfm/ast.svg?label=npm)](https://www.npmjs.com/package/@postdfm/ast) -[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) -[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) -[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/ast/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/ast/package.json) - -Sub-package for `postdfm`. - -Provides the AST structures used by `postdfm`. - -See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/ast/). +# @postdfm/ast + +[![npm](https://img.shields.io/npm/v/@postdfm/ast.svg?label=npm)](https://www.npmjs.com/package/@postdfm/ast) +[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) +[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) +[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/ast/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/ast/package.json) + +Sub-package for `postdfm`. + +Provides the AST structures used by `postdfm`. + +See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/ast/). diff --git a/packages/@postdfm/ast/__test__/item.test.ts b/packages/@postdfm/ast/__test__/item.test.ts index 0ced4da0..3ca1e4c4 100644 --- a/packages/@postdfm/ast/__test__/item.test.ts +++ b/packages/@postdfm/ast/__test__/item.test.ts @@ -1,19 +1,19 @@ -import * as AST from "../src"; - -describe("creating Items", () => { - test("empty Item", () => { - const node = new AST.Item(); - - expect(node.properties).toHaveLength(0); - }); - - test("Item", () => { - const propertyNode = new AST.Property( - "Font.Name", - new AST.StringValue([new AST.LiteralString("sans-serif")]) - ); - const node = new AST.Item([propertyNode]); - - expect(node.properties).toContainEqual(propertyNode); - }); -}); +import * as AST from "../src"; + +describe("creating Items", () => { + test("empty Item", () => { + const node = new AST.Item(); + + expect(node.properties).toHaveLength(0); + }); + + test("Item", () => { + const propertyNode = new AST.Property( + "Font.Name", + new AST.StringValue([new AST.LiteralString("sans-serif")]) + ); + const node = new AST.Item([propertyNode]); + + expect(node.properties).toContainEqual(propertyNode); + }); +}); diff --git a/packages/@postdfm/ast/__test__/list.test.ts b/packages/@postdfm/ast/__test__/list.test.ts index 5720ef8e..05b2e889 100644 --- a/packages/@postdfm/ast/__test__/list.test.ts +++ b/packages/@postdfm/ast/__test__/list.test.ts @@ -1,75 +1,75 @@ -import * as AST from "../src"; - -describe("creating Lists", () => { - test("empty VariantList", () => { - const node = new AST.VariantList(); - - expect(node.values).toHaveLength(0); - }); - - test("VariantList", () => { - const node = new AST.VariantList([ - new AST.StringValue([new AST.LiteralString("hello")]), - new AST.IntegerValue(255), - new AST.BooleanValue(true), - new AST.StringValue([new AST.LiteralString("world")]) - ]); - - expect(node.values).toContainEqual( - new AST.StringValue([new AST.LiteralString("world")]) - ); - - expect(node.values).toContainEqual(new AST.IntegerValue(255)); - - expect(node.values).toContainEqual(new AST.BooleanValue(true)); - }); - - test("empty BinaryStringList", () => { - const node = new AST.BinaryStringList(); - - expect(node.values).toHaveLength(0); - }); - - test("BinaryStringList", () => { - const node = new AST.BinaryStringList([ - new AST.BinaryStringValue("BADA55"), - new AST.BinaryStringValue("C0FFEE") - ]); - - expect(node.values).toContainEqual(new AST.BinaryStringValue("C0FFEE")); - }); - - test("empty QualifiedList", () => { - const node = new AST.IdentifierList(); - - expect(node.values).toHaveLength(0); - }); - - test("QualifiedList", () => { - const node = new AST.IdentifierList([ - new AST.IdentifierValue("enHello"), - new AST.IdentifierValue("enWorld") - ]); - - expect(node.values).toContainEqual(new AST.IdentifierValue("enWorld")); - }); - - test("empty ItemList", () => { - const node = new AST.ItemList(); - - expect(node.values).toHaveLength(0); - }); - - test("ItemList", () => { - const itemNode1 = new AST.Item(); - const itemNode2 = new AST.Item([ - new AST.Property( - "Font.Name", - new AST.StringValue([new AST.LiteralString("sans-serif")]) - ) - ]); - const node = new AST.ItemList([itemNode1, itemNode2]); - - expect(node.values).toContainEqual(itemNode2); - }); -}); +import * as AST from "../src"; + +describe("creating Lists", () => { + test("empty VariantList", () => { + const node = new AST.VariantList(); + + expect(node.values).toHaveLength(0); + }); + + test("VariantList", () => { + const node = new AST.VariantList([ + new AST.StringValue([new AST.LiteralString("hello")]), + new AST.IntegerValue(255), + new AST.BooleanValue(true), + new AST.StringValue([new AST.LiteralString("world")]), + ]); + + expect(node.values).toContainEqual( + new AST.StringValue([new AST.LiteralString("world")]) + ); + + expect(node.values).toContainEqual(new AST.IntegerValue(255)); + + expect(node.values).toContainEqual(new AST.BooleanValue(true)); + }); + + test("empty BinaryStringList", () => { + const node = new AST.BinaryStringList(); + + expect(node.values).toHaveLength(0); + }); + + test("BinaryStringList", () => { + const node = new AST.BinaryStringList([ + new AST.BinaryStringValue("BADA55"), + new AST.BinaryStringValue("C0FFEE"), + ]); + + expect(node.values).toContainEqual(new AST.BinaryStringValue("C0FFEE")); + }); + + test("empty QualifiedList", () => { + const node = new AST.IdentifierList(); + + expect(node.values).toHaveLength(0); + }); + + test("QualifiedList", () => { + const node = new AST.IdentifierList([ + new AST.IdentifierValue("enHello"), + new AST.IdentifierValue("enWorld"), + ]); + + expect(node.values).toContainEqual(new AST.IdentifierValue("enWorld")); + }); + + test("empty ItemList", () => { + const node = new AST.ItemList(); + + expect(node.values).toHaveLength(0); + }); + + test("ItemList", () => { + const itemNode1 = new AST.Item(); + const itemNode2 = new AST.Item([ + new AST.Property( + "Font.Name", + new AST.StringValue([new AST.LiteralString("sans-serif")]) + ), + ]); + const node = new AST.ItemList([itemNode1, itemNode2]); + + expect(node.values).toContainEqual(itemNode2); + }); +}); diff --git a/packages/@postdfm/ast/__test__/property.test.ts b/packages/@postdfm/ast/__test__/property.test.ts index ee454c09..a9140227 100644 --- a/packages/@postdfm/ast/__test__/property.test.ts +++ b/packages/@postdfm/ast/__test__/property.test.ts @@ -1,24 +1,24 @@ -import * as AST from "../src"; - -describe("creating Properties", () => { - test("Property with Value", () => { - const valueNode = new AST.StringValue([ - new AST.LiteralString("sans-serif") - ]); - const node = new AST.Property("Font.Name", valueNode); - - expect(node.name).toBe("Font.Name"); - expect(node.value).toEqual(valueNode); - }); - - test("Property with List", () => { - const listNode = new AST.VariantList([ - new AST.StringValue([new AST.LiteralString("Verdana")]), - new AST.StringValue([new AST.LiteralString("sans-serif")]) - ]); - const node = new AST.Property("Font.Name", listNode); - - expect(node.name).toBe("Font.Name"); - expect(node.value).toEqual(listNode); - }); -}); +import * as AST from "../src"; + +describe("creating Properties", () => { + test("Property with Value", () => { + const valueNode = new AST.StringValue([ + new AST.LiteralString("sans-serif"), + ]); + const node = new AST.Property("Font.Name", valueNode); + + expect(node.name).toBe("Font.Name"); + expect(node.value).toEqual(valueNode); + }); + + test("Property with List", () => { + const listNode = new AST.VariantList([ + new AST.StringValue([new AST.LiteralString("Verdana")]), + new AST.StringValue([new AST.LiteralString("sans-serif")]), + ]); + const node = new AST.Property("Font.Name", listNode); + + expect(node.name).toBe("Font.Name"); + expect(node.value).toEqual(listNode); + }); +}); diff --git a/packages/@postdfm/ast/__test__/value.test.ts b/packages/@postdfm/ast/__test__/value.test.ts index 5335bab0..d8e23fe3 100644 --- a/packages/@postdfm/ast/__test__/value.test.ts +++ b/packages/@postdfm/ast/__test__/value.test.ts @@ -1,157 +1,157 @@ -import * as AST from "../src"; - -describe("creating Values", () => { - test("empty ControlString", () => { - const node = new AST.ControlString(); - expect(node.value).toEqual(""); - }); - - test("ControlString", () => { - const node = new AST.ControlString(); - expect(node.value).toEqual(""); - }); - - test("empty LiteralString", () => { - const node = new AST.LiteralString(); - expect(node.value).toEqual(""); - }); - - test("LiteralString", () => { - const node = new AST.LiteralString(); - expect(node.value).toEqual(""); - }); - - test("empty StringValue", () => { - const node = new AST.StringValue(); - expect(node.value).toEqual([]); - }); - - test("StringValue", () => { - const node = new AST.StringValue([ - new AST.LiteralString("hello"), - new AST.ControlString("\r\n"), - new AST.LiteralString("world") - ]); - expect(node.value).toContainEqual(new AST.LiteralString("world")); - }); - - test("empty BinaryStringValue", () => { - const node = new AST.BinaryStringValue(); - expect(node.value).toBe(""); - }); - - test("BinaryStringValue", () => { - const node = new AST.BinaryStringValue("FFFFFFFF"); - expect(node.value).toBe("FFFFFFFF"); - }); - - test("empty HexCodeValue", () => { - const node = new AST.HexCodeValue(); - expect(node.value).toBe(""); - }); - - test("HexCodeValue", () => { - const node = new AST.HexCodeValue("FFFFFFFF"); - expect(node.value).toBe("FFFFFFFF"); - }); - - test("empty IntegerValue", () => { - const node = new AST.IntegerValue(); - expect(node.value).toBe(0); - }); - - test("IntegerValue", () => { - const node = new AST.IntegerValue(1337); - expect(node.value).toBe(1337); - }); - - test("empty DoubleValue", () => { - const node = new AST.DoubleValue(); - - expect(node.value).toEqual({ integer: "0" }); - }); - - test("DoubleValue", () => { - const node = new AST.DoubleValue({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - - expect(node.value).toEqual({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - }); - - test("empty SingleValue", () => { - const node = new AST.SingleValue(); - - expect(node.value).toEqual({ integer: "0" }); - }); - - test("SingleValue", () => { - const node = new AST.SingleValue({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - - expect(node.value).toEqual({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - }); - - test("empty CurrencyValue", () => { - const node = new AST.CurrencyValue(); - - expect(node.value).toEqual({ integer: "0" }); - }); - - test("CurrencyValue", () => { - const node = new AST.CurrencyValue({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - - expect(node.value).toEqual({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - }); - - test("empty DateTimeValue", () => { - const node = new AST.DateTimeValue(); - - expect(node.value).toEqual({ integer: "0" }); - }); - - test("DateTimeValue", () => { - const node = new AST.DateTimeValue({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - - expect(node.value).toEqual({ - exponent: "1337", - fraction: "000069", - integer: "420" - }); - }); - - test("BooleanValue", () => { - const node = new AST.BooleanValue(true); - expect(node.value).toBe(true); - }); - - test("IdentifierValue", () => { - const node = new AST.IdentifierValue("neIdentifier"); - expect(node.value).toBe("neIdentifier"); - }); -}); +import * as AST from "../src"; + +describe("creating Values", () => { + test("empty ControlString", () => { + const node = new AST.ControlString(); + expect(node.value).toEqual(""); + }); + + test("ControlString", () => { + const node = new AST.ControlString(); + expect(node.value).toEqual(""); + }); + + test("empty LiteralString", () => { + const node = new AST.LiteralString(); + expect(node.value).toEqual(""); + }); + + test("LiteralString", () => { + const node = new AST.LiteralString(); + expect(node.value).toEqual(""); + }); + + test("empty StringValue", () => { + const node = new AST.StringValue(); + expect(node.value).toEqual([]); + }); + + test("StringValue", () => { + const node = new AST.StringValue([ + new AST.LiteralString("hello"), + new AST.ControlString("\r\n"), + new AST.LiteralString("world"), + ]); + expect(node.value).toContainEqual(new AST.LiteralString("world")); + }); + + test("empty BinaryStringValue", () => { + const node = new AST.BinaryStringValue(); + expect(node.value).toBe(""); + }); + + test("BinaryStringValue", () => { + const node = new AST.BinaryStringValue("FFFFFFFF"); + expect(node.value).toBe("FFFFFFFF"); + }); + + test("empty HexCodeValue", () => { + const node = new AST.HexCodeValue(); + expect(node.value).toBe(""); + }); + + test("HexCodeValue", () => { + const node = new AST.HexCodeValue("FFFFFFFF"); + expect(node.value).toBe("FFFFFFFF"); + }); + + test("empty IntegerValue", () => { + const node = new AST.IntegerValue(); + expect(node.value).toBe(0); + }); + + test("IntegerValue", () => { + const node = new AST.IntegerValue(1337); + expect(node.value).toBe(1337); + }); + + test("empty DoubleValue", () => { + const node = new AST.DoubleValue(); + + expect(node.value).toEqual({ integer: "0" }); + }); + + test("DoubleValue", () => { + const node = new AST.DoubleValue({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + + expect(node.value).toEqual({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + }); + + test("empty SingleValue", () => { + const node = new AST.SingleValue(); + + expect(node.value).toEqual({ integer: "0" }); + }); + + test("SingleValue", () => { + const node = new AST.SingleValue({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + + expect(node.value).toEqual({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + }); + + test("empty CurrencyValue", () => { + const node = new AST.CurrencyValue(); + + expect(node.value).toEqual({ integer: "0" }); + }); + + test("CurrencyValue", () => { + const node = new AST.CurrencyValue({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + + expect(node.value).toEqual({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + }); + + test("empty DateTimeValue", () => { + const node = new AST.DateTimeValue(); + + expect(node.value).toEqual({ integer: "0" }); + }); + + test("DateTimeValue", () => { + const node = new AST.DateTimeValue({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + + expect(node.value).toEqual({ + exponent: "1337", + fraction: "000069", + integer: "420", + }); + }); + + test("BooleanValue", () => { + const node = new AST.BooleanValue(true); + expect(node.value).toBe(true); + }); + + test("IdentifierValue", () => { + const node = new AST.IdentifierValue("neIdentifier"); + expect(node.value).toBe("neIdentifier"); + }); +}); diff --git a/packages/@postdfm/ast/src/astNode.ts b/packages/@postdfm/ast/src/astNode.ts index 0db085d4..5f05f448 100644 --- a/packages/@postdfm/ast/src/astNode.ts +++ b/packages/@postdfm/ast/src/astNode.ts @@ -1,11 +1,11 @@ -import { ASTType } from "./astType"; -import { ASTRaws } from "./astRaws"; - -export class ASTNode { - public astType: ASTType; - - public raws: R; - constructor(astType: ASTType) { - this.astType = astType; - } -} +import { ASTType } from "./astType"; +import { ASTRaws } from "./astRaws"; + +export class ASTNode { + public astType: ASTType; + + public raws: R; + constructor(astType: ASTType) { + this.astType = astType; + } +} diff --git a/packages/@postdfm/ast/src/astRaws.ts b/packages/@postdfm/ast/src/astRaws.ts index 167c8dc4..bee04aa8 100644 --- a/packages/@postdfm/ast/src/astRaws.ts +++ b/packages/@postdfm/ast/src/astRaws.ts @@ -1,4 +1,4 @@ -export interface ASTRaws { - before?: string; - after?: string; -} +export interface ASTRaws { + before?: string; + after?: string; +} diff --git a/packages/@postdfm/ast/src/astType.ts b/packages/@postdfm/ast/src/astType.ts index 9f423bbd..68e403e7 100644 --- a/packages/@postdfm/ast/src/astType.ts +++ b/packages/@postdfm/ast/src/astType.ts @@ -1,22 +1,22 @@ -export enum ASTType { - String = "string", - ControlString = "controlString", - LiteralString = "literalString", - BinaryString = "binaryString", - Integer = "integer", - HexCode = "hexCode", - Double = "double", - Single = "single", - Currency = "currency", - DateTime = "dateTime", - Boolean = "boolean", - Identifier = "identifier", - Item = "item", - VariantList = "variantList", - BinaryStringList = "binaryStringList", - IdentifierList = "identifierList", - ItemList = "itemList", - Property = "property", - Object = "object", - Root = "root" -} +export enum ASTType { + String = "string", + ControlString = "controlString", + LiteralString = "literalString", + BinaryString = "binaryString", + Integer = "integer", + HexCode = "hexCode", + Double = "double", + Single = "single", + Currency = "currency", + DateTime = "dateTime", + Boolean = "boolean", + Identifier = "identifier", + Item = "item", + VariantList = "variantList", + BinaryStringList = "binaryStringList", + IdentifierList = "identifierList", + ItemList = "itemList", + Property = "property", + Object = "object", + Root = "root", +} diff --git a/packages/@postdfm/ast/src/index.ts b/packages/@postdfm/ast/src/index.ts index e8d2843f..0f36b0bc 100644 --- a/packages/@postdfm/ast/src/index.ts +++ b/packages/@postdfm/ast/src/index.ts @@ -1,35 +1,35 @@ -export { ASTType } from "./astType"; -export { ASTRaws } from "./astRaws"; -export { ASTNode } from "./astNode"; - -export { Keywords } from "./keywords"; - -export { Value } from "./value/value"; -export { StringValue } from "./value/stringValue"; -export { ControlString } from "./value/controlString"; -export { LiteralString } from "./value/literalString"; -export { BinaryStringValue } from "./value/binaryStringValue"; -export { IntegerValue } from "./value/integerValue"; -export { HexCodeValue } from "./value/hexCodeValue"; -export { DoubleValue } from "./value/doubleValue"; -export { SingleValue } from "./value/singleValue"; -export { CurrencyValue } from "./value/currencyValue"; -export { DateTimeValue } from "./value/dateTimeValue"; -export { BooleanValue } from "./value/booleanValue"; -export { IdentifierValue } from "./value/identifierValue"; - -export { Item } from "./item"; - -export { List } from "./list/list"; -export { BinaryStringList } from "./list/binaryStringList"; -export { IdentifierList } from "./list/identifierList"; -export { VariantList } from "./list/variantList"; -export { ItemList } from "./list/itemList"; - -export { Property } from "./property"; - -export { ObjectKind } from "./objectKind"; - -export { DObject } from "./object"; - -export { Root } from "./root"; +export { ASTType } from "./astType"; +export { ASTRaws } from "./astRaws"; +export { ASTNode } from "./astNode"; + +export { Keywords } from "./keywords"; + +export { Value } from "./value/value"; +export { StringValue } from "./value/stringValue"; +export { ControlString } from "./value/controlString"; +export { LiteralString } from "./value/literalString"; +export { BinaryStringValue } from "./value/binaryStringValue"; +export { IntegerValue } from "./value/integerValue"; +export { HexCodeValue } from "./value/hexCodeValue"; +export { DoubleValue } from "./value/doubleValue"; +export { SingleValue } from "./value/singleValue"; +export { CurrencyValue } from "./value/currencyValue"; +export { DateTimeValue } from "./value/dateTimeValue"; +export { BooleanValue } from "./value/booleanValue"; +export { IdentifierValue } from "./value/identifierValue"; + +export { Item } from "./item"; + +export { List } from "./list/list"; +export { BinaryStringList } from "./list/binaryStringList"; +export { IdentifierList } from "./list/identifierList"; +export { VariantList } from "./list/variantList"; +export { ItemList } from "./list/itemList"; + +export { Property } from "./property"; + +export { ObjectKind } from "./objectKind"; + +export { DObject } from "./object"; + +export { Root } from "./root"; diff --git a/packages/@postdfm/ast/src/item.ts b/packages/@postdfm/ast/src/item.ts index b59f7b00..904b8f73 100644 --- a/packages/@postdfm/ast/src/item.ts +++ b/packages/@postdfm/ast/src/item.ts @@ -1,18 +1,18 @@ -import { ASTNode } from "./astNode"; -import { ASTRaws } from "./astRaws"; -import { ASTType } from "./astType"; -import { Property } from "./property"; - -interface ItemRaws extends ASTRaws { - afterItem?: string; - beforeEnd?: string; -} - -export class Item extends ASTNode { - public properties: Property[]; - - constructor(properties?: Property[]) { - super(ASTType.Item); - this.properties = properties || []; - } -} +import { ASTNode } from "./astNode"; +import { ASTRaws } from "./astRaws"; +import { ASTType } from "./astType"; +import { Property } from "./property"; + +interface ItemRaws extends ASTRaws { + afterItem?: string; + beforeEnd?: string; +} + +export class Item extends ASTNode { + public properties: Property[]; + + constructor(properties?: Property[]) { + super(ASTType.Item); + this.properties = properties || []; + } +} diff --git a/packages/@postdfm/ast/src/keywords.ts b/packages/@postdfm/ast/src/keywords.ts index 01b48408..292cfd07 100644 --- a/packages/@postdfm/ast/src/keywords.ts +++ b/packages/@postdfm/ast/src/keywords.ts @@ -5,5 +5,5 @@ export const Keywords = [ "inherited", "inline", "end", - "item" + "item", ]; diff --git a/packages/@postdfm/ast/src/list/binaryStringList.ts b/packages/@postdfm/ast/src/list/binaryStringList.ts index 75b8c284..4f0f900b 100644 --- a/packages/@postdfm/ast/src/list/binaryStringList.ts +++ b/packages/@postdfm/ast/src/list/binaryStringList.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { BinaryStringValue } from "../value/binaryStringValue"; -import { List } from "./list"; - -export class BinaryStringList extends List { - constructor(values?: BinaryStringValue[]) { - super(ASTType.BinaryStringList, values || []); - } -} +import { ASTType } from "../astType"; +import { BinaryStringValue } from "../value/binaryStringValue"; +import { List } from "./list"; + +export class BinaryStringList extends List { + constructor(values?: BinaryStringValue[]) { + super(ASTType.BinaryStringList, values || []); + } +} diff --git a/packages/@postdfm/ast/src/list/identifierList.ts b/packages/@postdfm/ast/src/list/identifierList.ts index 7ef930ec..63ca14b0 100644 --- a/packages/@postdfm/ast/src/list/identifierList.ts +++ b/packages/@postdfm/ast/src/list/identifierList.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { IdentifierValue } from "../value/identifierValue"; -import { List } from "./list"; - -export class IdentifierList extends List { - constructor(values?: IdentifierValue[]) { - super(ASTType.IdentifierList, values || []); - } -} +import { ASTType } from "../astType"; +import { IdentifierValue } from "../value/identifierValue"; +import { List } from "./list"; + +export class IdentifierList extends List { + constructor(values?: IdentifierValue[]) { + super(ASTType.IdentifierList, values || []); + } +} diff --git a/packages/@postdfm/ast/src/list/itemList.ts b/packages/@postdfm/ast/src/list/itemList.ts index 586c2ea9..3d7bd8d8 100644 --- a/packages/@postdfm/ast/src/list/itemList.ts +++ b/packages/@postdfm/ast/src/list/itemList.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { Item } from "../item"; -import { List } from "./list"; - -export class ItemList extends List { - constructor(values?: Item[]) { - super(ASTType.ItemList, values || []); - } -} +import { ASTType } from "../astType"; +import { Item } from "../item"; +import { List } from "./list"; + +export class ItemList extends List { + constructor(values?: Item[]) { + super(ASTType.ItemList, values || []); + } +} diff --git a/packages/@postdfm/ast/src/list/list.ts b/packages/@postdfm/ast/src/list/list.ts index ef830a50..3664a995 100644 --- a/packages/@postdfm/ast/src/list/list.ts +++ b/packages/@postdfm/ast/src/list/list.ts @@ -1,16 +1,16 @@ -import { ASTNode } from "../astNode"; -import { ASTRaws } from "../astRaws"; -import { ASTType } from "../astType"; - -interface ListRaws extends ASTRaws { - afterOpen?: string; - beforeClose?: string; -} -export class List extends ASTNode { - public values: T[]; - - constructor(astType: ASTType, values: T[]) { - super(astType); - this.values = values; - } -} +import { ASTNode } from "../astNode"; +import { ASTRaws } from "../astRaws"; +import { ASTType } from "../astType"; + +interface ListRaws extends ASTRaws { + afterOpen?: string; + beforeClose?: string; +} +export class List extends ASTNode { + public values: T[]; + + constructor(astType: ASTType, values: T[]) { + super(astType); + this.values = values; + } +} diff --git a/packages/@postdfm/ast/src/list/variantList.ts b/packages/@postdfm/ast/src/list/variantList.ts index b9c00a74..b717e31e 100644 --- a/packages/@postdfm/ast/src/list/variantList.ts +++ b/packages/@postdfm/ast/src/list/variantList.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { VariantValue } from "../value/variantValue"; -import { List } from "./list"; - -export class VariantList extends List { - constructor(values?: Array) { - super(ASTType.VariantList, values || []); - } -} +import { ASTType } from "../astType"; +import { VariantValue } from "../value/variantValue"; +import { List } from "./list"; + +export class VariantList extends List { + constructor(values?: Array) { + super(ASTType.VariantList, values || []); + } +} diff --git a/packages/@postdfm/ast/src/objectKind.ts b/packages/@postdfm/ast/src/objectKind.ts index 2b8be5be..c0bfb403 100644 --- a/packages/@postdfm/ast/src/objectKind.ts +++ b/packages/@postdfm/ast/src/objectKind.ts @@ -1,5 +1,5 @@ -export enum ObjectKind { - Object = "object", - Inline = "inline", - Inherited = "inherited" -} +export enum ObjectKind { + Object = "object", + Inline = "inline", + Inherited = "inherited", +} diff --git a/packages/@postdfm/ast/src/property.ts b/packages/@postdfm/ast/src/property.ts index e1397b70..1133bfa4 100644 --- a/packages/@postdfm/ast/src/property.ts +++ b/packages/@postdfm/ast/src/property.ts @@ -1,20 +1,20 @@ -import { ASTNode } from "./astNode"; -import { ASTRaws } from "./astRaws"; -import { ASTType } from "./astType"; -import { AnyList } from "./list/anyList"; -import { VariantValue } from "./value/variantValue"; - -interface PropertyRaws extends ASTRaws { - afterName?: string; - beforeValue?: string; -} -export class Property extends ASTNode { - public name: string; - public value: VariantValue | AnyList; - - constructor(name: string, value: VariantValue | AnyList) { - super(ASTType.Property); - this.name = name; - this.value = value; - } -} +import { ASTNode } from "./astNode"; +import { ASTRaws } from "./astRaws"; +import { ASTType } from "./astType"; +import { AnyList } from "./list/anyList"; +import { VariantValue } from "./value/variantValue"; + +interface PropertyRaws extends ASTRaws { + afterName?: string; + beforeValue?: string; +} +export class Property extends ASTNode { + public name: string; + public value: VariantValue | AnyList; + + constructor(name: string, value: VariantValue | AnyList) { + super(ASTType.Property); + this.name = name; + this.value = value; + } +} diff --git a/packages/@postdfm/ast/src/value/binaryStringValue.ts b/packages/@postdfm/ast/src/value/binaryStringValue.ts index a8c09521..44c1ae4a 100644 --- a/packages/@postdfm/ast/src/value/binaryStringValue.ts +++ b/packages/@postdfm/ast/src/value/binaryStringValue.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class BinaryStringValue extends Value { - constructor(value?: string) { - super(ASTType.BinaryString, value || ""); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class BinaryStringValue extends Value { + constructor(value?: string) { + super(ASTType.BinaryString, value || ""); + } +} diff --git a/packages/@postdfm/ast/src/value/booleanValue.ts b/packages/@postdfm/ast/src/value/booleanValue.ts index ef352d44..a65b8dc3 100644 --- a/packages/@postdfm/ast/src/value/booleanValue.ts +++ b/packages/@postdfm/ast/src/value/booleanValue.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class BooleanValue extends Value { - constructor(value: boolean) { - super(ASTType.Boolean, value); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class BooleanValue extends Value { + constructor(value: boolean) { + super(ASTType.Boolean, value); + } +} diff --git a/packages/@postdfm/ast/src/value/controlString.ts b/packages/@postdfm/ast/src/value/controlString.ts index e2a9f196..3afdef68 100644 --- a/packages/@postdfm/ast/src/value/controlString.ts +++ b/packages/@postdfm/ast/src/value/controlString.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { StringValuePart } from "./stringValuePart"; - -export class ControlString extends StringValuePart { - constructor(value?: string) { - super(ASTType.ControlString, value); - } -} +import { ASTType } from "../astType"; +import { StringValuePart } from "./stringValuePart"; + +export class ControlString extends StringValuePart { + constructor(value?: string) { + super(ASTType.ControlString, value); + } +} diff --git a/packages/@postdfm/ast/src/value/currencyValue.ts b/packages/@postdfm/ast/src/value/currencyValue.ts index 05083aac..fc6fac98 100644 --- a/packages/@postdfm/ast/src/value/currencyValue.ts +++ b/packages/@postdfm/ast/src/value/currencyValue.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { Float } from "./float"; -import { Value } from "./value"; - -export class CurrencyValue extends Value { - constructor(value?: Float) { - super(ASTType.Currency, value || { integer: "0" }); - } -} +import { ASTType } from "../astType"; +import { Float } from "./float"; +import { Value } from "./value"; + +export class CurrencyValue extends Value { + constructor(value?: Float) { + super(ASTType.Currency, value || { integer: "0" }); + } +} diff --git a/packages/@postdfm/ast/src/value/dateTimeValue.ts b/packages/@postdfm/ast/src/value/dateTimeValue.ts index 1add4f62..53db6fed 100644 --- a/packages/@postdfm/ast/src/value/dateTimeValue.ts +++ b/packages/@postdfm/ast/src/value/dateTimeValue.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { Float } from "./float"; -import { Value } from "./value"; - -export class DateTimeValue extends Value { - constructor(value?: Float) { - super(ASTType.DateTime, value || { integer: "0" }); - } -} +import { ASTType } from "../astType"; +import { Float } from "./float"; +import { Value } from "./value"; + +export class DateTimeValue extends Value { + constructor(value?: Float) { + super(ASTType.DateTime, value || { integer: "0" }); + } +} diff --git a/packages/@postdfm/ast/src/value/doubleValue.ts b/packages/@postdfm/ast/src/value/doubleValue.ts index 3ea00d83..d039f331 100644 --- a/packages/@postdfm/ast/src/value/doubleValue.ts +++ b/packages/@postdfm/ast/src/value/doubleValue.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { Float } from "./float"; -import { Value } from "./value"; - -export class DoubleValue extends Value { - constructor(value?: Float) { - super(ASTType.Double, value || { integer: "0" }); - } -} +import { ASTType } from "../astType"; +import { Float } from "./float"; +import { Value } from "./value"; + +export class DoubleValue extends Value { + constructor(value?: Float) { + super(ASTType.Double, value || { integer: "0" }); + } +} diff --git a/packages/@postdfm/ast/src/value/float.ts b/packages/@postdfm/ast/src/value/float.ts index 126fcd17..ff7d5fb0 100644 --- a/packages/@postdfm/ast/src/value/float.ts +++ b/packages/@postdfm/ast/src/value/float.ts @@ -1,5 +1,5 @@ -export interface Float { - integer: string; - fraction?: string; - exponent?: string; -} +export interface Float { + integer: string; + fraction?: string; + exponent?: string; +} diff --git a/packages/@postdfm/ast/src/value/hexCodeValue.ts b/packages/@postdfm/ast/src/value/hexCodeValue.ts index 955ae6f8..c6dd504c 100644 --- a/packages/@postdfm/ast/src/value/hexCodeValue.ts +++ b/packages/@postdfm/ast/src/value/hexCodeValue.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class HexCodeValue extends Value { - constructor(value?: string) { - super(ASTType.HexCode, value || ""); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class HexCodeValue extends Value { + constructor(value?: string) { + super(ASTType.HexCode, value || ""); + } +} diff --git a/packages/@postdfm/ast/src/value/identifierValue.ts b/packages/@postdfm/ast/src/value/identifierValue.ts index 90cbd4f6..b71db9df 100644 --- a/packages/@postdfm/ast/src/value/identifierValue.ts +++ b/packages/@postdfm/ast/src/value/identifierValue.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class IdentifierValue extends Value { - constructor(value: string) { - super(ASTType.Identifier, value); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class IdentifierValue extends Value { + constructor(value: string) { + super(ASTType.Identifier, value); + } +} diff --git a/packages/@postdfm/ast/src/value/integerValue.ts b/packages/@postdfm/ast/src/value/integerValue.ts index 4a42703c..c62ce85a 100644 --- a/packages/@postdfm/ast/src/value/integerValue.ts +++ b/packages/@postdfm/ast/src/value/integerValue.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class IntegerValue extends Value { - constructor(value?: number) { - super(ASTType.Integer, value || 0); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class IntegerValue extends Value { + constructor(value?: number) { + super(ASTType.Integer, value || 0); + } +} diff --git a/packages/@postdfm/ast/src/value/literalString.ts b/packages/@postdfm/ast/src/value/literalString.ts index c9888c21..bee3e121 100644 --- a/packages/@postdfm/ast/src/value/literalString.ts +++ b/packages/@postdfm/ast/src/value/literalString.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { StringValuePart } from "./stringValuePart"; - -export class LiteralString extends StringValuePart { - constructor(value?: string) { - super(ASTType.LiteralString, value); - } -} +import { ASTType } from "../astType"; +import { StringValuePart } from "./stringValuePart"; + +export class LiteralString extends StringValuePart { + constructor(value?: string) { + super(ASTType.LiteralString, value); + } +} diff --git a/packages/@postdfm/ast/src/value/singleValue.ts b/packages/@postdfm/ast/src/value/singleValue.ts index 0054e85d..474cca1a 100644 --- a/packages/@postdfm/ast/src/value/singleValue.ts +++ b/packages/@postdfm/ast/src/value/singleValue.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { Float } from "./float"; -import { Value } from "./value"; - -export class SingleValue extends Value { - constructor(value?: Float) { - super(ASTType.Single, value || { integer: "0" }); - } -} +import { ASTType } from "../astType"; +import { Float } from "./float"; +import { Value } from "./value"; + +export class SingleValue extends Value { + constructor(value?: Float) { + super(ASTType.Single, value || { integer: "0" }); + } +} diff --git a/packages/@postdfm/ast/src/value/stringValue.ts b/packages/@postdfm/ast/src/value/stringValue.ts index 506d2775..1408c48e 100644 --- a/packages/@postdfm/ast/src/value/stringValue.ts +++ b/packages/@postdfm/ast/src/value/stringValue.ts @@ -1,9 +1,9 @@ -import { ASTType } from "../astType"; -import { StringValuePart } from "./stringValuePart"; -import { Value } from "./value"; - -export class StringValue extends Value { - constructor(value?: StringValuePart[]) { - super(ASTType.String, value || []); - } -} +import { ASTType } from "../astType"; +import { StringValuePart } from "./stringValuePart"; +import { Value } from "./value"; + +export class StringValue extends Value { + constructor(value?: StringValuePart[]) { + super(ASTType.String, value || []); + } +} diff --git a/packages/@postdfm/ast/src/value/stringValuePart.ts b/packages/@postdfm/ast/src/value/stringValuePart.ts index 99d9b8b0..5533d97c 100644 --- a/packages/@postdfm/ast/src/value/stringValuePart.ts +++ b/packages/@postdfm/ast/src/value/stringValuePart.ts @@ -1,8 +1,8 @@ -import { ASTType } from "../astType"; -import { Value } from "./value"; - -export class StringValuePart extends Value { - constructor(astType: ASTType, value?: string) { - super(astType, value || ""); - } -} +import { ASTType } from "../astType"; +import { Value } from "./value"; + +export class StringValuePart extends Value { + constructor(astType: ASTType, value?: string) { + super(astType, value || ""); + } +} diff --git a/packages/@postdfm/ast/src/value/value.ts b/packages/@postdfm/ast/src/value/value.ts index 7171d4b8..e8138a03 100644 --- a/packages/@postdfm/ast/src/value/value.ts +++ b/packages/@postdfm/ast/src/value/value.ts @@ -1,10 +1,10 @@ -import { ASTNode } from "../astNode"; -import { ASTType } from "../astType"; - -export class Value extends ASTNode { - public value: T; - constructor(astType: ASTType, value: T) { - super(astType); - this.value = value; - } -} +import { ASTNode } from "../astNode"; +import { ASTType } from "../astType"; + +export class Value extends ASTNode { + public value: T; + constructor(astType: ASTType, value: T) { + super(astType); + this.value = value; + } +} diff --git a/packages/@postdfm/ast/typedoc.config.js b/packages/@postdfm/ast/typedoc.config.js index 704916c7..e5786030 100644 --- a/packages/@postdfm/ast/typedoc.config.js +++ b/packages/@postdfm/ast/typedoc.config.js @@ -1,3 +1,3 @@ -module.exports = require("../../../typedoc")({ - out: "@postdfm/ast" -}); +module.exports = require("../../../typedoc")({ + out: "@postdfm/ast", +}); diff --git a/packages/@postdfm/ast2dfm/.eslintrc.js b/packages/@postdfm/ast2dfm/.eslintrc.js index d177fd35..dad6750a 100644 --- a/packages/@postdfm/ast2dfm/.eslintrc.js +++ b/packages/@postdfm/ast2dfm/.eslintrc.js @@ -1 +1 @@ -module.exports = require("../../../eslint.config.js")(true); +module.exports = require("../../../eslint.config.js")(true); diff --git a/packages/@postdfm/ast2dfm/README.md b/packages/@postdfm/ast2dfm/README.md index 409f01b0..3ab712eb 100644 --- a/packages/@postdfm/ast2dfm/README.md +++ b/packages/@postdfm/ast2dfm/README.md @@ -1,12 +1,12 @@ -# @postdfm/ast2dfm - -[![npm](https://img.shields.io/npm/v/@postdfm/ast2dfm.svg?label=npm)](https://www.npmjs.com/package/@postdfm/ast2dfm) -[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) -[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) -[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/ast2dfm/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/ast2dfm/package.json) - -Sub-package for `postdfm`. - -Provides functionality for turning the structure provided by `@postdfm/ast` into a string. - -See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/ast2dfm/). +# @postdfm/ast2dfm + +[![npm](https://img.shields.io/npm/v/@postdfm/ast2dfm.svg?label=npm)](https://www.npmjs.com/package/@postdfm/ast2dfm) +[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) +[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) +[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/ast2dfm/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/ast2dfm/package.json) + +Sub-package for `postdfm`. + +Provides functionality for turning the structure provided by `@postdfm/ast` into a string. + +See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/ast2dfm/). diff --git a/packages/@postdfm/ast2dfm/__test__/broken/ast.json b/packages/@postdfm/ast2dfm/__test__/broken/ast.json index b7675d72..2e54457c 100644 --- a/packages/@postdfm/ast2dfm/__test__/broken/ast.json +++ b/packages/@postdfm/ast2dfm/__test__/broken/ast.json @@ -1,3 +1,3 @@ -{ - "astType": "unknown" -} +{ + "astType": "unknown" +} diff --git a/packages/@postdfm/ast2dfm/__test__/broken/index.test.ts b/packages/@postdfm/ast2dfm/__test__/broken/index.test.ts index 2bd0275b..ecbc112b 100644 --- a/packages/@postdfm/ast2dfm/__test__/broken/index.test.ts +++ b/packages/@postdfm/ast2dfm/__test__/broken/index.test.ts @@ -1,14 +1,14 @@ -import * as AST from "@postdfm/ast"; -import * as fs from "fs"; -import * as path from "path"; -import stringify from "../../src"; - -describe("dfm2ast", () => { - test("broken AST throws error", () => { - const ast = JSON.parse( - fs.readFileSync(path.join(__dirname, "ast.json"), "utf8") - ) as AST.Root; - - expect(() => stringify(ast)).toThrow("Cannot stringify astType unknown"); - }); -}); +import * as AST from "@postdfm/ast"; +import * as fs from "fs"; +import * as path from "path"; +import stringify from "../../src"; + +describe("dfm2ast", () => { + test("broken AST throws error", () => { + const ast = JSON.parse( + fs.readFileSync(path.join(__dirname, "ast.json"), "utf8") + ) as AST.Root; + + expect(() => stringify(ast)).toThrow("Cannot stringify astType unknown"); + }); +}); diff --git a/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts b/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts index 3b674977..b6787cfc 100644 --- a/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts +++ b/packages/@postdfm/ast2dfm/__test__/fixtures/index.test.ts @@ -1,23 +1,23 @@ -import * as AST from "@postdfm/ast"; -import * as fs from "fs"; -import * as path from "path"; -import stringify from "../../src"; - -const rootFixturesDir = path.join("__test__", "__fixtures__"); -const parseFixturesDir = path.join(rootFixturesDir, "parse"); - -describe("dfm2ast", () => { - describe("fixtures", () => { - const fixtures = fs.readdirSync(parseFixturesDir); - fixtures.forEach(fixture => { - const astFile = path.join(parseFixturesDir, fixture, "ast.json"); - const formFile = path.join(parseFixturesDir, fixture, "form.dfm"); - - test(fixture, () => { - expect( - stringify(JSON.parse(fs.readFileSync(astFile, "utf8")) as AST.Root) - ).toEqual(fs.readFileSync(formFile, "ascii")); - }); - }); - }); -}); +import * as AST from "@postdfm/ast"; +import * as fs from "fs"; +import * as path from "path"; +import stringify from "../../src"; + +const rootFixturesDir = path.join("__test__", "__fixtures__"); +const parseFixturesDir = path.join(rootFixturesDir, "parse"); + +describe("dfm2ast", () => { + describe("fixtures", () => { + const fixtures = fs.readdirSync(parseFixturesDir); + fixtures.forEach((fixture) => { + const astFile = path.join(parseFixturesDir, fixture, "ast.json"); + const formFile = path.join(parseFixturesDir, fixture, "form.dfm"); + + test(fixture, () => { + expect( + stringify(JSON.parse(fs.readFileSync(astFile, "utf8")) as AST.Root) + ).toEqual(fs.readFileSync(formFile, "ascii")); + }); + }); + }); +}); diff --git a/packages/@postdfm/ast2dfm/src/index.ts b/packages/@postdfm/ast2dfm/src/index.ts index c421adf7..b1cd11e8 100644 --- a/packages/@postdfm/ast2dfm/src/index.ts +++ b/packages/@postdfm/ast2dfm/src/index.ts @@ -1,10 +1,10 @@ -import { Root } from "@postdfm/ast"; -import Stringifier from "./stringifier"; - -function stringify(ast: Root): string { - const stringifier = new Stringifier(); - return stringifier.stringify(ast); -} - -export default stringify; -export { stringify }; +import { Root } from "@postdfm/ast"; +import Stringifier from "./stringifier"; + +function stringify(ast: Root): string { + const stringifier = new Stringifier(); + return stringifier.stringify(ast); +} + +export default stringify; +export { stringify }; diff --git a/packages/@postdfm/ast2dfm/src/stringifier.ts b/packages/@postdfm/ast2dfm/src/stringifier.ts index 08afbc67..55d9bc01 100644 --- a/packages/@postdfm/ast2dfm/src/stringifier.ts +++ b/packages/@postdfm/ast2dfm/src/stringifier.ts @@ -1,281 +1,283 @@ -import * as AST from "@postdfm/ast"; - -export default class Stringifier { - public stringify(ast: AST.ASTNode): string { - switch (ast.astType) { - case AST.ASTType.String: - return this.printString(ast as AST.StringValue); - case AST.ASTType.ControlString: - return this.printControlString(ast as AST.ControlString); - case AST.ASTType.LiteralString: - return this.printLiteralString(ast as AST.LiteralString); - case AST.ASTType.Integer: - return this.printInteger(ast as AST.IntegerValue); - case AST.ASTType.HexCode: - return this.printHexCode(ast as AST.HexCodeValue); - case AST.ASTType.Double: - return this.printDouble(ast as AST.DoubleValue); - case AST.ASTType.Single: - return this.printSingle(ast as AST.SingleValue); - case AST.ASTType.Currency: - return this.printCurrency(ast as AST.CurrencyValue); - case AST.ASTType.DateTime: - return this.printDateTime(ast as AST.DateTimeValue); - case AST.ASTType.Boolean: - return this.printBoolean(ast as AST.BooleanValue); - case AST.ASTType.Identifier: - return this.printIdentifier(ast as AST.IdentifierValue); - case AST.ASTType.VariantList: - return this.printVariantList(ast as AST.VariantList); - case AST.ASTType.BinaryStringList: - return this.printBinaryStringList(ast as AST.BinaryStringList); - case AST.ASTType.IdentifierList: - return this.printIdentifierList(ast as AST.IdentifierList); - case AST.ASTType.ItemList: - return this.printItemList(ast as AST.ItemList); - case AST.ASTType.Root: - return this.printRoot(ast as AST.Root); - default: - throw Error(`Cannot stringify astType ${ast.astType}`); - } - } - - private printString(ast: AST.StringValue): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.value.map(str => this.stringify(str)).join(""), - raws.after - ); - } - - private printControlString(ast: AST.ControlString): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "#", - `${ast.value.charCodeAt(0)}`, - raws.after - ); - } - - private printLiteralString(ast: AST.LiteralString): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "'", - ast.value.replace(/'/g, "''"), - "'", - raws.after - ); - } - - private printBinaryString(ast: AST.BinaryStringValue): string { - const raws = this.raws(ast); - return this.print(raws.before, ast.value, raws.after); - } - - private printInteger(ast: AST.IntegerValue): string { - const raws = this.raws(ast); - return this.print(raws.before, `${ast.value}`, raws.after); - } - - private printHexCode(ast: AST.HexCodeValue): string { - const raws = this.raws(ast); - return this.print(raws.before, "$", ast.value, raws.after); - } - - private printDouble(ast: AST.DoubleValue): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.value.integer, - ast.value.fraction ? `.${ast.value.fraction}` : "", - ast.value.exponent ? `e${ast.value.exponent}` : "", - raws.after - ); - } - - private printSingle(ast: AST.SingleValue): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.value.integer, - ast.value.fraction ? `.${ast.value.fraction}` : "", - ast.value.exponent ? `e${ast.value.exponent}` : "", - "s", - raws.after - ); - } - - private printCurrency(ast: AST.CurrencyValue): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.value.integer, - ast.value.fraction ? `.${ast.value.fraction}` : "", - ast.value.exponent ? `e${ast.value.exponent}` : "", - "c", - raws.after - ); - } - - private printDateTime(ast: AST.DateTimeValue): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.value.integer, - ast.value.fraction ? `.${ast.value.fraction}` : "", - ast.value.exponent ? `e${ast.value.exponent}` : "", - "d", - raws.after - ); - } - - private printBoolean(ast: AST.BooleanValue): string { - const raws = this.raws(ast); - return this.print(raws.before, ast.value ? "True" : "False", raws.after); - } - - private printIdentifier(ast: AST.IdentifierValue): string { - const raws = this.raws(ast); - return this.print(raws.before, ast.value, raws.after); - } - - private printItem(ast: AST.Item): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "item", - raws.afterItem, - ast.properties.map(property => this.printProperty(property)).join(""), - raws.beforeEnd, - "end", - raws.after - ); - } - - private printVariantList(ast: AST.VariantList): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "(", - raws.afterOpen, - ast.values.map(variant => this.stringify(variant)).join(""), - raws.beforeClose, - ")", - raws.after - ); - } - - private printBinaryStringList(ast: AST.BinaryStringList): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "{", - raws.afterOpen, - ast.values - .map(binaryString => this.printBinaryString(binaryString)) - .join(""), - raws.beforeClose, - "}", - raws.after - ); - } - - private printIdentifierList(ast: AST.IdentifierList): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "[", - raws.afterOpen, - ast.values.map(identifier => this.printIdentifier(identifier)).join(","), - raws.beforeClose, - "]", - raws.after - ); - } - - private printItemList(ast: AST.ItemList): string { - const raws = this.raws(ast); - return this.print( - raws.before, - "<", - raws.afterOpen, - ast.values.map(item => this.printItem(item)).join(""), - raws.beforeClose, - ">", - raws.after - ); - } - - private printProperty(ast: AST.Property): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.name, - raws.afterName, - "=", - raws.beforeValue, - this.stringify(ast.value), - raws.after - ); - } - - private printObject(ast: AST.DObject): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.kind, - raws.beforeName, - ast.name, - raws.afterName, - ast.type - ? this.print(":", raws.beforeType, ast.type, raws.afterType) - : "", - ast.order !== undefined - ? this.print( - "[", - raws.beforeOrder, - `${ast.order}`, - raws.afterOrder, - "]" - ) - : "", - ast.properties && ast.properties.length - ? this.print( - raws.beforeProperties, - ast.properties - .map(property => this.printProperty(property)) - .join("") - ) - : "", - ast.children && ast.children.length - ? this.print( - raws.beforeChildren, - ast.children.map(child => this.printObject(child)).join("") - ) - : "", - raws.beforeEnd, - "end", - raws.after - ); - } - - private printRoot(ast: AST.Root): string { - const raws = this.raws(ast); - return this.print( - raws.before, - ast.child ? this.printObject(ast.child) : "", - raws.after - ); - } - - private print(...values: (string | undefined)[]): string { - return values.filter(v => !!v).join(""); - } - - private raws(obj: AST.ASTNode): R { - return obj.raws || {}; - } -} +import * as AST from "@postdfm/ast"; + +export default class Stringifier { + public stringify(ast: AST.ASTNode): string { + switch (ast.astType) { + case AST.ASTType.String: + return this.printString(ast as AST.StringValue); + case AST.ASTType.ControlString: + return this.printControlString(ast as AST.ControlString); + case AST.ASTType.LiteralString: + return this.printLiteralString(ast as AST.LiteralString); + case AST.ASTType.Integer: + return this.printInteger(ast as AST.IntegerValue); + case AST.ASTType.HexCode: + return this.printHexCode(ast as AST.HexCodeValue); + case AST.ASTType.Double: + return this.printDouble(ast as AST.DoubleValue); + case AST.ASTType.Single: + return this.printSingle(ast as AST.SingleValue); + case AST.ASTType.Currency: + return this.printCurrency(ast as AST.CurrencyValue); + case AST.ASTType.DateTime: + return this.printDateTime(ast as AST.DateTimeValue); + case AST.ASTType.Boolean: + return this.printBoolean(ast as AST.BooleanValue); + case AST.ASTType.Identifier: + return this.printIdentifier(ast as AST.IdentifierValue); + case AST.ASTType.VariantList: + return this.printVariantList(ast as AST.VariantList); + case AST.ASTType.BinaryStringList: + return this.printBinaryStringList(ast as AST.BinaryStringList); + case AST.ASTType.IdentifierList: + return this.printIdentifierList(ast as AST.IdentifierList); + case AST.ASTType.ItemList: + return this.printItemList(ast as AST.ItemList); + case AST.ASTType.Root: + return this.printRoot(ast as AST.Root); + default: + throw Error(`Cannot stringify astType ${ast.astType}`); + } + } + + private printString(ast: AST.StringValue): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.value.map((str) => this.stringify(str)).join(""), + raws.after + ); + } + + private printControlString(ast: AST.ControlString): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "#", + `${ast.value.charCodeAt(0)}`, + raws.after + ); + } + + private printLiteralString(ast: AST.LiteralString): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "'", + ast.value.replace(/'/g, "''"), + "'", + raws.after + ); + } + + private printBinaryString(ast: AST.BinaryStringValue): string { + const raws = this.raws(ast); + return this.print(raws.before, ast.value, raws.after); + } + + private printInteger(ast: AST.IntegerValue): string { + const raws = this.raws(ast); + return this.print(raws.before, `${ast.value}`, raws.after); + } + + private printHexCode(ast: AST.HexCodeValue): string { + const raws = this.raws(ast); + return this.print(raws.before, "$", ast.value, raws.after); + } + + private printDouble(ast: AST.DoubleValue): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.value.integer, + ast.value.fraction ? `.${ast.value.fraction}` : "", + ast.value.exponent ? `e${ast.value.exponent}` : "", + raws.after + ); + } + + private printSingle(ast: AST.SingleValue): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.value.integer, + ast.value.fraction ? `.${ast.value.fraction}` : "", + ast.value.exponent ? `e${ast.value.exponent}` : "", + "s", + raws.after + ); + } + + private printCurrency(ast: AST.CurrencyValue): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.value.integer, + ast.value.fraction ? `.${ast.value.fraction}` : "", + ast.value.exponent ? `e${ast.value.exponent}` : "", + "c", + raws.after + ); + } + + private printDateTime(ast: AST.DateTimeValue): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.value.integer, + ast.value.fraction ? `.${ast.value.fraction}` : "", + ast.value.exponent ? `e${ast.value.exponent}` : "", + "d", + raws.after + ); + } + + private printBoolean(ast: AST.BooleanValue): string { + const raws = this.raws(ast); + return this.print(raws.before, ast.value ? "True" : "False", raws.after); + } + + private printIdentifier(ast: AST.IdentifierValue): string { + const raws = this.raws(ast); + return this.print(raws.before, ast.value, raws.after); + } + + private printItem(ast: AST.Item): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "item", + raws.afterItem, + ast.properties.map((property) => this.printProperty(property)).join(""), + raws.beforeEnd, + "end", + raws.after + ); + } + + private printVariantList(ast: AST.VariantList): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "(", + raws.afterOpen, + ast.values.map((variant) => this.stringify(variant)).join(""), + raws.beforeClose, + ")", + raws.after + ); + } + + private printBinaryStringList(ast: AST.BinaryStringList): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "{", + raws.afterOpen, + ast.values + .map((binaryString) => this.printBinaryString(binaryString)) + .join(""), + raws.beforeClose, + "}", + raws.after + ); + } + + private printIdentifierList(ast: AST.IdentifierList): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "[", + raws.afterOpen, + ast.values + .map((identifier) => this.printIdentifier(identifier)) + .join(","), + raws.beforeClose, + "]", + raws.after + ); + } + + private printItemList(ast: AST.ItemList): string { + const raws = this.raws(ast); + return this.print( + raws.before, + "<", + raws.afterOpen, + ast.values.map((item) => this.printItem(item)).join(""), + raws.beforeClose, + ">", + raws.after + ); + } + + private printProperty(ast: AST.Property): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.name, + raws.afterName, + "=", + raws.beforeValue, + this.stringify(ast.value), + raws.after + ); + } + + private printObject(ast: AST.DObject): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.kind, + raws.beforeName, + ast.name, + raws.afterName, + ast.type + ? this.print(":", raws.beforeType, ast.type, raws.afterType) + : "", + ast.order !== undefined + ? this.print( + "[", + raws.beforeOrder, + `${ast.order}`, + raws.afterOrder, + "]" + ) + : "", + ast.properties && ast.properties.length + ? this.print( + raws.beforeProperties, + ast.properties + .map((property) => this.printProperty(property)) + .join("") + ) + : "", + ast.children && ast.children.length + ? this.print( + raws.beforeChildren, + ast.children.map((child) => this.printObject(child)).join("") + ) + : "", + raws.beforeEnd, + "end", + raws.after + ); + } + + private printRoot(ast: AST.Root): string { + const raws = this.raws(ast); + return this.print( + raws.before, + ast.child ? this.printObject(ast.child) : "", + raws.after + ); + } + + private print(...values: (string | undefined)[]): string { + return values.filter((v) => !!v).join(""); + } + + private raws(obj: AST.ASTNode): R { + return obj.raws || {}; + } +} diff --git a/packages/@postdfm/ast2dfm/typedoc.config.js b/packages/@postdfm/ast2dfm/typedoc.config.js index d7545d5a..353a8bdd 100644 --- a/packages/@postdfm/ast2dfm/typedoc.config.js +++ b/packages/@postdfm/ast2dfm/typedoc.config.js @@ -1,3 +1,3 @@ -module.exports = require("../../../typedoc")({ - out: "@postdfm/ast2dfm" -}); +module.exports = require("../../../typedoc")({ + out: "@postdfm/ast2dfm", +}); diff --git a/packages/@postdfm/dfm2ast/.eslintrc.js b/packages/@postdfm/dfm2ast/.eslintrc.js index d177fd35..dad6750a 100644 --- a/packages/@postdfm/dfm2ast/.eslintrc.js +++ b/packages/@postdfm/dfm2ast/.eslintrc.js @@ -1 +1 @@ -module.exports = require("../../../eslint.config.js")(true); +module.exports = require("../../../eslint.config.js")(true); diff --git a/packages/@postdfm/dfm2ast/README.md b/packages/@postdfm/dfm2ast/README.md index 80ab6a46..fd84e860 100644 --- a/packages/@postdfm/dfm2ast/README.md +++ b/packages/@postdfm/dfm2ast/README.md @@ -1,12 +1,12 @@ -# @postdfm/dfm2ast - -[![npm](https://img.shields.io/npm/v/@postdfm/dfm2ast.svg?label=npm)](https://www.npmjs.com/package/@postdfm/dfm2ast) -[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) -[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) -[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/dfm2ast/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/dfm2ast/package.json) - -Sub-package for `postdfm`. - -Provides functionality for parsing DFMs into the structures provided by `@postdfm/ast`. - -See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/dfm2ast/). +# @postdfm/dfm2ast + +[![npm](https://img.shields.io/npm/v/@postdfm/dfm2ast.svg?label=npm)](https://www.npmjs.com/package/@postdfm/dfm2ast) +[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) +[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) +[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/@postdfm/dfm2ast/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/@postdfm/dfm2ast/package.json) + +Sub-package for `postdfm`. + +Provides functionality for parsing DFMs into the structures provided by `@postdfm/ast`. + +See [`postdfm`](https://github.com/spiltcoffee/postdfm) for more information, or the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/@postdfm/dfm2ast/). diff --git a/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts b/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts index f1b57ff1..45060c33 100644 --- a/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts +++ b/packages/@postdfm/dfm2ast/__test__/fixtures/index.test.ts @@ -1,22 +1,22 @@ -import * as fs from "fs"; -import * as path from "path"; -import parse from "../../src"; - -const rootFixturesDir = path.join("__test__", "__fixtures__"); -const parseFixturesDir = path.join(rootFixturesDir, "parse"); - -describe("dfm2ast", () => { - describe("fixtures", () => { - const fixtures = fs.readdirSync(parseFixturesDir); - fixtures.forEach(fixture => { - const formFile = path.join(parseFixturesDir, fixture, "form.dfm"); - const astFile = path.join(parseFixturesDir, fixture, "ast.json"); - - test(fixture, () => { - expect( - JSON.parse(JSON.stringify(parse(fs.readFileSync(formFile, "ascii")))) - ).toEqual(JSON.parse(fs.readFileSync(astFile, "utf8"))); - }); - }); - }); -}); +import * as fs from "fs"; +import * as path from "path"; +import parse from "../../src"; + +const rootFixturesDir = path.join("__test__", "__fixtures__"); +const parseFixturesDir = path.join(rootFixturesDir, "parse"); + +describe("dfm2ast", () => { + describe("fixtures", () => { + const fixtures = fs.readdirSync(parseFixturesDir); + fixtures.forEach((fixture) => { + const formFile = path.join(parseFixturesDir, fixture, "form.dfm"); + const astFile = path.join(parseFixturesDir, fixture, "ast.json"); + + test(fixture, () => { + expect( + JSON.parse(JSON.stringify(parse(fs.readFileSync(formFile, "ascii")))) + ).toEqual(JSON.parse(fs.readFileSync(astFile, "utf8"))); + }); + }); + }); +}); diff --git a/packages/@postdfm/dfm2ast/src/index.ts b/packages/@postdfm/dfm2ast/src/index.ts index 7bbeedf2..ab7bf6ed 100644 --- a/packages/@postdfm/dfm2ast/src/index.ts +++ b/packages/@postdfm/dfm2ast/src/index.ts @@ -1,25 +1,25 @@ -import { Root } from "@postdfm/ast"; -import { Grammar, Parser } from "nearley"; -import grammar from "./grammar"; - -function parse(dfm: string): Root { - const parser = new Parser(Grammar.fromCompiled(grammar)); - parser.feed(dfm); - - if (!parser.results.length) { - throw new Error("Unexpected End Of Input"); - } - - if (parser.results.length > 1) { - throw new Error( - `Ambiguous Grammar: ${parser.results.length} Results Found\n\n` + - " This probably isn't your fault. Please consider raising an " + - "issue with a reproducable case at github.com/spiltcoffee/postdfm" - ); - } - - return parser.results[0]; -} - -export default parse; -export { parse }; +import { Root } from "@postdfm/ast"; +import { Grammar, Parser } from "nearley"; +import grammar from "./grammar"; + +function parse(dfm: string): Root { + const parser = new Parser(Grammar.fromCompiled(grammar)); + parser.feed(dfm); + + if (!parser.results.length) { + throw new Error("Unexpected End Of Input"); + } + + if (parser.results.length > 1) { + throw new Error( + `Ambiguous Grammar: ${parser.results.length} Results Found\n\n` + + " This probably isn't your fault. Please consider raising an " + + "issue with a reproducable case at github.com/spiltcoffee/postdfm" + ); + } + + return parser.results[0]; +} + +export default parse; +export { parse }; diff --git a/packages/@postdfm/dfm2ast/typedoc.config.js b/packages/@postdfm/dfm2ast/typedoc.config.js index cc642e01..9b700ef7 100644 --- a/packages/@postdfm/dfm2ast/typedoc.config.js +++ b/packages/@postdfm/dfm2ast/typedoc.config.js @@ -1,3 +1,3 @@ -module.exports = require("../../../typedoc")({ - out: "@postdfm/dfm2ast" -}); +module.exports = require("../../../typedoc")({ + out: "@postdfm/dfm2ast", +}); diff --git a/packages/postdfm/.eslintrc.js b/packages/postdfm/.eslintrc.js index 4fa8a65b..1dc4a604 100644 --- a/packages/postdfm/.eslintrc.js +++ b/packages/postdfm/.eslintrc.js @@ -1 +1 @@ -module.exports = require("../../eslint.config.js")(true); +module.exports = require("../../eslint.config.js")(true); diff --git a/packages/postdfm/README.md b/packages/postdfm/README.md index 367cea5b..965ff640 100644 --- a/packages/postdfm/README.md +++ b/packages/postdfm/README.md @@ -1,142 +1,142 @@ -# postdfm - -> Process over Delphi Forms (.dfm) files via an AST. -> -> Inspired by the excellent PostCSS tool, motivated by my rage at the Delphi IDE. - -[![npm](https://img.shields.io/npm/v/postdfm.svg?label=npm)](https://www.npmjs.com/package/postdfm) -[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) -[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) -[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/postdfm/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/postdfm/package.json) - -## Table of Contents - -- [Installation](#installation) -- [Example Usage](#example-usage) -- [Reference](#reference) -- [Contributing](#contributing) -- [License](#license) - -## Installation - -The `postdfm` project is an interface wrapping all the separate modules together. - -```shell -# npm -$ npm install postdfm - -# yarn -$ yarn add postdfm -``` - -## Example Usage - -```js -const fs = require("fs"); -const postdfm = require("postdfm"); - -const cisDfm = fs.readFileSync( - "cis.dfm", - //.dfm files tend to be ascii instead of utf8 - "ascii" -); - -const runner = postdfm({ - transformers: [ - function(ast) { - //transform and return the ast - return transformedAst; - } - ] -}); - -const transDfm = runner.processSync(dfm, { - //filename used for reporting errors - from: "cis.dfm" -}); - -fs.writeFileSync("trans.dfm", transDfm); -``` - -## Reference - -### `Runner` instance - -Create a runner by calling the `postdfm` function. - -```js -const postdfm = require("postdfm"); -const runner = postdfm(); -``` - -#### `postdfm(options?: RunnerOptions)` - -Create a `Runner` instance using `RunnerOptions` - -#### `runner.process(dfm: string, processingOptions: ProcessingOptions): Promise` - -Process a file through the runner asynchronously. - -#### `runner.processSync(dfm: string, processingOptions: ProcessingOptions): string` - -Process a file through the runner synchronously. - -### `RunnerOptions` - -Options to pass to an instance of `Runner`. - -#### `options.transformers: Transformer[]` - -Array of transformations to perform on AST. - -#### `options.parser: Parser = "@postdfm/dfm2ast"` - -Parser to use, defaults to `@postdfm/dfm2ast`. - -#### `options.stringifier: Stringifier = "@postdfm/ast2dfm"` - -Stringifier to use, defaults to `@postdfm/ast2dfm`. - -### `Transformer` - -A function that takes an AST, transforms it, and returns it. - -```js -(ast: AST.Root): AST.Root -``` - -### `Parser` - -A function that takes a string, parses it, and returns an AST. - -```js -(dfm: string): AST.Root -``` - -### `Stringifier` - -A function that takes an AST, stringifies it, and returns a string. - -```js -(ast: AST.Root): string -``` - -### `ProcessingOptions` - -#### `processingOptions.from` - -The file which is being processed. Used when throwing syntax errors. - -## Generated Documentation - -You can find the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/postdfm/). - -## Contributing - -Bug reports and feature requests are greatly appreciated, as are pull requests. - -Please see the [Contributing Guide](https://github.com/spiltcoffee/postdfm/blob/master/.github/CONTRIBUTING.md) for instructions on how to contribute to this project. - -## License - -Licensed under the MIT License. +# postdfm + +> Process over Delphi Forms (.dfm) files via an AST. +> +> Inspired by the excellent PostCSS tool, motivated by my rage at the Delphi IDE. + +[![npm](https://img.shields.io/npm/v/postdfm.svg?label=npm)](https://www.npmjs.com/package/postdfm) +[![CircleCI branch](https://img.shields.io/circleci/project/github/spiltcoffee/postdfm/master.svg)](https://circleci.com) +[![Codecov branch](https://img.shields.io/codecov/c/gh/spiltcoffee/postdfm/master.svg)](https://codecov.io) +[![Known Vulnerabilities](https://snyk.io/test/github/spiltcoffee/postdfm/badge.svg?targetFile=packages/postdfm/package.json)](https://snyk.io/test/github/spiltcoffee/postdfm?targetFile=packages/postdfm/package.json) + +## Table of Contents + +- [Installation](#installation) +- [Example Usage](#example-usage) +- [Reference](#reference) +- [Contributing](#contributing) +- [License](#license) + +## Installation + +The `postdfm` project is an interface wrapping all the separate modules together. + +```shell +# npm +$ npm install postdfm + +# yarn +$ yarn add postdfm +``` + +## Example Usage + +```js +const fs = require("fs"); +const postdfm = require("postdfm"); + +const cisDfm = fs.readFileSync( + "cis.dfm", + //.dfm files tend to be ascii instead of utf8 + "ascii" +); + +const runner = postdfm({ + transformers: [ + function (ast) { + //transform and return the ast + return transformedAst; + }, + ], +}); + +const transDfm = runner.processSync(dfm, { + //filename used for reporting errors + from: "cis.dfm", +}); + +fs.writeFileSync("trans.dfm", transDfm); +``` + +## Reference + +### `Runner` instance + +Create a runner by calling the `postdfm` function. + +```js +const postdfm = require("postdfm"); +const runner = postdfm(); +``` + +#### `postdfm(options?: RunnerOptions)` + +Create a `Runner` instance using `RunnerOptions` + +#### `runner.process(dfm: string, processingOptions: ProcessingOptions): Promise` + +Process a file through the runner asynchronously. + +#### `runner.processSync(dfm: string, processingOptions: ProcessingOptions): string` + +Process a file through the runner synchronously. + +### `RunnerOptions` + +Options to pass to an instance of `Runner`. + +#### `options.transformers: Transformer[]` + +Array of transformations to perform on AST. + +#### `options.parser: Parser = "@postdfm/dfm2ast"` + +Parser to use, defaults to `@postdfm/dfm2ast`. + +#### `options.stringifier: Stringifier = "@postdfm/ast2dfm"` + +Stringifier to use, defaults to `@postdfm/ast2dfm`. + +### `Transformer` + +A function that takes an AST, transforms it, and returns it. + +```js +(ast: AST.Root): AST.Root +``` + +### `Parser` + +A function that takes a string, parses it, and returns an AST. + +```js +(dfm: string): AST.Root +``` + +### `Stringifier` + +A function that takes an AST, stringifies it, and returns a string. + +```js +(ast: AST.Root): string +``` + +### `ProcessingOptions` + +#### `processingOptions.from` + +The file which is being processed. Used when throwing syntax errors. + +## Generated Documentation + +You can find the generated `typedoc` documentation [here](https://spiltcoffee.com/docs/postdfm/). + +## Contributing + +Bug reports and feature requests are greatly appreciated, as are pull requests. + +Please see the [Contributing Guide](https://github.com/spiltcoffee/postdfm/blob/master/.github/CONTRIBUTING.md) for instructions on how to contribute to this project. + +## License + +Licensed under the MIT License. diff --git a/packages/postdfm/__test__/broken/index.test.ts b/packages/postdfm/__test__/broken/index.test.ts index ab2adbb7..1744372b 100644 --- a/packages/postdfm/__test__/broken/index.test.ts +++ b/packages/postdfm/__test__/broken/index.test.ts @@ -1,41 +1,41 @@ -import * as fs from "fs"; -import * as path from "path"; -import postdfm from "../../src"; - -describe("postdfm", () => { - describe("broken DFMs throw errors", () => { - describe("unexpected end", () => { - const file = path.join(__dirname, "unexpectedEnd.dfm"); - const dfm = fs.readFileSync(file, "ascii"); - - test("without `from`", () => { - expect(() => postdfm().processSync(dfm)).toThrow( - /Unexpected End Of Input/ - ); - }); - - test("with `from`", () => { - expect(() => postdfm().processSync(dfm, { from: file })).toThrow( - /unexpectedEnd.dfm: Unexpected End Of Input/ - ); - }); - }); - - describe("invalid property", () => { - const file = path.join(__dirname, "invalidProperty.dfm"); - const dfm = fs.readFileSync(file, "ascii"); - - test("without `from`", () => { - expect(() => postdfm().processSync(dfm)).toThrow( - /Syntax error at line 3 col 1/ - ); - }); - - test("with `from`", () => { - expect(() => postdfm().processSync(dfm, { from: file })).toThrow( - /invalidProperty.dfm: Syntax error at line 3 col 1/ - ); - }); - }); - }); -}); +import * as fs from "fs"; +import * as path from "path"; +import postdfm from "../../src"; + +describe("postdfm", () => { + describe("broken DFMs throw errors", () => { + describe("unexpected end", () => { + const file = path.join(__dirname, "unexpectedEnd.dfm"); + const dfm = fs.readFileSync(file, "ascii"); + + test("without `from`", () => { + expect(() => postdfm().processSync(dfm)).toThrow( + /Unexpected End Of Input/ + ); + }); + + test("with `from`", () => { + expect(() => postdfm().processSync(dfm, { from: file })).toThrow( + /unexpectedEnd.dfm: Unexpected End Of Input/ + ); + }); + }); + + describe("invalid property", () => { + const file = path.join(__dirname, "invalidProperty.dfm"); + const dfm = fs.readFileSync(file, "ascii"); + + test("without `from`", () => { + expect(() => postdfm().processSync(dfm)).toThrow( + /Syntax error at line 3 col 1/ + ); + }); + + test("with `from`", () => { + expect(() => postdfm().processSync(dfm, { from: file })).toThrow( + /invalidProperty.dfm: Syntax error at line 3 col 1/ + ); + }); + }); + }); +}); diff --git a/packages/postdfm/__test__/fixtures/index.test.ts b/packages/postdfm/__test__/fixtures/index.test.ts index fa39ed66..ade5756a 100644 --- a/packages/postdfm/__test__/fixtures/index.test.ts +++ b/packages/postdfm/__test__/fixtures/index.test.ts @@ -1,70 +1,70 @@ -import * as fs from "fs"; -import * as path from "path"; -import postdfm from "../../src"; -import { Root } from "@postdfm/ast"; - -const rootFixturesDir = path.resolve("__test__", "__fixtures__"); -const parseFixturesDir = path.join(rootFixturesDir, "parse"); -const transformFixturesDir = path.join(rootFixturesDir, "transform"); - -function noopTransform(ast: Root): Root { - return ast; -} - -describe("postdfm", () => { - describe("parse fixtures", () => { - const runner = postdfm({ - transformers: [noopTransform] - }); - - const fixtures = fs.readdirSync(parseFixturesDir); - fixtures.forEach(fixture => { - const cisForm = fs.readFileSync( - path.join(parseFixturesDir, fixture, "form.dfm"), - "ascii" - ); - - describe(`${fixture}`, () => { - test("sync", () => { - expect(runner.processSync(cisForm)).toEqual(cisForm); - }); - - test("async", () => { - return runner - .process(cisForm) - .then(dfm => expect(dfm).toEqual(cisForm)); - }); - }); - }); - }); - - describe("transform fixtures", () => { - const fixtures = fs.readdirSync(transformFixturesDir); - fixtures.forEach(fixture => { - const fixtureDir = path.join(transformFixturesDir, fixture); - const cisForm = fs.readFileSync( - path.join(fixtureDir, "cis.dfm"), - "ascii" - ); - const transForm = fs.readFileSync( - path.join(fixtureDir, "trans.dfm"), - "ascii" - ); - const transformers = [require(path.join(fixtureDir, "transformer.js"))]; - - const runner = postdfm({ transformers }); - - describe(`${fixture}`, () => { - test("sync", () => { - expect(runner.processSync(cisForm)).toEqual(transForm); - }); - - test("async", () => { - return runner - .process(cisForm) - .then(dfm => expect(dfm).toEqual(transForm)); - }); - }); - }); - }); -}); +import * as fs from "fs"; +import * as path from "path"; +import postdfm from "../../src"; +import { Root } from "@postdfm/ast"; + +const rootFixturesDir = path.resolve("__test__", "__fixtures__"); +const parseFixturesDir = path.join(rootFixturesDir, "parse"); +const transformFixturesDir = path.join(rootFixturesDir, "transform"); + +function noopTransform(ast: Root): Root { + return ast; +} + +describe("postdfm", () => { + describe("parse fixtures", () => { + const runner = postdfm({ + transformers: [noopTransform], + }); + + const fixtures = fs.readdirSync(parseFixturesDir); + fixtures.forEach((fixture) => { + const cisForm = fs.readFileSync( + path.join(parseFixturesDir, fixture, "form.dfm"), + "ascii" + ); + + describe(`${fixture}`, () => { + test("sync", () => { + expect(runner.processSync(cisForm)).toEqual(cisForm); + }); + + test("async", () => { + return runner + .process(cisForm) + .then((dfm) => expect(dfm).toEqual(cisForm)); + }); + }); + }); + }); + + describe("transform fixtures", () => { + const fixtures = fs.readdirSync(transformFixturesDir); + fixtures.forEach((fixture) => { + const fixtureDir = path.join(transformFixturesDir, fixture); + const cisForm = fs.readFileSync( + path.join(fixtureDir, "cis.dfm"), + "ascii" + ); + const transForm = fs.readFileSync( + path.join(fixtureDir, "trans.dfm"), + "ascii" + ); + const transformers = [require(path.join(fixtureDir, "transformer.js"))]; + + const runner = postdfm({ transformers }); + + describe(`${fixture}`, () => { + test("sync", () => { + expect(runner.processSync(cisForm)).toEqual(transForm); + }); + + test("async", () => { + return runner + .process(cisForm) + .then((dfm) => expect(dfm).toEqual(transForm)); + }); + }); + }); + }); +}); diff --git a/packages/postdfm/__test__/options/index.test.ts b/packages/postdfm/__test__/options/index.test.ts index a21d3431..808ec53b 100644 --- a/packages/postdfm/__test__/options/index.test.ts +++ b/packages/postdfm/__test__/options/index.test.ts @@ -1,63 +1,63 @@ -import { stringify } from "@postdfm/ast2dfm"; -import { parse } from "@postdfm/dfm2ast"; -import * as path from "path"; -import postdfm, { RunnerOptions, Transformer } from "../../src"; -import { Root } from "@postdfm/ast"; - -function noopTransformer(ast: Root): Root { - return ast; -} - -describe("postdfm", () => { - describe("options", () => { - test("valid (normal)", () => { - const parser = parse; - const stringifier = stringify; - const transformers: Transformer[] = [noopTransformer]; - - postdfm(); - postdfm({ parser }); - postdfm({ stringifier }); - postdfm({ transformers }); - postdfm({ parser, stringifier }); - postdfm({ parser, transformers }); - postdfm({ stringifier, transformers }); - postdfm({ parser, stringifier, transformers }); - }); - - test("valid (using strings)", () => { - const parser = "@postdfm/dfm2ast"; - const stringifier = "@postdfm/ast2dfm"; - const transformers = [path.join(__dirname, "transformer.js")]; - - postdfm(); - postdfm({ parser }); - postdfm({ stringifier }); - postdfm({ transformers }); - postdfm({ parser, stringifier }); - postdfm({ parser, transformers }); - postdfm({ stringifier, transformers }); - postdfm({ parser, stringifier, transformers }); - }); - - test("invalid", () => { - const parser = true; - const stringifier = 5; - const transformer1 = {}; - const transformer2 = [5]; - - expect(() => postdfm(({ parser } as unknown) as RunnerOptions)).toThrow( - /parser must be a string or a function/ - ); - expect(() => - postdfm(({ stringifier } as unknown) as RunnerOptions) - ).toThrow(/stringifier must be a string or a function/); - expect(() => - postdfm(({ transformers: transformer1 } as unknown) as RunnerOptions) - ).toThrow(/transformers must be an array of strings and\/or functions/); - expect(() => - postdfm(({ transformers: transformer2 } as unknown) as RunnerOptions) - ).toThrow(/transformers must be an array of strings and\/or functions/); - }); - }); -}); +import { stringify } from "@postdfm/ast2dfm"; +import { parse } from "@postdfm/dfm2ast"; +import * as path from "path"; +import postdfm, { RunnerOptions, Transformer } from "../../src"; +import { Root } from "@postdfm/ast"; + +function noopTransformer(ast: Root): Root { + return ast; +} + +describe("postdfm", () => { + describe("options", () => { + test("valid (normal)", () => { + const parser = parse; + const stringifier = stringify; + const transformers: Transformer[] = [noopTransformer]; + + postdfm(); + postdfm({ parser }); + postdfm({ stringifier }); + postdfm({ transformers }); + postdfm({ parser, stringifier }); + postdfm({ parser, transformers }); + postdfm({ stringifier, transformers }); + postdfm({ parser, stringifier, transformers }); + }); + + test("valid (using strings)", () => { + const parser = "@postdfm/dfm2ast"; + const stringifier = "@postdfm/ast2dfm"; + const transformers = [path.join(__dirname, "transformer.js")]; + + postdfm(); + postdfm({ parser }); + postdfm({ stringifier }); + postdfm({ transformers }); + postdfm({ parser, stringifier }); + postdfm({ parser, transformers }); + postdfm({ stringifier, transformers }); + postdfm({ parser, stringifier, transformers }); + }); + + test("invalid", () => { + const parser = true; + const stringifier = 5; + const transformer1 = {}; + const transformer2 = [5]; + + expect(() => postdfm(({ parser } as unknown) as RunnerOptions)).toThrow( + /parser must be a string or a function/ + ); + expect(() => + postdfm(({ stringifier } as unknown) as RunnerOptions) + ).toThrow(/stringifier must be a string or a function/); + expect(() => + postdfm(({ transformers: transformer1 } as unknown) as RunnerOptions) + ).toThrow(/transformers must be an array of strings and\/or functions/); + expect(() => + postdfm(({ transformers: transformer2 } as unknown) as RunnerOptions) + ).toThrow(/transformers must be an array of strings and\/or functions/); + }); + }); +}); diff --git a/packages/postdfm/__test__/options/transformer.js b/packages/postdfm/__test__/options/transformer.js index 05f7696c..e48737e2 100644 --- a/packages/postdfm/__test__/options/transformer.js +++ b/packages/postdfm/__test__/options/transformer.js @@ -1 +1 @@ -module.exports = ast => ast; +module.exports = (ast) => ast; diff --git a/packages/postdfm/src/index.ts b/packages/postdfm/src/index.ts index 70678bad..ad1999ee 100644 --- a/packages/postdfm/src/index.ts +++ b/packages/postdfm/src/index.ts @@ -76,7 +76,7 @@ export default function postdfm(options?: RunnerOptions): Runner { const internalOptions: InternalRunnerOptions = { parser: parse, stringifier: stringify, - transformers: [] + transformers: [], }; if (options) { @@ -107,7 +107,7 @@ export default function postdfm(options?: RunnerOptions): Runner { ); } - options.transformers.forEach(transformer => { + options.transformers.forEach((transformer) => { let internalTransformer: Transformer; if (typeof transformer === "string") { internalTransformer = require(transformer); diff --git a/packages/postdfm/typedoc.config.js b/packages/postdfm/typedoc.config.js index 8f5fce73..5dc7f9a7 100644 --- a/packages/postdfm/typedoc.config.js +++ b/packages/postdfm/typedoc.config.js @@ -1,3 +1,3 @@ -module.exports = require("../../typedoc")({ - out: "postdfm" -}); +module.exports = require("../../typedoc")({ + out: "postdfm", +}); diff --git a/release.config.js b/release.config.js index e43ed7d4..4aba51e6 100644 --- a/release.config.js +++ b/release.config.js @@ -20,8 +20,8 @@ module.exports = { "@semantic-release/npm", { pkgRoot, - tarballDir - } + tarballDir, + }, ]), [ "@semantic-release/github", @@ -31,17 +31,17 @@ module.exports = { tarballDir, `${name.replace("@", "").replace("/", "-")}-*.tgz` ), - label: name - })) - } + label: name, + })), + }, ], [ "@semantic-release/git", { assets: [ - ["packages/**/package.json", "!**/node_modules/**/package.json"] - ] - } - ] - ] + ["packages/**/package.json", "!**/node_modules/**/package.json"], + ], + }, + ], + ], }; diff --git a/typedoc.js b/typedoc.js index a1272d14..568fcd98 100644 --- a/typedoc.js +++ b/typedoc.js @@ -1,13 +1,13 @@ -const path = require("path"); - -module.exports = options => - Object.assign( - { - excludePrivate: true, - theme: "minimal" - }, - options, - { - out: path.resolve(__dirname, "docs", options.out) - } - ); +const path = require("path"); + +module.exports = (options) => + Object.assign( + { + excludePrivate: true, + theme: "minimal", + }, + options, + { + out: path.resolve(__dirname, "docs", options.out), + } + );