New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add json schema of fixture runner options #12619
Merged
nicolo-ribaudo
merged 3 commits into
babel:main
from
JLHwung:add-json-schema-of-fixture-options
Jul 4, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"/**/fixtures/*/options.json", | ||
"!/packages/babel-parser/test/fixtures/**/options.json" | ||
], | ||
"url": "./packages/babel-helper-fixtures/data/schema.json" | ||
}, | ||
{ | ||
"fileMatch": [ | ||
"/packages/babel-parser/test/fixtures/**/options.json" | ||
], | ||
"url": "./packages/babel-parser/test/schema.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Options", | ||
"description": "JSON schema for Babel Fixture Test Runner", | ||
"allOf": [ | ||
{ "$ref": "#/definitions/TaskOption" }, | ||
{ "$ref": "https://json.schemastore.org/babelrc", "$comment": "Todo: switch to our inhouse schema" } | ||
], | ||
"definitions": { | ||
"OS": { | ||
"type":"string", | ||
"description": "The possible values of `process.platform`. See https://nodejs.org/api/process.html#process_process_platform", | ||
"enum": ["aix", "darwin", "freebsd", "linux", "openbsd", "sunos", "win32"] | ||
}, | ||
"TaskOption": { | ||
"type": "object", | ||
"properties": { | ||
"BABEL_8_BREAKING": { | ||
"description": "Whether this test should run when BABEL_8_BREAKING is enabled", | ||
"type":"boolean" | ||
}, | ||
"ignoreOutput": { | ||
"description": "Whether the test should generate and compare with output.js", | ||
"type": "boolean" | ||
}, | ||
"minNodeVersion": { | ||
"description": "The minimum Node.js version this test should run on", | ||
"type": "string", | ||
"pattern": "^\\d+(\\.\\d+){0,2}$" | ||
}, | ||
"os": { | ||
"description": "The OS this test should run on", | ||
"anyOf": [ | ||
{ "type": "array", "items": { "$ref": "#/definitions/OS" } }, | ||
{ | ||
"$ref": "#/definitions/OS" | ||
} | ||
] | ||
}, | ||
"throws": { | ||
"description": "Expected thrown error message", | ||
"type":"string", | ||
"default": "" | ||
}, | ||
"validateLogs": { | ||
"description": "Whether this test should validate the stdout and stderr", | ||
"type":"boolean", | ||
"default": false | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"DecoratorsPluginOptions": { | ||
"properties": { | ||
"decoratorsBeforeExport": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"FlowPluginOptions": { | ||
"properties": { | ||
"all": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"PipelineOperatorPluginOptions": { | ||
"properties": { | ||
"proposal": { | ||
"enum": ["fsharp", "minimal", "smart"], | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"RecordAndTuplePluginOptions": { | ||
"properties": { | ||
"syntaxType": { | ||
"enum": ["bar", "hash"], | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"properties": { | ||
"allowAwaitOutsideFunction": { | ||
"description": "By default, await use is not allowed outside of an async function.\nSet this to true to accept such code.", | ||
"type": "boolean" | ||
}, | ||
"allowImportExportEverywhere": { | ||
"description": "By default, import and export declarations can only appear at a program's top level.\nSetting this option to true allows them anywhere where a statement is allowed.", | ||
"type": "boolean" | ||
}, | ||
"allowReturnOutsideFunction": { | ||
"description": "By default, a return statement at the top level raises an error.\nSet this to true to accept such code.", | ||
"type": "boolean" | ||
}, | ||
"allowSuperOutsideMethod": { | ||
"type": "boolean" | ||
}, | ||
"allowUndeclaredExports": { | ||
"description": "By default, exported identifiers must refer to a declared variable.\nSet this to true to allow export statements to reference undeclared variables.", | ||
"type": "boolean" | ||
}, | ||
"createParenthesizedExpressions": { | ||
"description": "By default, the parser adds information about parentheses by setting\n`extra.parenthesized` to `true` as needed.\nWhen this option is `true` the parser creates `ParenthesizedExpression`\nAST nodes instead of using the `extra` property.", | ||
"type": "boolean" | ||
}, | ||
"errorRecovery": { | ||
"description": "By default, Babel always throws an error when it finds some invalid code.\nWhen this option is set to true, it will store the parsing error and\ntry to continue parsing the invalid input file.", | ||
"type": "boolean" | ||
}, | ||
"plugins": { | ||
"description": "Array containing the plugins that you want to enable.", | ||
"items": { | ||
"anyOf": [ | ||
{ | ||
"items": [ | ||
{ | ||
"enum": ["decorators"], | ||
"type": "string" | ||
}, | ||
{ | ||
"$ref": "#/definitions/DecoratorsPluginOptions" | ||
} | ||
], | ||
"additionalItems": false, | ||
"type": "array" | ||
}, | ||
{ | ||
"items": [ | ||
{ | ||
"enum": ["pipelineOperator"], | ||
"type": "string" | ||
}, | ||
{ | ||
"$ref": "#/definitions/PipelineOperatorPluginOptions" | ||
} | ||
], | ||
"additionalItems": false, | ||
"type": "array" | ||
}, | ||
{ | ||
"items": [ | ||
{ | ||
"enum": ["recordAndTuple"], | ||
"type": "string" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RecordAndTuplePluginOptions" | ||
} | ||
], | ||
"additionalItems": false, | ||
"type": "array" | ||
}, | ||
{ | ||
"items": [ | ||
{ | ||
"enum": ["flow"], | ||
"type": "string" | ||
}, | ||
{ | ||
"$ref": "#/definitions/FlowPluginOptions" | ||
} | ||
], | ||
"additionalItems": false, | ||
"type": "array" | ||
}, | ||
{ | ||
"enum": [ | ||
"asyncGenerators", | ||
"bigInt", | ||
"classPrivateMethods", | ||
"classPrivateProperties", | ||
"classProperties", | ||
"classStaticBlock", | ||
"decimal", | ||
"decorators", | ||
"decorators-legacy", | ||
"doExpressions", | ||
"dynamicImport", | ||
"estree", | ||
"exportDefaultFrom", | ||
"exportNamespaceFrom", | ||
"flow", | ||
"flowComments", | ||
"functionBind", | ||
"functionSent", | ||
"importAssertions", | ||
"importMeta", | ||
"jsx", | ||
"logicalAssignment", | ||
"moduleStringNames", | ||
"nullishCoalescingOperator", | ||
"numericSeparator", | ||
"objectRestSpread", | ||
"optionalCatchBinding", | ||
"optionalChaining", | ||
"partialApplication", | ||
"pipelineOperator", | ||
"placeholders", | ||
"privateIn", | ||
"throwExpressions", | ||
"topLevelAwait", | ||
"typescript", | ||
"v8intrinsic" | ||
], | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"type": "array" | ||
}, | ||
"ranges": { | ||
"description": "Adds a ranges property to each node: [node.start, node.end]", | ||
"type": "boolean" | ||
}, | ||
"sourceFilename": { | ||
"description": "Correlate output AST nodes with their source filename.\nUseful when generating code and source maps from the ASTs of multiple input files.", | ||
"type": "string" | ||
}, | ||
"sourceType": { | ||
"description": "Indicate the mode the code should be parsed in.\nCan be one of \"script\", \"module\", or \"unambiguous\". Defaults to \"script\".\n\"unambiguous\" will make @babel/parser attempt to guess, based on the presence\nof ES6 import or export statements.\nFiles with ES6 imports and exports are considered \"module\" and are otherwise \"script\".", | ||
"enum": ["module", "script", "unambiguous"], | ||
"type": "string" | ||
}, | ||
"startLine": { | ||
"description": "By default, the first line of code parsed is treated as line 1.\nYou can provide a line number to alternatively start with.\nUseful for integration with other source tools.", | ||
"type": "number" | ||
}, | ||
"strictMode": { | ||
"description": "Should the parser work in strict mode.\nDefaults to true if sourceType === 'module'. Otherwise, false.", | ||
"type": "boolean" | ||
}, | ||
"tokens": { | ||
"description": "Adds all parsed tokens to a tokens property on the File node.", | ||
"type": "boolean" | ||
} | ||
}, | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Options", | ||
"description": "JSON schema for Babel Parser Fixture Test Runner", | ||
"allOf": [ | ||
{ "$ref": "#/definitions/TaskOption" }, | ||
{ "$ref": "../data/schema.json" } | ||
], | ||
"definitions": { | ||
"TaskOption": { | ||
"type": "object", | ||
"properties": { | ||
"throws": { | ||
"description": "Expected thrown error message", | ||
"type":"string", | ||
"default": "" | ||
} | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema was generated from
typings/babel-parser.d.ts
by https://github.com/YousefED/typescript-json-schema. I have tuned a little bit: replacingminItems: 2, maxItems: 2
toadditionalItems: false
.We should explore generating API option types from JSON schema or vice.