diff --git a/tests/ast-alignment/known-issues.js b/tests/ast-alignment/known-issues.js new file mode 100644 index 0000000..e00cd9b --- /dev/null +++ b/tests/ast-alignment/known-issues.js @@ -0,0 +1,88 @@ +/** + * ================================================== + * KNOWN/DIAGNOSED ISSUES + * ================================================== + */ + +// const fixturePatternsToTest = [ + /** + * "ExperimentalSpreadProperty" in espree/typescript-eslint-parser vs "SpreadElement" in Babylon + * comes up a lot in this section + */ + // "ecma-features/experimentalObjectRestSpread/**/*.src.js", // mixture of babylon parse errors and AST diffs + + /* ================================================== */ + + /** + * Template strings seem to also be affected by the difference in opinion between different parsers in: + * https://github.com/babel/babylon/issues/673 + */ + // "comments/no-comment-template.src.js", // Purely AST diffs + // "comments/template-string-block.src.js", // Purely AST diffs + // "ecma-features/templateStrings/**/*.src.js", // mixture of babylon parse errors and AST diffs + + /* ================================================== */ + + /** + * TypeScript, espree and acorn parse this fine - esprima, flow and babylon do not... + */ + // "ecma-features/forOf/for-of-with-function-initializer.src.js", // babylon parse errors + + /* ================================================== */ + + /** + * TypeScript, flow and babylon parse this fine - esprima, espree and acorn do not... + */ + // "ecma-features/modules/invalid-export-default.src.js",, // typescript-eslint-parser parse errors + + /* ================================================== */ + + /** + * Babylon parse error because of more strict spec enforcement than other parsers. + */ + + /** + * super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this. + */ + // "ecma-features/classes/class-one-method-super.src.js", // babylon parse errors + + /* ================================================== */ + + /** + * Expected babylon parse errors - all of these files below produce parse errors in espree + * as well, but the TypeScript compiler is so forgiving during parsing that typescript-eslint-parser + * does not actually error on them and will produce an AST. + */ + // "ecma-features/arrowFunctions/error-dup-params.src.js", // babylon parse errors + // "ecma-features/arrowFunctions/error-dup-params.src.js", // babylon parse errors + // "ecma-features/arrowFunctions/error-strict-dup-params.src.js", // babylon parse errors + // "ecma-features/arrowFunctions/error-strict-octal.src.js", // babylon parse errors + // "ecma-features/arrowFunctions/error-two-lines.src.js", // babylon parse errors + // "ecma-features/classes/invalid-class-declaration.src.js", // babylon parse errors + // "ecma-features/classes/invalid-class-setter-declaration.src.js", // babylon parse errors + // "ecma-features/destructuring/invalid-defaults-object-assign.src.js", // babylon parse errors + // "ecma-features/destructuring-and-spread/error-complex-destructured-spread-first.src.js", // babylon parse errors + // "ecma-features/objectLiteralDuplicateProperties/error-proto-property.src.js", // babylon parse errors + // "ecma-features/objectLiteralDuplicateProperties/error-proto-string-property.src.js", // babylon parse errors + // "ecma-features/modules/invalid-export-named-default.src.js", // babylon parse errors + // "ecma-features/modules/invalid-import-default-module-specifier.src.js", // babylon parse errors + // "ecma-features/modules/invalid-import-module-specifier.src.js", // babylon parse errors + // "ecma-features/newTarget/invalid-new-target.src.js", // babylon parse errors + // "ecma-features/newTarget/invalid-unknown-property.src.js", // babylon parse errors + // "ecma-features/restParams/error-no-default.src.js", // babylon parse errors + // "ecma-features/restParams/error-not-last.src.js", // babylon parse errors + /** + * Deleting local variable in strict mode + */ + // { + // pattern: "ecma-features/modules/error-delete.src.js", + // config: { babylonParserOptions: { sourceType: "module" } } + // }, + /** + * 'with' in strict mode + */ + // { + // pattern: "ecma-features/modules/error-strict.src.js", + // config: { babylonParserOptions: { sourceType: "module" } } + // }, +// ]; diff --git a/tests/ast-alignment/parse.js b/tests/ast-alignment/parse.js index 180d6f1..9ef4013 100644 --- a/tests/ast-alignment/parse.js +++ b/tests/ast-alignment/parse.js @@ -13,9 +13,10 @@ function createError(message, line, column) { // eslint-disable-line return error; } -function parseWithBabylonPluginTypescript(text) { // eslint-disable-line +function parseWithBabylonPluginTypescript(text, parserOptions) { // eslint-disable-line + parserOptions = parserOptions || {}; const babylon = require("babylon"); - return babylon.parse(text, { + return babylon.parse(text, Object.assign({ sourceType: "script", allowImportExportEverywhere: true, allowReturnOutsideFunction: true, @@ -35,13 +36,14 @@ function parseWithBabylonPluginTypescript(text) { // eslint-disable-line "numericSeparator", "estree" ] - }); + }, parserOptions)); } -function parseWithTypeScriptESLintParser(text) { // eslint-disable-line +function parseWithTypeScriptESLintParser(text, parserOptions) { // eslint-disable-line + parserOptions = parserOptions || {}; const parser = require("../../parser"); try { - return parser.parse(text, { + return parser.parse(text, Object.assign({ loc: true, range: true, tokens: false, @@ -51,7 +53,7 @@ function parseWithTypeScriptESLintParser(text) { // eslint-disable-line ecmaFeatures: { jsx: true } - }); + }, parserOptions)); } catch (e) { throw createError( e.message, @@ -63,21 +65,26 @@ function parseWithTypeScriptESLintParser(text) { // eslint-disable-line module.exports = function parse(text, opts) { - let parseFunction; - - switch (opts.parser) { - case "typescript-eslint-parser": - parseFunction = parseWithTypeScriptESLintParser; - break; - case "babylon-plugin-typescript": - parseFunction = parseWithBabylonPluginTypescript; - break; - default: - throw new Error("Please provide a valid parser: either \"typescript-eslint-parser\" or \"babylon-plugin-typescript\""); - } + /** + * Always return a consistent interface, there will be times when we expect both + * parsers to fail to parse the invalid source. + */ + const result = { + parseError: null, + ast: null + }; try { - return parseUtils.normalizeNodeTypes(parseFunction(text)); + switch (opts.parser) { + case "typescript-eslint-parser": + result.ast = parseUtils.normalizeNodeTypes(parseWithTypeScriptESLintParser(text, opts.typeScriptESLintParserOptions)); + break; + case "babylon-plugin-typescript": + result.ast = parseUtils.normalizeNodeTypes(parseWithBabylonPluginTypescript(text, opts.babylonParserOptions)); + break; + default: + throw new Error("Please provide a valid parser: either \"typescript-eslint-parser\" or \"babylon-plugin-typescript\""); + } } catch (error) { const loc = error.loc; if (loc) { @@ -86,7 +93,9 @@ module.exports = function parse(text, opts) { }); error.message += `\n${error.codeFrame}`; } - throw error; + result.parseError = error; } + return result; + }; diff --git a/tests/ast-alignment/spec.js b/tests/ast-alignment/spec.js index 73bf551..ee8d169 100644 --- a/tests/ast-alignment/spec.js +++ b/tests/ast-alignment/spec.js @@ -6,20 +6,431 @@ const glob = require("glob"); const parse = require("./parse"); const parseUtils = require("./utils"); +/** + * JSX fixtures which have known issues for typescript-eslint-parser + */ +const jsxFilesWithKnownIssues = require("../jsx-known-issues"); + +/** + * Current random error difference on jsx/invalid-no-tag-name.src.js + * TSEP - SyntaxError + * Babylon - RangeError + * + * Reported here: https://github.com/babel/babylon/issues/674 + */ +jsxFilesWithKnownIssues.push("jsx/invalid-no-tag-name"); + +const jsxPattern = `jsx/!(${jsxFilesWithKnownIssues.map(f => f.replace("jsx/", "")).join("|")}).src.js`; + const fixturesDirPath = path.join(__dirname, "../fixtures"); + +// Either a string of the pattern, or an object containing the pattern and some additional config const fixturePatternsToTest = [ - "basics/instanceof.src.js", - "basics/update-expression.src.js", - "basics/new-without-parens.src.js", - "ecma-features/arrowFunctions/**/as*.src.js", - "jsx/attributes.src.js" + "basics/**/*.src.js", + + "comments/block-trailing-comment.src.js", + "comments/comment-within-condition.src.js", + "comments/jsx-block-comment.src.js", + "comments/jsx-tag-comments.src.js", + "comments/line-comment-with-block-syntax.src.js", + "comments/mix-line-and-block-comments.src.js", + "comments/no-comment-regex.src.js", + "comments/surrounding-call-comments.src.js", + "comments/surrounding-debugger-comments.src.js", + "comments/surrounding-return-comments.src.js", + "comments/surrounding-throw-comments.src.js", + "comments/surrounding-while-loop-comments.src.js", + "comments/switch-fallthrough-comment-in-function.src.js", + "comments/switch-fallthrough-comment.src.js", + "comments/switch-no-default-comment-in-function.src.js", + "comments/switch-no-default-comment-in-nested-functions.src.js", + "comments/switch-no-default-comment.src.js", + + "ecma-features/arrowFunctions/as-param-with-params.src.js", + "ecma-features/arrowFunctions/as-param.src.js", + "ecma-features/arrowFunctions/basic.src.js", + "ecma-features/arrowFunctions/basic-in-binary-expression.src.js", + "ecma-features/arrowFunctions/block-body-not-object.src.js", + "ecma-features/arrowFunctions/block-body.src.js", + "ecma-features/arrowFunctions/error-missing-paren.src.js", + "ecma-features/arrowFunctions/error-not-arrow.src.js", + "ecma-features/arrowFunctions/error-numeric-param-multi.src.js", + "ecma-features/arrowFunctions/error-numeric-param.src.js", + "ecma-features/arrowFunctions/error-reverse-arrow.src.js", + "ecma-features/arrowFunctions/error-strict-default-param-eval.src.js", + "ecma-features/arrowFunctions/error-strict-eval-return.src.js", + "ecma-features/arrowFunctions/error-strict-eval.src.js", + "ecma-features/arrowFunctions/error-strict-param-arguments.src.js", + "ecma-features/arrowFunctions/error-strict-param-eval.src.js", + "ecma-features/arrowFunctions/error-strict-param-names.src.js", + "ecma-features/arrowFunctions/error-strict-param-no-paren-arguments.src.js", + "ecma-features/arrowFunctions/error-strict-param-no-paren-eval.src.js", + "ecma-features/arrowFunctions/error-wrapped-param.src.js", + "ecma-features/arrowFunctions/expression.src.js", + "ecma-features/arrowFunctions/iife.src.js", + "ecma-features/arrowFunctions/multiple-params.src.js", + "ecma-features/arrowFunctions/no-auto-return.src.js", + "ecma-features/arrowFunctions/not-strict-arguments.src.js", + "ecma-features/arrowFunctions/not-strict-eval-params.src.js", + "ecma-features/arrowFunctions/not-strict-eval.src.js", + "ecma-features/arrowFunctions/not-strict-octal.src.js", + "ecma-features/arrowFunctions/return-arrow-function.src.js", + "ecma-features/arrowFunctions/return-sequence.src.js", + "ecma-features/arrowFunctions/single-param-parens.src.js", + "ecma-features/arrowFunctions/single-param-return-identifier.src.js", + "ecma-features/arrowFunctions/single-param.src.js", + "ecma-features/binaryLiterals/**/*.src.js", + "ecma-features/blockBindings/**/*.src.js", + "ecma-features/classes/class-accessor-properties.src.js", + "ecma-features/classes/class-computed-static-method.src.js", + "ecma-features/classes/class-expression.src.js", + "ecma-features/classes/class-method-named-prototype.src.js", + "ecma-features/classes/class-method-named-static.src.js", + "ecma-features/classes/class-method-named-with-space.src.js", + "ecma-features/classes/class-one-method.src.js", + "ecma-features/classes/class-static-method-named-prototype.src.js", + "ecma-features/classes/class-static-method-named-static.src.js", + "ecma-features/classes/class-static-method.src.js", + "ecma-features/classes/class-static-methods-and-accessor-properties.src.js", + "ecma-features/classes/class-two-computed-static-methods.src.js", + "ecma-features/classes/class-two-methods-computed-constructor.src.js", + "ecma-features/classes/class-two-methods-semi.src.js", + "ecma-features/classes/class-two-methods-three-semi.src.js", + "ecma-features/classes/class-two-methods-two-semi.src.js", + "ecma-features/classes/class-two-methods.src.js", + "ecma-features/classes/class-two-static-methods-named-constructor.src.js", + "ecma-features/classes/class-with-constructor-parameters.src.js", + "ecma-features/classes/class-with-constructor-with-space.src.js", + "ecma-features/classes/class-with-constructor.src.js", + "ecma-features/classes/derived-class-assign-to-var.src.js", + "ecma-features/classes/derived-class-expression.src.js", + "ecma-features/classes/empty-class-double-semi.src.js", + "ecma-features/classes/empty-class-semi.src.js", + "ecma-features/classes/empty-class.src.js", + "ecma-features/classes/empty-literal-derived-class.src.js", + "ecma-features/classes/named-class-expression.src.js", + "ecma-features/classes/named-derived-class-expression.src.js", + "ecma-features/defaultParams/**/*.src.js", + "ecma-features/destructuring/array-member.src.js", + "ecma-features/destructuring/array-to-array.src.js", + "ecma-features/destructuring/array-var-undefined.src.js", + "ecma-features/destructuring/class-constructor-params-array.src.js", + "ecma-features/destructuring/class-constructor-params-defaults-array.src.js", + "ecma-features/destructuring/class-constructor-params-defaults-object.src.js", + "ecma-features/destructuring/class-constructor-params-object.src.js", + "ecma-features/destructuring/class-method-params-array.src.js", + "ecma-features/destructuring/class-method-params-defaults-array.src.js", + "ecma-features/destructuring/class-method-params-defaults-object.src.js", + "ecma-features/destructuring/class-method-params-object.src.js", + "ecma-features/destructuring/defaults-array-all.src.js", + "ecma-features/destructuring/defaults-array-longform-nested-multi.src.js", + "ecma-features/destructuring/defaults-array-multi.src.js", + "ecma-features/destructuring/defaults-array-nested-all.src.js", + "ecma-features/destructuring/defaults-array-nested-multi.src.js", + "ecma-features/destructuring/defaults-array.src.js", + "ecma-features/destructuring/defaults-object-all.src.js", + "ecma-features/destructuring/defaults-object-longform-all.src.js", + "ecma-features/destructuring/defaults-object-longform-multi.src.js", + "ecma-features/destructuring/defaults-object-longform.src.js", + "ecma-features/destructuring/defaults-object-mixed-multi.src.js", + "ecma-features/destructuring/defaults-object-multi.src.js", + "ecma-features/destructuring/defaults-object-nested-all.src.js", + "ecma-features/destructuring/defaults-object-nested-multi.src.js", + "ecma-features/destructuring/defaults-object.src.js", + "ecma-features/destructuring/destructured-array-catch.src.js", + "ecma-features/destructuring/destructured-object-catch.src.js", + "ecma-features/destructuring/named-param.src.js", + "ecma-features/destructuring/nested-array.src.js", + "ecma-features/destructuring/nested-object.src.js", + "ecma-features/destructuring/object-var-named.src.js", + "ecma-features/destructuring/object-var-undefined.src.js", + "ecma-features/destructuring/param-defaults-array.src.js", + "ecma-features/destructuring/param-defaults-object-nested.src.js", + "ecma-features/destructuring/param-defaults-object.src.js", + "ecma-features/destructuring/params-array-wrapped.src.js", + "ecma-features/destructuring/params-array.src.js", + "ecma-features/destructuring/params-multi-object.src.js", + "ecma-features/destructuring/params-nested-array.src.js", + "ecma-features/destructuring/params-nested-object.src.js", + "ecma-features/destructuring/params-object-wrapped.src.js", + "ecma-features/destructuring/params-object.src.js", + "ecma-features/destructuring/sparse-array.src.js", + "ecma-features/destructuring-and-arrowFunctions/**/*.src.js", + "ecma-features/destructuring-and-blockBindings/**/*.src.js", + "ecma-features/destructuring-and-defaultParams/**/*.src.js", + "ecma-features/destructuring-and-forOf/**/*.src.js", + "ecma-features/destructuring-and-spread/complex-destructured.src.js", + "ecma-features/destructuring-and-spread/destructured-array-literal.src.js", + "ecma-features/destructuring-and-spread/destructuring-param.src.js", + "ecma-features/destructuring-and-spread/multi-destructured.src.js", + "ecma-features/destructuring-and-spread/single-destructured.src.js", + "ecma-features/destructuring-and-spread/var-complex-destructured.src.js", + "ecma-features/destructuring-and-spread/var-destructured-array-literal.src.js", + "ecma-features/destructuring-and-spread/var-multi-destructured.src.js", + "ecma-features/destructuring-and-spread/var-single-destructured.src.js", + "ecma-features/experimentalAsyncIteration/**/*.src.js", + "ecma-features/experimentalDynamicImport/**/*.src.js", + "ecma-features/exponentiationOperators/**/*.src.js", + "ecma-features/forOf/for-of-with-var-and-braces.src.js", + "ecma-features/forOf/for-of-with-var-and-no-braces.src.js", + "ecma-features/forOf/invalid-for-of-with-const-and-no-braces.src.js", + "ecma-features/forOf/invalid-for-of-with-let-and-no-braces.src.js", + "ecma-features/generators/**/*.src.js", + "ecma-features/globalReturn/**/*.src.js", + "ecma-features/modules/error-function.src.js", + "ecma-features/modules/invalid-export-batch-missing-from-clause.src.js", + "ecma-features/modules/invalid-export-batch-token.src.js", + "ecma-features/modules/invalid-export-default-equal.src.js", + "ecma-features/modules/invalid-export-default-token.src.js (1ms)", + "ecma-features/modules/invalid-export-named-extra-comma.src.js", + "ecma-features/modules/invalid-export-named-middle-comma.src.js", + "ecma-features/modules/invalid-import-default-after-named-after-default.src.js", + "ecma-features/modules/invalid-import-default-after-named.src.js", + "ecma-features/modules/invalid-import-default-missing-module-specifier.src.js", + "ecma-features/modules/invalid-import-default.src.js (1ms)", + "ecma-features/modules/invalid-import-missing-module-specifier.src.js", + "ecma-features/modules/invalid-import-named-after-named.src.js", + "ecma-features/modules/invalid-import-named-after-namespace.src.js", + "ecma-features/modules/invalid-import-named-as-missing-from.src.js", + "ecma-features/modules/invalid-import-named-extra-comma.src.js", + "ecma-features/modules/invalid-import-named-middle-comma.src.js (1ms)", + "ecma-features/modules/invalid-import-namespace-after-named.src.js", + "ecma-features/modules/invalid-import-namespace-missing-as.src.js", + "ecma-features/newTarget/simple-new-target.src.js", + "ecma-features/objectLiteralComputedProperties/**/*.src.js", + "ecma-features/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js", + "ecma-features/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js", + "ecma-features/objectLiteralShorthandMethods/**/*.src.js", + "ecma-features/objectLiteralShorthandProperties/**/*.src.js", + "ecma-features/octalLiterals/**/*.src.js", + "ecma-features/regex/**/*.src.js", + "ecma-features/regexUFlag/**/*.src.js", + "ecma-features/regexYFlag/**/*.src.js", + "ecma-features/restParams/basic-rest.src.js", + "ecma-features/restParams/class-constructor.src.js", + "ecma-features/restParams/class-method.src.js", + "ecma-features/restParams/func-expression-multi.src.js", + "ecma-features/restParams/func-expression.src.js", + "ecma-features/restParams/invalid-rest-param.src.js", + "ecma-features/restParams/single-rest.src.js", + "ecma-features/spread/**/*.src.js", + "ecma-features/unicodeCodePointEscapes/**/*.src.js", + + jsxPattern, + + "jsx-useJSXTextNode/**/*.src.js", + + /** + * The TypeScript compiler gives us the "externalModuleIndicator" to allow typescript-eslint-parser do dynamically detect the "sourceType". + * Babylon does not have an equivalent feature (although perhaps it might come in the future https://github.com/babel/babylon/issues/440), + * so we have to specify the "sourceType" we want to use. + * + * By default we have configured babylon to use "script", but for the examples below we need "module". + * Maybe fixed by https://github.com/babel/babylon/commit/00ad6d8310ce826dcdd59c7a819dbd50955058d7? + */ + { + pattern: "comments/export-default-anonymous-class.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-array.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-class.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-expression.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-function.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-named-class.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-named-function.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-number.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-object.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-default-value.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-batch.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-default.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-named-as-default.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-named-as-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-named-as-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-from-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-function.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-as-default.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-as-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-as-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-class.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-empty.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-specifiers-comma.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-named-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-var-anonymous-function.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-var-number.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/export-var.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-default-and-named-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-default-and-namespace-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-default-as.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-default.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-jquery.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-module.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-as-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-as-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-empty.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-specifiers-comma.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-named-specifiers.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-namespace-specifier.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/import-null-as-nil.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/invalid-await.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + }, + { + pattern: "ecma-features/modules/invalid-class.src.js", + config: { babylonParserOptions: { sourceType: "module" } } + } + + /** + * Lots of issues, needs to be broken down + */ + // "typescript/**/*.src.ts" // lots and lots of issues... ]; +// Either a string of the pattern, or an object containing the pattern and some additional config const fixturesToTest = []; fixturePatternsToTest.forEach(fixturePattern => { - const matchingFixtures = glob.sync(`${fixturesDirPath}/${fixturePattern}`, {}); - matchingFixtures.forEach(filename => fixturesToTest.push(filename)); + const globPattern = (typeof fixturePattern === "string") ? fixturePattern : fixturePattern.pattern; + const matchingFixtures = glob.sync(`${fixturesDirPath}/${globPattern}`, {}); + matchingFixtures.forEach(filename => { + if (typeof fixturePattern === "string") { + fixturesToTest.push(filename); + } else { + fixturesToTest.push({ + filename, + config: fixturePattern.config + }); + } + }); }); /** @@ -64,6 +475,12 @@ function preprocessBabylonAST(ast) { return true; } }, + { + key: "directive", + predicate() { + return true; + } + }, { key: "innerComments", predicate() { @@ -75,33 +492,107 @@ function preprocessBabylonAST(ast) { predicate() { return true; } + }, + { + key: "trailingComments", + predicate() { + return true; + } + }, + { + key: "guardedHandlers", + predicate() { + return true; + } } ]); } -fixturesToTest.forEach(filename => { +/** + * There is currently a really awkward difference in location data for Program nodes + * between different parsers in the ecosystem. Hack around this by removing the data + * before comparing the ASTs. + * + * See: https://github.com/babel/babylon/issues/673 + * + * @param {Object} ast the raw AST with a Program node at its top level + * @returns {Object} the ast with the location data removed from the Program node + */ +function removeLocationDataFromProgramNode(ast) { + delete ast.loc; + delete ast.range; + return ast; +} +fixturesToTest.forEach(fixture => { + + const filename = (typeof fixture === "string") ? fixture : fixture.filename; const source = fs.readFileSync(filename, "utf8").replace(/\r\n/g, "\n"); /** * Parse with typescript-eslint-parser */ - const typeScriptESLintParserAST = parse(source, { - parser: "typescript-eslint-parser" + const typeScriptESLintParserResult = parse(source, { + parser: "typescript-eslint-parser", + typeScriptESLintParserOptions: (fixture.config && fixture.config.typeScriptESLintParserOptions) ? fixture.config.typeScriptESLintParserOptions : null + }); + + /** + * Parse the source with babylon typescript-plugin + */ + const babylonTypeScriptPluginResult = parse(source, { + parser: "babylon-plugin-typescript", + babylonParserOptions: (fixture.config && fixture.config.babylonParserOptions) ? fixture.config.babylonParserOptions : null }); /** - * Parse the source with babylon typescript-plugin, and perform some extra formatting steps + * If babylon fails to parse the source, ensure that typescript-eslint-parser has the same fundamental issue + */ + if (babylonTypeScriptPluginResult.parseError) { + /** + * FAIL: babylon errored but typescript-eslint-parser did not + */ + if (!typeScriptESLintParserResult.parseError) { + test(`TEST FAIL [BABYLON ERRORED, BUT TSEP DID NOT] - ${filename}`, () => { + expect(typeScriptESLintParserResult.parseError).toEqual(babylonTypeScriptPluginResult.parseError); + }); + return; + } + /** + * Both parsers errored - this is OK as long as the errors are of the same "type" + */ + test(`[Both parsers error as expected] - ${filename}`, () => { + expect(babylonTypeScriptPluginResult.parseError.name).toEqual(typeScriptESLintParserResult.parseError.name); + }); + return; + } + + /** + * FAIL: typescript-eslint-parser errored but babylon did not */ - const babylonTypeScriptPluginAST = preprocessBabylonAST(parse(source, { - parser: "babylon-plugin-typescript" - })); + if (typeScriptESLintParserResult.parseError) { + test(`TEST FAIL [TSEP ERRORED, BUT BABYLON DID NOT] - ${filename}`, () => { + expect(babylonTypeScriptPluginResult.parseError).toEqual(typeScriptESLintParserResult.parseError); + }); + return; + } /** - * Assert the two ASTs match + * No errors, assert the two ASTs match */ test(`${filename}`, () => { - expect(babylonTypeScriptPluginAST).toEqual(typeScriptESLintParserAST); + expect(babylonTypeScriptPluginResult.ast).toBeTruthy(); + expect(typeScriptESLintParserResult.ast).toBeTruthy(); + /** + * Perform some extra formatting steps on the babylon AST before comparing + */ + expect( + removeLocationDataFromProgramNode( + preprocessBabylonAST(babylonTypeScriptPluginResult.ast) + ) + ).toEqual( + removeLocationDataFromProgramNode(typeScriptESLintParserResult.ast) + ); }); }); diff --git a/tests/ast-alignment/utils.js b/tests/ast-alignment/utils.js index e9a52a2..bf8460a 100644 --- a/tests/ast-alignment/utils.js +++ b/tests/ast-alignment/utils.js @@ -34,6 +34,7 @@ function omitDeep(obj, keysToOmit) { } return false; } + for (const key in obj) { if (!obj.hasOwnProperty(key)) { continue; @@ -42,19 +43,26 @@ function omitDeep(obj, keysToOmit) { if (isPlainObject(val)) { if (shouldOmit(key, val)) { delete obj[key]; - break; + // re-run with the same arguments + // in case the object has multiple keys to omit + return omitDeep(obj, keysToOmit); } omitDeep(val, keysToOmit); } else if (Array.isArray(val)) { if (shouldOmit(key, val)) { delete obj[key]; - break; + // re-run with the same arguments + // in case the object has multiple keys to omit + return omitDeep(obj, keysToOmit); } for (const i of val) { omitDeep(i, keysToOmit); } } else if (shouldOmit(key, val)) { delete obj[key]; + // re-run with the same arguments + // in case the object has multiple keys to omit + return omitDeep(obj, keysToOmit); } } return obj; diff --git a/tests/fixtures/ecma-features/arrowFunctions/basic-in-binary-expression.src.js b/tests/fixtures/ecma-features/arrowFunctions/basic-in-binary-expression.src.js index f27ea48..5549093 100644 --- a/tests/fixtures/ecma-features/arrowFunctions/basic-in-binary-expression.src.js +++ b/tests/fixtures/ecma-features/arrowFunctions/basic-in-binary-expression.src.js @@ -1,5 +1,2 @@ (a => ({})) + 1; -(a => ({})) = 1; ((a => ({})) + 1); -((a => ({})) = 1); - diff --git a/tests/fixtures/ecma-features/destructuring/named-param.src.js b/tests/fixtures/ecma-features/destructuring/named-param.src.js index b45ac68..5f3ddae 100644 --- a/tests/fixtures/ecma-features/destructuring/named-param.src.js +++ b/tests/fixtures/ecma-features/destructuring/named-param.src.js @@ -1 +1 @@ -({ responseText: text }) = res; \ No newline at end of file +({ responseText: text } = res); \ No newline at end of file diff --git a/tests/jsx-known-issues.js b/tests/jsx-known-issues.js new file mode 100644 index 0000000..92cb4d6 --- /dev/null +++ b/tests/jsx-known-issues.js @@ -0,0 +1,11 @@ +"use strict"; + +/** + * Export the list to allow it to be used within both unit and AST comparison tests + */ +module.exports = [ + "jsx/embedded-tags", // https://github.com/Microsoft/TypeScript/issues/7410 + "jsx/namespaced-attribute-and-value-inserted", // https://github.com/Microsoft/TypeScript/issues/7411 + "jsx/namespaced-name-and-attribute", // https://github.com/Microsoft/TypeScript/issues/7411 + "jsx/invalid-namespace-value-with-dots" // https://github.com/Microsoft/TypeScript/issues/7411 +]; diff --git a/tests/lib/__snapshots__/ecma-features.js.snap b/tests/lib/__snapshots__/ecma-features.js.snap index 4129aae..4ebfe05 100644 --- a/tests/lib/__snapshots__/ecma-features.js.snap +++ b/tests/lib/__snapshots__/ecma-features.js.snap @@ -2131,18 +2131,18 @@ Object { "body": Object { "loc": Object { "end": Object { - "column": 9, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 8, "line": 2, }, }, "properties": Array [], "range": Array [ - 24, - 26, + 25, + 27, ], "type": "ObjectExpression", }, @@ -2151,11 +2151,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 10, + "column": 11, "line": 2, }, "start": Object { - "column": 1, + "column": 2, "line": 2, }, }, @@ -2163,67 +2163,67 @@ Object { Object { "loc": Object { "end": Object { - "column": 2, + "column": 3, "line": 2, }, "start": Object { - "column": 1, + "column": 2, "line": 2, }, }, "name": "a", "range": Array [ - 18, 19, + 20, ], "type": "Identifier", }, ], "range": Array [ - 18, - 27, + 19, + 28, ], "type": "ArrowFunctionExpression", }, "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 2, }, "start": Object { - "column": 0, + "column": 1, "line": 2, }, }, - "operator": "=", + "operator": "+", "range": Array [ - 17, - 32, + 18, + 33, ], "right": Object { "loc": Object { "end": Object { - "column": 15, + "column": 16, "line": 2, }, "start": Object { - "column": 14, + "column": 15, "line": 2, }, }, "range": Array [ - 31, 32, + 33, ], "raw": "1", "type": "Literal", "value": 1, }, - "type": "AssignmentExpression", + "type": "BinaryExpression", }, "loc": Object { "end": Object { - "column": 16, + "column": 18, "line": 2, }, "start": Object { @@ -2233,233 +2233,7 @@ Object { }, "range": Array [ 17, - 33, - ], - "type": "ExpressionStatement", - }, - Object { - "expression": Object { - "left": Object { - "async": false, - "body": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "properties": Array [], - "range": Array [ - 42, - 44, - ], - "type": "ObjectExpression", - }, - "expression": true, - "generator": false, - "id": null, - "loc": Object { - "end": Object { - "column": 11, - "line": 3, - }, - "start": Object { - "column": 2, - "line": 3, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 3, - "line": 3, - }, - "start": Object { - "column": 2, - "line": 3, - }, - }, - "name": "a", - "range": Array [ - 36, - 37, - ], - "type": "Identifier", - }, - ], - "range": Array [ - 36, - 45, - ], - "type": "ArrowFunctionExpression", - }, - "loc": Object { - "end": Object { - "column": 16, - "line": 3, - }, - "start": Object { - "column": 1, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 35, - 50, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 49, - 50, - ], - "raw": "1", - "type": "Literal", - "value": 1, - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 0, - "line": 3, - }, - }, - "range": Array [ - 34, - 52, - ], - "type": "ExpressionStatement", - }, - Object { - "expression": Object { - "left": Object { - "async": false, - "body": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 8, - "line": 4, - }, - }, - "properties": Array [], - "range": Array [ - 61, - 63, - ], - "type": "ObjectExpression", - }, - "expression": true, - "generator": false, - "id": null, - "loc": Object { - "end": Object { - "column": 11, - "line": 4, - }, - "start": Object { - "column": 2, - "line": 4, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 3, - "line": 4, - }, - "start": Object { - "column": 2, - "line": 4, - }, - }, - "name": "a", - "range": Array [ - 55, - 56, - ], - "type": "Identifier", - }, - ], - "range": Array [ - 55, - 64, - ], - "type": "ArrowFunctionExpression", - }, - "loc": Object { - "end": Object { - "column": 16, - "line": 4, - }, - "start": Object { - "column": 1, - "line": 4, - }, - }, - "operator": "=", - "range": Array [ - 54, - 69, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 4, - }, - "start": Object { - "column": 15, - "line": 4, - }, - }, - "range": Array [ - 68, - 69, - ], - "raw": "1", - "type": "Literal", - "value": 1, - }, - "type": "AssignmentExpression", - }, - "loc": Object { - "end": Object { - "column": 18, - "line": 4, - }, - "start": Object { - "column": 0, - "line": 4, - }, - }, - "range": Array [ - 53, - 71, + 35, ], "type": "ExpressionStatement", }, @@ -2467,7 +2241,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 3, }, "start": Object { "column": 0, @@ -2476,7 +2250,7 @@ Object { }, "range": Array [ 0, - 73, + 36, ], "sourceType": "script", "tokens": Array [ @@ -2711,44 +2485,44 @@ Object { 18, 19, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 5, + "column": 3, "line": 2, }, "start": Object { - "column": 3, + "column": 2, "line": 2, }, }, "range": Array [ + 19, 20, - 22, ], - "type": "Punctuator", - "value": "=>", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 7, + "column": 6, "line": 2, }, "start": Object { - "column": 6, + "column": 4, "line": 2, }, }, "range": Array [ + 21, 23, - 24, ], "type": "Punctuator", - "value": "(", + "value": "=>", }, Object { "loc": Object { @@ -2766,7 +2540,7 @@ Object { 25, ], "type": "Punctuator", - "value": "{", + "value": "(", }, Object { "loc": Object { @@ -2784,7 +2558,7 @@ Object { 26, ], "type": "Punctuator", - "value": "}", + "value": "{", }, Object { "loc": Object { @@ -2802,7 +2576,7 @@ Object { 27, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { @@ -2825,38 +2599,38 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 12, "line": 2, }, "start": Object { - "column": 12, + "column": 11, "line": 2, }, }, "range": Array [ + 28, 29, - 30, ], "type": "Punctuator", - "value": "=", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 14, "line": 2, }, "start": Object { - "column": 14, + "column": 13, "line": 2, }, }, "range": Array [ + 30, 31, - 32, ], - "type": "Numeric", - "value": "1", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { @@ -2873,438 +2647,6 @@ Object { 32, 33, ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { - "column": 1, - "line": 3, - }, - "start": Object { - "column": 0, - "line": 3, - }, - }, - "range": Array [ - 34, - 35, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 2, - "line": 3, - }, - "start": Object { - "column": 1, - "line": 3, - }, - }, - "range": Array [ - 35, - 36, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 3, - "line": 3, - }, - "start": Object { - "column": 2, - "line": 3, - }, - }, - "range": Array [ - 36, - 37, - ], - "type": "Identifier", - "value": "a", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 3, - }, - }, - "range": Array [ - 38, - 40, - ], - "type": "Punctuator", - "value": "=>", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 3, - }, - "start": Object { - "column": 7, - "line": 3, - }, - }, - "range": Array [ - 41, - 42, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 42, - 43, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 3, - }, - "start": Object { - "column": 9, - "line": 3, - }, - }, - "range": Array [ - 43, - 44, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 3, - }, - "start": Object { - "column": 10, - "line": 3, - }, - }, - "range": Array [ - 44, - 45, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 3, - }, - "start": Object { - "column": 11, - "line": 3, - }, - }, - "range": Array [ - 45, - 46, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 3, - }, - "start": Object { - "column": 13, - "line": 3, - }, - }, - "range": Array [ - 47, - 48, - ], - "type": "Punctuator", - "value": "+", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 49, - 50, - ], - "type": "Numeric", - "value": "1", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 3, - }, - "start": Object { - "column": 16, - "line": 3, - }, - }, - "range": Array [ - 50, - 51, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 17, - "line": 3, - }, - }, - "range": Array [ - 51, - 52, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { - "column": 1, - "line": 4, - }, - "start": Object { - "column": 0, - "line": 4, - }, - }, - "range": Array [ - 53, - 54, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 2, - "line": 4, - }, - "start": Object { - "column": 1, - "line": 4, - }, - }, - "range": Array [ - 54, - 55, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 3, - "line": 4, - }, - "start": Object { - "column": 2, - "line": 4, - }, - }, - "range": Array [ - 55, - 56, - ], - "type": "Identifier", - "value": "a", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 4, - }, - "start": Object { - "column": 4, - "line": 4, - }, - }, - "range": Array [ - 57, - 59, - ], - "type": "Punctuator", - "value": "=>", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 4, - }, - "start": Object { - "column": 7, - "line": 4, - }, - }, - "range": Array [ - 60, - 61, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 4, - }, - "start": Object { - "column": 8, - "line": 4, - }, - }, - "range": Array [ - 61, - 62, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 4, - }, - "start": Object { - "column": 9, - "line": 4, - }, - }, - "range": Array [ - 62, - 63, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 4, - }, - "start": Object { - "column": 10, - "line": 4, - }, - }, - "range": Array [ - 63, - 64, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 4, - }, - "start": Object { - "column": 11, - "line": 4, - }, - }, - "range": Array [ - 64, - 65, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 4, - }, - "start": Object { - "column": 13, - "line": 4, - }, - }, - "range": Array [ - 66, - 67, - ], - "type": "Punctuator", - "value": "=", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 4, - }, - "start": Object { - "column": 15, - "line": 4, - }, - }, - "range": Array [ - 68, - 69, - ], "type": "Numeric", "value": "1", }, @@ -3312,16 +2654,16 @@ Object { "loc": Object { "end": Object { "column": 17, - "line": 4, + "line": 2, }, "start": Object { "column": 16, - "line": 4, + "line": 2, }, }, "range": Array [ - 69, - 70, + 33, + 34, ], "type": "Punctuator", "value": ")", @@ -3330,16 +2672,16 @@ Object { "loc": Object { "end": Object { "column": 18, - "line": 4, + "line": 2, }, "start": Object { "column": 17, - "line": 4, + "line": 2, }, }, "range": Array [ - 70, - 71, + 34, + 35, ], "type": "Punctuator", "value": ";", @@ -38660,34 +38002,34 @@ Object { }, "loc": Object { "end": Object { - "column": 30, + "column": 29, "line": 1, }, "start": Object { - "column": 0, + "column": 1, "line": 1, }, }, "operator": "=", "range": Array [ - 0, - 30, + 1, + 29, ], "right": Object { "loc": Object { "end": Object { - "column": 30, + "column": 29, "line": 1, }, "start": Object { - "column": 27, + "column": 26, "line": 1, }, }, "name": "res", "range": Array [ - 27, - 30, + 26, + 29, ], "type": "Identifier", }, @@ -38837,38 +38179,38 @@ Object { Object { "loc": Object { "end": Object { - "column": 24, + "column": 25, "line": 1, }, "start": Object { - "column": 23, + "column": 24, "line": 1, }, }, "range": Array [ - 23, 24, + 25, ], "type": "Punctuator", - "value": ")", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 29, "line": 1, }, "start": Object { - "column": 25, + "column": 26, "line": 1, }, }, "range": Array [ - 25, 26, + 29, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "res", }, Object { "loc": Object { @@ -38877,16 +38219,16 @@ Object { "line": 1, }, "start": Object { - "column": 27, + "column": 29, "line": 1, }, }, "range": Array [ - 27, + 29, 30, ], - "type": "Identifier", - "value": "res", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { diff --git a/tests/lib/jsx.js b/tests/lib/jsx.js index 60e0bdb..edc705d 100644 --- a/tests/lib/jsx.js +++ b/tests/lib/jsx.js @@ -13,7 +13,8 @@ const path = require("path"), shelljs = require("shelljs"), - testUtils = require("../../tools/test-utils"); + testUtils = require("../../tools/test-utils"), + filesWithKnownIssues = require("../jsx-known-issues"); //------------------------------------------------------------------------------ // Setup @@ -21,16 +22,9 @@ const path = require("path"), const JSX_FIXTURES_DIR = "./tests/fixtures/jsx"; -const filesWithOutsandingTSIssues = [ - "jsx/embedded-tags", // https://github.com/Microsoft/TypeScript/issues/7410 - "jsx/namespaced-attribute-and-value-inserted", // https://github.com/Microsoft/TypeScript/issues/7411 - "jsx/namespaced-name-and-attribute", // https://github.com/Microsoft/TypeScript/issues/7411 - "jsx/invalid-namespace-value-with-dots" // https://github.com/Microsoft/TypeScript/issues/7411 -]; - const jsxTestFiles = shelljs.find(JSX_FIXTURES_DIR) .filter(filename => filename.indexOf(".src.js") > -1) - .filter(filename => filesWithOutsandingTSIssues.every(fileName => filename.indexOf(fileName) === -1)) + .filter(filename => filesWithKnownIssues.every(fileName => filename.indexOf(fileName) === -1)) // strip off ".src.js" .map(filename => filename.substring(JSX_FIXTURES_DIR.length - 1, filename.length - 7));