diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 116e43fdd53d..a3534dd85c31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,12 @@ jobs: # Website will be built by the Netlify GitHub App yarn build --exclude website + - name: Run unit tests for ast-spec + run: yarn test + working-directory: packages/ast-spec + env: + CI: true + - name: Run unit tests for typescript-estree run: npx nx test @typescript-eslint/typescript-estree env: @@ -308,6 +314,7 @@ jobs: env: CI: true + # ast-spec is internal only - so don't care about compat on other versions # eslint-plugin-internal is internal only - so don't care about compat on other versions website_tests: diff --git a/.prettierignore b/.prettierignore index 93e27c9f84d6..896d5c464a35 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,6 +12,7 @@ packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.j packages/eslint-plugin/src/configs/*.json .all-contributorsrc CONTRIBUTORS.md +packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/.vscode/launch.json b/.vscode/launch.json index d61dbf50a74a..aee0ff73ab0d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -242,5 +242,37 @@ "${workspaceFolder}/packages/scope-manager/dist/index.js", ], }, + { + "type": "node", + "request": "launch", + "name": "Run currently opened ast-spec test", + "cwd": "${workspaceFolder}/packages/ast-spec/", + "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", + "args": [ + "--runInBand", + "--no-cache", + "--no-coverage", + "${fileBasename}" + ], + "sourceMaps": true, + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "skipFiles": [ + "${workspaceFolder}/packages/experimental-utils/src/index.ts", + "${workspaceFolder}/packages/experimental-utils/dist/index.js", + "${workspaceFolder}/packages/experimental-utils/src/ts-estree.ts", + "${workspaceFolder}/packages/experimental-utils/dist/ts-estree.js", + "${workspaceFolder}/packages/parser/src/index.ts", + "${workspaceFolder}/packages/parser/dist/index.js", + "${workspaceFolder}/packages/typescript-estree/src/index.ts", + "${workspaceFolder}/packages/typescript-estree/dist/index.js", + "${workspaceFolder}/packages/types/src/index.ts", + "${workspaceFolder}/packages/types/dist/index.js", + "${workspaceFolder}/packages/visitor-keys/src/index.ts", + "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + ], + }, ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index f0677068d037..896fbaebbb3a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,7 @@ - { + // This matches the value configured on the autoformatter + "editor.rulers": [80], + // An array of language ids which should be validated by ESLint "eslint.validate": [ "javascript", @@ -27,10 +29,7 @@ { "icon": "jest_snapshot", "extensions": [ - ".ts.shot", - ".tsx.shot", - ".js.shot", - ".jsx.shot", + ".shot", ], "extends": "jest_snapshot" }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bd62a8812d6..48640ccb73a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Bug Fixes + +* add rule to vscode settings ([#4881](https://github.com/typescript-eslint/typescript-eslint/issues/4881)) ([3eab889](https://github.com/typescript-eslint/typescript-eslint/commit/3eab889022c9d1617f275017d6951f663ea57f24)) +* **eslint-plugin:** [comma-spacing] verify `nextToken` exists ([#4868](https://github.com/typescript-eslint/typescript-eslint/issues/4868)) ([23746f8](https://github.com/typescript-eslint/typescript-eslint/commit/23746f8babace7c2354368d6fb0881be26e19c41)) + + +### Features + +* **ast-spec:** add fixture test framework and some initial fixtures ([#3258](https://github.com/typescript-eslint/typescript-eslint/issues/3258)) ([f3cf87b](https://github.com/typescript-eslint/typescript-eslint/commit/f3cf87bf20fd0542f92a96a318aa9ee5bf23c1f6)) +* **eslint-plugin:** [no-duplicate-enum-values] add rule ([#4833](https://github.com/typescript-eslint/typescript-eslint/issues/4833)) ([5899164](https://github.com/typescript-eslint/typescript-eslint/commit/5899164b35d91106512a2720b23ba92e1893132f)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) diff --git a/lerna.json b/lerna.json index 8f192d86a86b..e09a210b2a31 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.21.0", + "version": "5.22.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/package.json b/package.json index d889f08dffa3..a57385f883d8 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,10 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "devDependencies": { + "@babel/code-frame": "^7.14.5", + "@babel/eslint-parser": "^7.15.4", + "@babel/parser": "^7.15.7", + "@babel/types": "^7.15.6", "@commitlint/cli": "^16.0.1", "@commitlint/config-conventional": "^16.0.0", "@nrwl/cli": "13.8.5", @@ -63,6 +67,7 @@ "@nrwl/workspace": "13.8.5", "@swc/core": "^1.2.159", "@swc/jest": "^0.2.20", + "@types/babel__code-frame": "^7.0.3", "@types/debug": "^4.1.7", "@types/eslint-visitor-keys": "^1.0.0", "@types/glob": "^7.2.0", @@ -93,6 +98,8 @@ "glob": "^8.0.1", "husky": "^7.0.4", "jest": "^27.3.1", + "jest-diff": "^27.3.1", + "jest-snapshot": "^27.3.1", "jest-specific-snapshot": "^5.0.0", "lerna": "^4.0.0", "lint-staged": "^12.0.2", diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index e5ae56bd58c4..3d17b3150c95 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Features + +* **ast-spec:** add fixture test framework and some initial fixtures ([#3258](https://github.com/typescript-eslint/typescript-eslint/issues/3258)) ([f3cf87b](https://github.com/typescript-eslint/typescript-eslint/commit/f3cf87bf20fd0542f92a96a318aa9ee5bf23c1f6)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/ast-spec diff --git a/packages/ast-spec/jest.config.js b/packages/ast-spec/jest.config.js index 77fe4d022a95..ac3b63608b7a 100644 --- a/packages/ast-spec/jest.config.js +++ b/packages/ast-spec/jest.config.js @@ -5,4 +5,9 @@ module.exports = { ...require('../../jest.config.base.js'), testRegex: ['./tests/.+\\.test\\.ts$'], + collectCoverage: false, + collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + coverageReporters: ['text-summary', 'lcov'], + setupFilesAfterEnv: ['./tests/util/setupJest.ts'], }; diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index 264482b97e32..1d1de4ced2a1 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.21.0", + "version": "5.22.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ @@ -32,8 +32,10 @@ "build": "tsc -b tsconfig.build.json && api-extractor run --local", "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf .rollup.cache && rimraf coverage", + "clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", + "test": "jest", "typecheck": "tsc -p tsconfig.json --noEmit" }, "funding": { @@ -41,7 +43,17 @@ "url": "https://opencollective.com/typescript-eslint" }, "devDependencies": { + "@babel/core": "*", + "@babel/eslint-parser": "*", + "@babel/parser": "*", "@microsoft/api-extractor": "^7.18.16", + "@types/babel__core": "*", + "glob": "*", + "jest-diff": "*", + "jest-snapshot": "*", + "jest-specific-snapshot": "*", + "make-dir": "*", + "pretty-format": "*", "typescript": "*" } } diff --git a/packages/ast-spec/src/base/TSHeritageBase.ts b/packages/ast-spec/src/base/TSHeritageBase.ts index b3ed1770b674..5c20542e4f92 100644 --- a/packages/ast-spec/src/base/TSHeritageBase.ts +++ b/packages/ast-spec/src/base/TSHeritageBase.ts @@ -3,6 +3,7 @@ import type { Expression } from '../unions/Expression'; import type { BaseNode } from './BaseNode'; export interface TSHeritageBase extends BaseNode { + // TODO(error handling) - this should be restricted to MemberExpression | Identifier expression: Expression; typeParameters?: TSTypeParameterInstantiation; } diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/fixture.ts new file mode 100644 index 000000000000..d9bb750ada25 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/fixture.ts @@ -0,0 +1 @@ +class Foo implements 'thing' {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..d4b25d3584bf --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ implements-non-identifier TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..32918ff7c5f7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ implements-non-identifier Babel - Error 1`] = `[SyntaxError: Unexpected token (1:21)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..123225a18253 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ implements-non-identifier Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/fixture.ts new file mode 100644 index 000000000000..12cf01a79ca3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/fixture.ts @@ -0,0 +1 @@ +class Foo; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..305258435809 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..e72c371e8425 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ no-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:9)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..b69460232224 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ no-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 000000000000..140ca7e5d569 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +class 'Foo' {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..7b137a8c5dec --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..e3a40451c7e4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: A class name is required. (1:6)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..098ed5e7a14f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/fixture.ts new file mode 100644 index 000000000000..57d09b35b4cb --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/fixture.ts @@ -0,0 +1 @@ +abstract class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..bae3f5a82873 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [19, 21], + loc: { + start: { column: 19, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + superClass: null, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..0cda23120060 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "abstract", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [9, 14], + loc: { + start: { column: 9, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..d8e3d045b848 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/3-Babel-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + abstract: true, + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [19, 21], + loc: { + start: { column: 19, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + superClass: null, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..ac5930044d1e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "abstract", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [9, 14], + loc: { + start: { column: 9, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..54a7219ce9a8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..248c67fcb6ae --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/abstract/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration abstract AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/fixture.ts new file mode 100644 index 000000000000..a12e8045e83d --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/fixture.ts @@ -0,0 +1 @@ +declare class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..d20ffd3e1308 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + superClass: null, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..4006c278dcb7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [8, 13], + loc: { + start: { column: 8, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..27ac3a41954c --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + superClass: null, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..0fbe7f7fe385 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [8, 13], + loc: { + start: { column: 8, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..9fbaa86d5a24 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..1bb1eef41abe --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/fixture.ts new file mode 100644 index 000000000000..259743a73f75 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/fixture.ts @@ -0,0 +1,3 @@ +@decoratorOne +@decoratorTwo +class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ab7726fcd526 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [38, 40], + loc: { + start: { column: 10, line: 3 }, + end: { column: 12, line: 3 }, + }, + }, + decorators: Array [ + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decoratorOne", + + range: [1, 13], + loc: { + start: { column: 1, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decoratorTwo", + + range: [15, 27], + loc: { + start: { column: 1, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + + range: [14, 27], + loc: { + start: { column: 0, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [34, 37], + loc: { + start: { column: 6, line: 3 }, + end: { column: 9, line: 3 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..f406c8123352 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "@", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "decoratorOne", + + range: [1, 13], + loc: { + start: { column: 1, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "@", + + range: [14, 15], + loc: { + start: { column: 0, line: 2 }, + end: { column: 1, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "decoratorTwo", + + range: [15, 27], + loc: { + start: { column: 1, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [28, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 5, line: 3 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [34, 37], + loc: { + start: { column: 6, line: 3 }, + end: { column: 9, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [38, 39], + loc: { + start: { column: 10, line: 3 }, + end: { column: 11, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 11, line: 3 }, + end: { column: 12, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..60af58e326d3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [38, 40], + loc: { + start: { column: 10, line: 3 }, + end: { column: 12, line: 3 }, + }, + }, + decorators: Array [ + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decoratorOne", + + range: [1, 13], + loc: { + start: { column: 1, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decoratorTwo", + + range: [15, 27], + loc: { + start: { column: 1, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + + range: [14, 27], + loc: { + start: { column: 0, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [34, 37], + loc: { + start: { column: 6, line: 3 }, + end: { column: 9, line: 3 }, + }, + }, + superClass: null, + + range: [0, 40], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 41], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..888d2f213d3f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "@", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "decoratorOne", + + range: [1, 13], + loc: { + start: { column: 1, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "@", + + range: [14, 15], + loc: { + start: { column: 0, line: 2 }, + end: { column: 1, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "decoratorTwo", + + range: [15, 27], + loc: { + start: { column: 1, line: 2 }, + end: { column: 13, line: 2 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [28, 33], + loc: { + start: { column: 0, line: 3 }, + end: { column: 5, line: 3 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [34, 37], + loc: { + start: { column: 6, line: 3 }, + end: { column: 9, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [38, 39], + loc: { + start: { column: 10, line: 3 }, + end: { column: 11, line: 3 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [39, 40], + loc: { + start: { column: 11, line: 3 }, + end: { column: 12, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..97881c1404c3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..e57e9fa7313b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorMany AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/fixture.ts new file mode 100644 index 000000000000..3db0178e0a4f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/fixture.ts @@ -0,0 +1,2 @@ +@decorator +class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..f0550dcabbe8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 10, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + decorators: Array [ + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decorator", + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 6, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + superClass: null, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 2 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 3 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..7354a4e9bfed --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "@", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "decorator", + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [11, 16], + loc: { + start: { column: 0, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 6, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 10, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..f2e4581ba588 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 10, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + decorators: Array [ + Decorator { + type: "Decorator", + expression: Identifier { + type: "Identifier", + name: "decorator", + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 6, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + superClass: null, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 2 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 3 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..eb1816cba73b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "@", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "decorator", + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [11, 16], + loc: { + start: { column: 0, line: 2 }, + end: { column: 5, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 6, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 10, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..19b8f62ee26d --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..915fd1d51f92 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decoratorOne AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/fixture.ts new file mode 100644 index 000000000000..4e6a6de65314 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/fixture.ts @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..9ead7d30ab75 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [10, 12], + loc: { + start: { column: 10, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..98e26f81f22b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..b44e7f980bf9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [10, 12], + loc: { + start: { column: 10, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..7687be9ddb06 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..795e34e032cc --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..bf9e1cf5e602 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration empty AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/README.md b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/README.md new file mode 100644 index 000000000000..2e811c1316fb --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/README.md @@ -0,0 +1 @@ +This is dumb code - but it's 100% syntactically valid and adheres to the ESTree spec. diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/fixture.ts new file mode 100644 index 000000000000..7bb36dc00673 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/fixture.ts @@ -0,0 +1 @@ +class Foo extends 'Thing' {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..dc5437192e6f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [26, 28], + loc: { + start: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Literal { + type: "Literal", + raw: "'Thing'", + value: "Thing", + + range: [18, 25], + loc: { + start: { column: 18, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..578f3c6a8648 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + String { + type: "String", + value: "'Thing'", + + range: [18, 25], + loc: { + start: { column: 18, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..0a84daeb896c --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/3-Babel-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [26, 28], + loc: { + start: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Literal { + type: "Literal", + raw: "'Thing'", + value: "Thing", + + range: [18, 25], + loc: { + start: { column: 18, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..ec6443288fb5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + String { + type: "String", + value: "'Thing'", + + range: [18, 25], + loc: { + start: { column: 18, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..432a1483eb47 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..5c213302190f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-literal/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-literal AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/fixture.ts new file mode 100644 index 000000000000..5d0bc8ed7c76 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/fixture.ts @@ -0,0 +1 @@ +class Foo extends Set {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..da9fc3ba5ca5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [30, 32], + loc: { + start: { column: 30, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Set", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + superTypeParameters: TSTypeParameterInstantiation { + type: "TSTypeParameterInstantiation", + params: Array [ + TSStringKeyword { + type: "TSStringKeyword", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..3eb2b515a24e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Set", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..8f9634b6629e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [30, 32], + loc: { + start: { column: 30, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Set", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + superTypeParameters: TSTypeParameterInstantiation { + type: "TSTypeParameterInstantiation", + params: Array [ + TSStringKeyword { + type: "TSStringKeyword", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..db93259e13a5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Set", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..17f60ddc36a5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..8c6277e35df2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/fixture.ts new file mode 100644 index 000000000000..1f5fd8cad4ef --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/fixture.ts @@ -0,0 +1 @@ +class Foo extends Object {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..d8241f2f4d5a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [25, 27], + loc: { + start: { column: 25, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Object", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..1a912d351164 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..337d09683e9e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/3-Babel-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [25, 27], + loc: { + start: { column: 25, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Object", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..2f17f69fe6b8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [10, 17], + loc: { + start: { column: 10, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..7408520a611e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..ff9ee33e186d --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration extends AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/fixture.ts new file mode 100644 index 000000000000..c0cae9a11154 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/fixture.ts @@ -0,0 +1 @@ +class Foo implements Object, Function, RegExp {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..6467e4a37f03 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [46, 48], + loc: { + start: { column: 46, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ + TSClassImplements { + type: "TSClassImplements", + expression: Identifier { + type: "Identifier", + name: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + TSClassImplements { + type: "TSClassImplements", + expression: Identifier { + type: "Identifier", + name: "Function", + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + TSClassImplements { + type: "TSClassImplements", + expression: Identifier { + type: "Identifier", + name: "RegExp", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..ffe359159d45 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "implements", + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Function", + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "RegExp", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..c5a75e6d5b1b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [46, 48], + loc: { + start: { column: 46, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "Function", + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "RegExp", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..ca4cb279c004 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "implements", + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Function", + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "RegExp", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..77b0476655c6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,115 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [], + + range: [46, 48], + loc: { + start: { column: 46, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ +- TSClassImplements { +- type: 'TSClassImplements', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'Object', + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +- TSClassImplements { +- type: 'TSClassImplements', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'Function', + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, +- TSClassImplements { +- type: 'TSClassImplements', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'RegExp', + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..931998b9e187 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'implements', + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Object', + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Function', + + range: [29, 37], + loc: { + start: { column: 29, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'RegExp', + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/fixture.ts new file mode 100644 index 000000000000..2e21f7b78336 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/fixture.ts @@ -0,0 +1 @@ +class Foo implements Object {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..c5228690b09a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ + TSClassImplements { + type: "TSClassImplements", + expression: Identifier { + type: "Identifier", + name: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..160a01b3a57a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "implements", + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..de05a724a09f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..07fe25e0f650 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "implements", + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Object", + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..b0aec089f615 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + implements: Array [ +- TSClassImplements { +- type: 'TSClassImplements', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'Object', + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + superClass: null, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..0d56c0d096e8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/implements-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration implements-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'class', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'implements', + + range: [10, 20], + loc: { + start: { column: 10, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Object', + + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts new file mode 100644 index 000000000000..9a3d334adee5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts @@ -0,0 +1 @@ +class Foo extends Set {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..7fa282280172 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,115 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Set", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + superTypeParameters: TSTypeParameterInstantiation { + type: "TSTypeParameterInstantiation", + params: Array [ + TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "T", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: Identifier { + type: "Identifier", + name: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..f73a167dba3e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [13, 20], + loc: { + start: { column: 13, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Set", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..7c5a5149bbed --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: "Identifier", + name: "Set", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + superTypeParameters: TSTypeParameterInstantiation { + type: "TSTypeParameterInstantiation", + params: Array [ + TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "T", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..17ca652dc4a9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [13, 20], + loc: { + start: { column: 13, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Set", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..70cae74b3003 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,120 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: Identifier { + type: 'Identifier', + name: 'Set', + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + superTypeParameters: TSTypeParameterInstantiation { + type: 'TSTypeParameterInstantiation', + params: Array [ + TSTypeReference { + type: 'TSTypeReference', + typeName: Identifier { + type: 'Identifier', + name: 'T', + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [10, 11], +- loc: { +- start: { column: 10, line: 1 }, +- end: { column: 11, line: 1 }, +- }, +- }, ++ name: 'T', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..4e5329e739f9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts new file mode 100644 index 000000000000..9f84d173bfa3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts @@ -0,0 +1 @@ +class Foo {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..0b476f5584ed --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [13, 15], + loc: { + start: { column: 13, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: Identifier { + type: "Identifier", + name: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..7afa2b8839ba --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..de9ab22cc6b9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [13, 15], + loc: { + start: { column: 13, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..89bca663a6db --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..f3b75ecbb25a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [], + + range: [13, 15], + loc: { + start: { column: 13, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [10, 11], +- loc: { +- start: { column: 10, line: 1 }, +- end: { column: 11, line: 1 }, +- }, +- }, ++ name: 'T', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..a99d685df3d6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-parameters AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts new file mode 100644 index 000000000000..8bab23b35992 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts @@ -0,0 +1 @@ +export * as 'foo' from 'module'; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..5f6d97e5f2b1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ named-non-identifier TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..04ccfb73d5bb --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ named-non-identifier Babel - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..3e05e98bfafd --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ named-non-identifier Error Alignment 1`] = `"TSESTree errored but Babel didn't"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/fixture.ts new file mode 100644 index 000000000000..b5299226ad4c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/fixture.ts @@ -0,0 +1 @@ +export * from; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..acdaf4c735f9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source TSESTree - Error 1`] = `[TSError: Expression expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..8bd09ace8dc6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source Babel - Error 1`] = `[SyntaxError: Unexpected token (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..c2ac962baac0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/fixture.ts new file mode 100644 index 000000000000..d78b6918cb1b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/fixture.ts @@ -0,0 +1 @@ +export * from module; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..bcf5b40695c1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ non-string-source TSESTree - Error 1`] = `[TSError: Module specifier must be a string literal.]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..a3d08a7b52a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ non-string-source Babel - Error 1`] = `[SyntaxError: Unexpected token (1:14)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..3a1a419a8312 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ non-string-source Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/fixture.ts new file mode 100644 index 000000000000..35e627e28c5a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/fixture.ts @@ -0,0 +1 @@ +export type * from 'a'; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..a9b2c20c7fa1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ type-kind TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..e448d4b4299f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ type-kind Babel - Error 1`] = `[SyntaxError: Unexpected token (1:12)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..e9c5efb68982 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/type-kind/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ type-kind Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/fixture.ts new file mode 100644 index 000000000000..32858cf72034 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/fixture.ts @@ -0,0 +1 @@ +export * from 'mod' assert { type: 'json' }; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..28172433eacf --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [29, 33], + loc: { + start: { column: 29, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [35, 41], + loc: { + start: { column: 35, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + + range: [29, 41], + loc: { + start: { column: 29, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + ], + exported: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 45], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..c1e14a803e22 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [29, 33], + loc: { + start: { column: 29, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [35, 41], + loc: { + start: { column: 35, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [42, 43], + loc: { + start: { column: 42, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [43, 44], + loc: { + start: { column: 43, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..5a36d4040e4a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [29, 33], + loc: { + start: { column: 29, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [35, 41], + loc: { + start: { column: 35, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + + range: [29, 41], + loc: { + start: { column: 29, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + ], + exported: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 44], + loc: { + start: { column: 0, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 45], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..963999a2a4dc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [29, 33], + loc: { + start: { column: 29, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [35, 41], + loc: { + start: { column: 35, line: 1 }, + end: { column: 41, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [42, 43], + loc: { + start: { column: 42, line: 1 }, + end: { column: 43, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [43, 44], + loc: { + start: { column: 43, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..077fe892d338 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..d5d091ffabd1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration assertion AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/fixture.ts new file mode 100644 index 000000000000..fca392829b84 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/fixture.ts @@ -0,0 +1 @@ +export * as mod from 'module'; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..0650677e2f6c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [], + exported: Identifier { + type: "Identifier", + name: "mod", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'module'", + value: "module", + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..7fc2d67babaf --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "mod", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + String { + type: "String", + value: "'module'", + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..251754367731 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/3-Babel-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [], + exported: Identifier { + type: "Identifier", + name: "mod", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'module'", + value: "module", + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..66f249ee6ca3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "mod", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + String { + type: "String", + value: "'module'", + + range: [21, 29], + loc: { + start: { column: 21, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..8aabbae33575 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..5020f9f630ea --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/named/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration named AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/fixture.ts new file mode 100644 index 000000000000..86a4838f7b9b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/fixture.ts @@ -0,0 +1 @@ +export * from 'my-module'; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..170461aa1dbe --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [], + exported: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'my-module'", + value: "my-module", + + range: [14, 25], + loc: { + start: { column: 14, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..29ffb6ae0fef --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'my-module'", + + range: [14, 25], + loc: { + start: { column: 14, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..67c28f6a2394 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/3-Babel-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [], + exported: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'my-module'", + value: "my-module", + + range: [14, 25], + loc: { + start: { column: 14, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..82327ff3352a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'my-module'", + + range: [14, 25], + loc: { + start: { column: 14, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..351bb72f34fb --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..e2a55391779c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/unnamed/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration unnamed AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/fixture.ts new file mode 100644 index 000000000000..0386d9255b00 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/fixture.ts @@ -0,0 +1 @@ +export default enum Foo {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..c289052b36c9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ enum TSESTree - Error 1`] = `[TSError: Expression expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..294c438cb03c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ enum Babel - Error 1`] = `[SyntaxError: Unexpected reserved word 'enum'. (1:15)]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..32a1cb0d3000 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/enum/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ enum Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/fixture.ts new file mode 100644 index 000000000000..dcefd115a281 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/fixture.ts @@ -0,0 +1 @@ +export default namespace Foo {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..d1633569950d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ namespace TSESTree - Error 1`] = `[TSError: ';' expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..a80c32336147 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ namespace Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:24)]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..7ecaa9bcded4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/namespace/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ namespace Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/fixture.ts new file mode 100644 index 000000000000..81b83c5de986 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/fixture.ts @@ -0,0 +1 @@ +export default type Foo = 1; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..bce2c7cd5eee --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ type-alias TSESTree - Error 1`] = `[TSError: ';' expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..6afc67d4a5b0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ type-alias Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:19)]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..9f4c01a03373 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/type-alias/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ type-alias Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/fixture.ts new file mode 100644 index 000000000000..4b535f12615c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/fixture.ts @@ -0,0 +1 @@ +export default const x = 1; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..43ab9a3893ec --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ variable-declaration TSESTree - Error 1`] = `[TSError: Expression expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..318dee3aacf2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ variable-declaration Babel - Error 1`] = `[SyntaxError: Only expressions, functions or classes are allowed as the \`default\` export. (1:15)]`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..327cd763562b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/_error_/variable-declaration/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration _error_ variable-declaration Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/fixture.ts new file mode 100644 index 000000000000..a6e68e983892 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/fixture.ts @@ -0,0 +1 @@ +export default class {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..bc5b9ffa8c16 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: null, + superClass: null, + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..9773e0f17a93 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..1262745aeade --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/3-Babel-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: null, + superClass: null, + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..74d6f62864bb --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..6c6174587332 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..7ace75359644 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-class/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-class AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/fixture.ts new file mode 100644 index 000000000000..ea9b101e1c22 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/fixture.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..e30c973e4c53 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [27, 29], + loc: { + start: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + expression: false, + generator: false, + id: null, + params: Array [], + + range: [15, 29], + loc: { + start: { column: 15, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..292689734d68 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..d379b69f6c45 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/3-Babel-AST.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [27, 29], + loc: { + start: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + expression: false, + generator: false, + id: null, + params: Array [], + + range: [15, 29], + loc: { + start: { column: 15, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..b52b674b4d56 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..0472fbccb826 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..9b1f36f4e1e4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/anonymous-function/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration anonymous-function AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/fixture.ts new file mode 100644 index 000000000000..2d1ec238274a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/fixture.ts @@ -0,0 +1 @@ +export default () => {}; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..d4ccafd5b51a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: null, + params: Array [], + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..b49305998ffb --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..85a0d39624f9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/3-Babel-AST.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: null, + params: Array [], + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..fc7a2baf0885 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..359c33602be1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..c7f2151c9207 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/arrow-function-expression/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration arrow-function-expression AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/fixture.ts new file mode 100644 index 000000000000..caaf4f896e88 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/fixture.ts @@ -0,0 +1 @@ +export default (class Foo {}); diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..166a1d77c3d6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassExpression { + type: "ClassExpression", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [26, 28], + loc: { + start: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [22, 25], + loc: { + start: { column: 22, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + superClass: null, + + range: [16, 28], + loc: { + start: { column: 16, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..4e62aa0dc6a7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [16, 21], + loc: { + start: { column: 16, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [22, 25], + loc: { + start: { column: 22, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..25ab06d87ef7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/3-Babel-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassExpression { + type: "ClassExpression", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [26, 28], + loc: { + start: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [22, 25], + loc: { + start: { column: 22, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + superClass: null, + + range: [16, 28], + loc: { + start: { column: 16, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..4137a875c9fd --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [16, 21], + loc: { + start: { column: 16, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [22, 25], + loc: { + start: { column: 22, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..4d3dd269c491 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..1328ba27a285 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class-expression/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class-expression AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/fixture.ts new file mode 100644 index 000000000000..7804111002d7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/fixture.ts @@ -0,0 +1 @@ +export default class Foo {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..f2ce271ea778 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [25, 27], + loc: { + start: { column: 25, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + superClass: null, + + range: [15, 27], + loc: { + start: { column: 15, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..5703d446ea54 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..432ded443078 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/3-Babel-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [25, 27], + loc: { + start: { column: 25, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + superClass: null, + + range: [15, 27], + loc: { + start: { column: 15, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..01f9049584e8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [21, 24], + loc: { + start: { column: 21, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..892ae8987da5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..96e9c654eee5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration class AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/fixture.ts new file mode 100644 index 000000000000..386baca17315 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/fixture.ts @@ -0,0 +1 @@ +export default function foo() {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..59570dbd56d7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [30, 32], + loc: { + start: { column: 30, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + params: Array [], + + range: [15, 32], + loc: { + start: { column: 15, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..b3a2cd2b15ba --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..98b11432232d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/3-Babel-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [30, 32], + loc: { + start: { column: 30, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + params: Array [], + + range: [15, 32], + loc: { + start: { column: 15, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..44f7cd272d3d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..6e67c16fb8bd --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..b5de7325dea2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/function/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration function AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/fixture.ts new file mode 100644 index 000000000000..7b56c8b8f391 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/fixture.ts @@ -0,0 +1 @@ +export default x; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..11900ab6838c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: Identifier { + type: "Identifier", + name: "x", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..d52ccbb0406c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..be4bb919b887 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/3-Babel-AST.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: Identifier { + type: "Identifier", + name: "x", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..e4567a57c93e --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..1fc84e1257d5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..fa730c9cc1d9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/identifier/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration identifier AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/fixture.ts new file mode 100644 index 000000000000..4c36019eea28 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/fixture.ts @@ -0,0 +1 @@ +export default interface Foo {} diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..755e1480fde3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [29, 31], + loc: { + start: { column: 29, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [25, 28], + loc: { + start: { column: 25, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [15, 31], + loc: { + start: { column: 15, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..e528391c3b1c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "interface", + + range: [15, 24], + loc: { + start: { column: 15, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [25, 28], + loc: { + start: { column: 25, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..2619c1ffa782 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [29, 31], + loc: { + start: { column: 29, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [25, 28], + loc: { + start: { column: 25, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [15, 31], + loc: { + start: { column: 15, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..9363ba0a28b3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "interface", + + range: [15, 24], + loc: { + start: { column: 15, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [25, 28], + loc: { + start: { column: 25, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..778b30b15138 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..e0918e2af4ec --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration interface AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'export', + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'default', + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [15, 24], + loc: { + start: { column: 15, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [25, 28], + loc: { + start: { column: 25, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/fixture.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/fixture.ts new file mode 100644 index 000000000000..aef22247d752 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/fixture.ts @@ -0,0 +1 @@ +export default 1; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..dae455b793b0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..48eaeb62600c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..f4c959e63f26 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/3-Babel-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportDefaultDeclaration { + type: "ExportDefaultDeclaration", + declaration: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + exportKind: "value", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..209d1dbb63f2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "default", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..7715558acb14 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..c0a93423d4de --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/fixtures/literal/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportDefaultDeclaration literal AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts index 492d0981b8ca..2cfe1cce5b33 100644 --- a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts @@ -6,6 +6,10 @@ import type { ExportKind } from '../ExportAndImportKind'; export interface ExportDefaultDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportDefaultDeclaration; - declaration: ExportDeclaration | Expression; + declaration: + | // TODO(error handling) - the following are disallowed syntactically, but allowed by TS error recovery: + // TSEnumDeclaration, TSModuleDeclaration, TSTypeAliasDeclaration, VariableDeclaration + ExportDeclaration + | Expression; exportKind: ExportKind; } diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/fixture.ts new file mode 100644 index 000000000000..5faf31b8867a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/fixture.ts @@ -0,0 +1 @@ +export { a as 'a' }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..71841045f6c5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ aliased-literal TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..dabc7d927d5d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ aliased-literal Babel - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..efb973998424 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ aliased-literal Error Alignment 1`] = `"TSESTree errored but Babel didn't"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/fixture.ts new file mode 100644 index 000000000000..c433d66cf649 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/fixture.ts @@ -0,0 +1 @@ +export class {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..4bb37139b1b5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-class TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..b3ebe67f29a9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-class Babel - Error 1`] = `[SyntaxError: A class name is required. (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..82e5ade47506 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-class Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/fixture.ts new file mode 100644 index 000000000000..d9a2010f9256 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/fixture.ts @@ -0,0 +1 @@ +export function () {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..9c89f7d7f370 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-function-expression TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..70ef1140faae --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-function-expression Babel - Error 1`] = `[SyntaxError: Unexpected token (1:16)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..15aae2856e1b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-function-expression/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ anonymous-function-expression Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/fixture.ts new file mode 100644 index 000000000000..ec7e7945aaf4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/fixture.ts @@ -0,0 +1 @@ +export () => {}; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..bc1507d797f0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ arrow-function TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..d3a01941b964 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ arrow-function Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..fd6445ddef39 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/arrow-function/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ arrow-function Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/fixture.ts new file mode 100644 index 000000000000..bb46c3698b97 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/fixture.ts @@ -0,0 +1 @@ +export (class Foo {}); diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..af9eba5ac2cc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ class-expression TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..59d790cb18df --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ class-expression Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..dbe6913aab56 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/class-expression/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ class-expression Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/fixture.ts new file mode 100644 index 000000000000..0d3d77ac4130 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/fixture.ts @@ -0,0 +1 @@ +export a; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..302c6c7c652d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ identifier-direct TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..968987af2099 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ identifier-direct Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..00f60c625f57 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/identifier-direct/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ identifier-direct Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/fixture.ts new file mode 100644 index 000000000000..7eec000d816d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/fixture.ts @@ -0,0 +1 @@ +export { 'a' }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..7e7d8c008fc2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-braced TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..3ba27489473b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/2-Babel-Error.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-braced Babel - Error 1`] = ` +[SyntaxError: A string literal cannot be used as an exported binding without \`from\`. +- Did you mean \`export { 'a' as 'a' } from 'some-module'\`? (1:9)] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..f2d4bb40cc50 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-braced/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-braced Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/fixture.ts new file mode 100644 index 000000000000..ed5896524bf1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/fixture.ts @@ -0,0 +1 @@ +export 'a'; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..9e96ac055223 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-direct TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..cf5a26409d14 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-direct Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..7d06f41fc053 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/_error_/literal-direct/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration _error_ literal-direct Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/fixture.ts new file mode 100644 index 000000000000..060ae5187cf3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/fixture.ts @@ -0,0 +1 @@ +export { a as b }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..c5593e6762b6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "b", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..24df13756b8d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [11, 13], + loc: { + start: { column: 11, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..8978d2ea713e --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/3-Babel-AST.shot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "b", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..bce9dd071b10 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [11, 13], + loc: { + start: { column: 11, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..845f2cb5cfbc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: null, + exportKind: 'value', + source: null, + specifiers: Array [ + ExportSpecifier { + type: 'ExportSpecifier', + exported: Identifier { + type: 'Identifier', + name: 'b', + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + exportKind: 'value', + local: Identifier { + type: 'Identifier', + name: 'a', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..ce523723d51e --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/aliased/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration aliased AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/fixture.ts new file mode 100644 index 000000000000..f139479dad01 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/fixture.ts @@ -0,0 +1 @@ +export { foo } from 'mod' assert { type: 'json' }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..9136ca295cb1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [35, 39], + loc: { + start: { column: 35, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [41, 47], + loc: { + start: { column: 41, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [35, 47], + loc: { + start: { column: 35, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + ], + declaration: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [20, 25], + loc: { + start: { column: 20, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..9a30eb2745ce --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [15, 19], + loc: { + start: { column: 15, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [20, 25], + loc: { + start: { column: 20, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [35, 39], + loc: { + start: { column: 35, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [39, 40], + loc: { + start: { column: 39, line: 1 }, + end: { column: 40, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [41, 47], + loc: { + start: { column: 41, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [49, 50], + loc: { + start: { column: 49, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..b2ee980389e8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [35, 39], + loc: { + start: { column: 35, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [41, 47], + loc: { + start: { column: 41, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [35, 47], + loc: { + start: { column: 35, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + ], + declaration: null, + exportKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [20, 25], + loc: { + start: { column: 20, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 51], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..95aa314bf6b3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [15, 19], + loc: { + start: { column: 15, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [20, 25], + loc: { + start: { column: 20, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [33, 34], + loc: { + start: { column: 33, line: 1 }, + end: { column: 34, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [35, 39], + loc: { + start: { column: 35, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [39, 40], + loc: { + start: { column: 39, line: 1 }, + end: { column: 40, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [41, 47], + loc: { + start: { column: 41, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [49, 50], + loc: { + start: { column: 49, line: 1 }, + end: { column: 50, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..258519a7adf2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..dade8ee29e7f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration assertion AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/fixture.ts new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/fixture.ts @@ -0,0 +1 @@ +export class Foo {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..d33d4cd08d4d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [17, 19], + loc: { + start: { column: 17, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + superClass: null, + + range: [7, 19], + loc: { + start: { column: 7, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..b9218046a087 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..b50c37aca337 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/3-Babel-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [], + + range: [17, 19], + loc: { + start: { column: 17, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + superClass: null, + + range: [7, 19], + loc: { + start: { column: 7, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..cdfb7afcd34f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "class", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..cb90ab5e0fbc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..8f68d87f732a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/class/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration class AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/fixture.ts new file mode 100644 index 000000000000..b1725174a5e8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/fixture.ts @@ -0,0 +1 @@ +export declare function foo(): void; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..e6cd6c4d7a38 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [29, 35], + loc: { + start: { column: 29, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [7, 36], + loc: { + start: { column: 7, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 36], + loc: { + start: { column: 0, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 37], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..13073c0479d3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "declare", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [35, 36], + loc: { + start: { column: 35, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..59786b3f97ea --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [29, 35], + loc: { + start: { column: 29, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [7, 36], + loc: { + start: { column: 7, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 36], + loc: { + start: { column: 0, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 37], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..b5ea9d5fbf4b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "declare", + + range: [7, 14], + loc: { + start: { column: 7, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [15, 23], + loc: { + start: { column: 15, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [35, 36], + loc: { + start: { column: 35, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..9aaae286a11a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: TSDeclareFunction { + type: 'TSDeclareFunction', + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: 'Identifier', + name: 'foo', + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: 'TSTypeAnnotation', + typeAnnotation: TSVoidKeyword { + type: 'TSVoidKeyword', + + range: [31, 35], + loc: { + start: { column: 31, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [29, 35], + loc: { + start: { column: 29, line: 1 }, + end: { column: 35, line: 1 }, + }, + }, + + range: [7, 36], + loc: { + start: { column: 7, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + exportKind: 'type', + source: null, + specifiers: Array [], + + range: [0, 36], + loc: { + start: { column: 0, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 37], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..9b1647311bd1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/declare-function/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration declare-function AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/fixture.ts new file mode 100644 index 000000000000..3705c4fd946a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/fixture.ts @@ -0,0 +1 @@ +export enum Foo {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..70f1a5783f9c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + members: Array [], + + range: [7, 18], + loc: { + start: { column: 7, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..5c6e73d4b258 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "enum", + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..cff1b64a3bcc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/3-Babel-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + members: Array [], + + range: [7, 18], + loc: { + start: { column: 7, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..e7ad15b4a50c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "enum", + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..1a21129afb24 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..2d3cd94a36c5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/enum/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration enum AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'export', + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'enum', + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/fixture.ts new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/fixture.ts @@ -0,0 +1 @@ +export function foo() {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..ad4118a633cc --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + params: Array [], + + range: [7, 24], + loc: { + start: { column: 7, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..c4c9340ff8c5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [7, 15], + loc: { + start: { column: 7, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..0a8a9e7e818c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/3-Babel-AST.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + params: Array [], + + range: [7, 24], + loc: { + start: { column: 7, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..f60ad2056b01 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [7, 15], + loc: { + start: { column: 7, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [16, 19], + loc: { + start: { column: 16, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..fe318b3ed6ff --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..502fe958a402 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/function-declaration/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration function-declaration AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/fixture.ts new file mode 100644 index 000000000000..7e905f38bf5d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/fixture.ts @@ -0,0 +1 @@ +export { a }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..3a91eb9c2525 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..471a1862f6cf --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..355669e5d302 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/3-Babel-AST.shot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..c01ed8b93a41 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..240f602618f3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: null, + exportKind: 'value', + source: null, + specifiers: Array [ + ExportSpecifier { + type: 'ExportSpecifier', + exported: Identifier { + type: 'Identifier', + name: 'a', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: 'value', + local: Identifier { + type: 'Identifier', + name: 'a', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..d3563662f8c1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-braced/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-braced AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/fixture.ts new file mode 100644 index 000000000000..606432a162aa --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/fixture.ts @@ -0,0 +1 @@ +export { a, b }; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..4c2fa789c167 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..91bf0e7c2b99 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..d228386edb52 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: null, + exportKind: "value", + source: null, + specifiers: Array [ + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ExportSpecifier { + type: "ExportSpecifier", + exported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + exportKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..f29165c63d00 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..8d76dc7c5710 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: null, + exportKind: 'value', + source: null, + specifiers: Array [ + ExportSpecifier { + type: 'ExportSpecifier', + exported: Identifier { + type: 'Identifier', + name: 'a', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + exportKind: 'value', + local: Identifier { + type: 'Identifier', + name: 'a', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ExportSpecifier { + type: 'ExportSpecifier', + exported: Identifier { + type: 'Identifier', + name: 'b', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + exportKind: 'value', + local: Identifier { + type: 'Identifier', + name: 'b', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..939b36fc37cd --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/identifier-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration identifier-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts new file mode 100644 index 000000000000..39df3b83f7e9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts @@ -0,0 +1 @@ +export interface Foo {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..a301d0efca70 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [7, 23], + loc: { + start: { column: 7, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..9a0b5ef7598a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "interface", + + range: [7, 16], + loc: { + start: { column: 7, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..776ce5004ba2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [7, 23], + loc: { + start: { column: 7, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..c52d2829e2e4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "interface", + + range: [7, 16], + loc: { + start: { column: 7, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..02ddc518379b --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: TSInterfaceDeclaration { + type: 'TSInterfaceDeclaration', + body: TSInterfaceBody { + type: 'TSInterfaceBody', + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [7, 23], + loc: { + start: { column: 7, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: 'type', + source: null, + specifiers: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..3bf1141ae946 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/interface/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration interface AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'export', + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [7, 16], + loc: { + start: { column: 7, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/fixture.ts new file mode 100644 index 000000000000..851030bd0285 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/fixture.ts @@ -0,0 +1 @@ +export namespace Foo {} diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..8bee64090fc2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [7, 23], + loc: { + start: { column: 7, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..72df88433a45 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [7, 16], + loc: { + start: { column: 7, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..494c5144247c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [7, 23], + loc: { + start: { column: 7, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..0a3d1ca1dee4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [7, 16], + loc: { + start: { column: 7, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..00a19c01c581 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..57daa643d18f --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/namespace/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration namespace AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/fixture.ts new file mode 100644 index 000000000000..f29cc6f5296e --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/fixture.ts @@ -0,0 +1 @@ +export type A = 1; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..2a6f27ff6911 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "A", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [7, 18], + loc: { + start: { column: 7, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..b7fb84a7c81e --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..b4392aa8e9c9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/3-Babel-AST.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "A", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [7, 18], + loc: { + start: { column: 7, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: "type", + source: null, + specifiers: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..597a4d5f2bdb --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..db70418e9f1d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExportNamedDeclaration { + type: 'ExportNamedDeclaration', + assertions: Array [], + declaration: TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', + id: Identifier { + type: 'Identifier', + name: 'A', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: 'TSLiteralType', + literal: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [7, 18], + loc: { + start: { column: 7, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: 'type', + source: null, + specifiers: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..6f04a9a69814 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/type-alias/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration type-alias AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/fixture.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/fixture.ts new file mode 100644 index 000000000000..ad1d380d6cc4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/fixture.ts @@ -0,0 +1 @@ +export const x = 1; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/1-TSESTree-AST.shot new file mode 100644 index 000000000000..64a85af7e541 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [13, 18], + loc: { + start: { column: 13, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + kind: "const", + + range: [7, 19], + loc: { + start: { column: 7, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 000000000000..73bd6c93bb9d --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "const", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/3-Babel-AST.shot new file mode 100644 index 000000000000..8b842b6d5841 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportNamedDeclaration { + type: "ExportNamedDeclaration", + assertions: Array [], + declaration: VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [13, 18], + loc: { + start: { column: 13, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + kind: "const", + + range: [7, 19], + loc: { + start: { column: 7, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + exportKind: "value", + source: null, + specifiers: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/4-Babel-Tokens.shot new file mode 100644 index 000000000000..1bfff47fa927 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "const", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 000000000000..bb45021e9c4a --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 000000000000..de15dbc1cc63 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/fixtures/variable-declaration/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportNamedDeclaration variable-declaration AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts index d2f4d75b3c2e..3e2989b74990 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -8,6 +8,7 @@ import type { ExportKind } from '../ExportAndImportKind'; export interface ExportNamedDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportNamedDeclaration; + // TODO(error handling) - ClassExpression is not valid here declaration: ExportDeclaration | null; specifiers: ExportSpecifier[]; source: StringLiteral | null; diff --git a/packages/ast-spec/tests/PunctuatorTokenToText.test.ts b/packages/ast-spec/tests/PunctuatorTokenToText.type-test.ts similarity index 91% rename from packages/ast-spec/tests/PunctuatorTokenToText.test.ts rename to packages/ast-spec/tests/PunctuatorTokenToText.type-test.ts index 32deee0bea9a..e92f2a7db0c5 100644 --- a/packages/ast-spec/tests/PunctuatorTokenToText.test.ts +++ b/packages/ast-spec/tests/PunctuatorTokenToText.type-test.ts @@ -2,7 +2,6 @@ import type { PunctuationSyntaxKind } from 'typescript'; import type { PunctuatorTokenToText } from '../src'; -// @ts-expect-error: purposely unused type _Test = { readonly [T in PunctuationSyntaxKind]: PunctuatorTokenToText[T]; // If there are any PunctuationSyntaxKind members that don't have a diff --git a/packages/ast-spec/tests/ast-node-types.test.ts b/packages/ast-spec/tests/ast-node-types.type-test.ts similarity index 94% rename from packages/ast-spec/tests/ast-node-types.test.ts rename to packages/ast-spec/tests/ast-node-types.type-test.ts index 7cc247f2d094..dc3d9a1bd506 100644 --- a/packages/ast-spec/tests/ast-node-types.test.ts +++ b/packages/ast-spec/tests/ast-node-types.type-test.ts @@ -9,7 +9,6 @@ type AllKeys = { type TakesString> = T; -// @ts-expect-error: purposely unused type _Test = // forcing the test onto a new line so it isn't covered by the expect error // If there are any enum members that don't have a corresponding TSESTree.Node, then this line will error with "Type 'string | number | symbol' is not assignable to type 'string'." diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot new file mode 100644 index 000000000000..2a37d6b6582d --- /dev/null +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures List fixtures with AST differences 1`] = ` +Set { + "declaration/ClassDeclaration/fixtures/implements-many/fixture.ts", + "declaration/ClassDeclaration/fixtures/implements-one/fixture.ts", + "declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts", + "declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/aliased/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/declare-function/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/identifier-braced/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/identifier-many/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/type-alias/fixture.ts", +} +`; diff --git a/packages/ast-spec/tests/fixtures-with-differences-errors.shot b/packages/ast-spec/tests/fixtures-with-differences-errors.shot new file mode 100644 index 000000000000..59b5c479a758 --- /dev/null +++ b/packages/ast-spec/tests/fixtures-with-differences-errors.shot @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures List fixtures with Error differences 1`] = ` +Object { + "Babel errored but TSESTree didn't": Set { + "declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/fixture.ts", + "declaration/ExportAllDeclaration/fixtures/_error_/type-kind/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/fixture.ts", + }, + "TSESTree errored but Babel didn't": Set { + "declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/fixture.ts", + }, +} +`; diff --git a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot new file mode 100644 index 000000000000..6c8d721a41a5 --- /dev/null +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures List fixtures with Token differences 1`] = ` +Set { + "declaration/ClassDeclaration/fixtures/implements-many/fixture.ts", + "declaration/ClassDeclaration/fixtures/implements-one/fixture.ts", + "declaration/ExportDefaultDeclaration/fixtures/interface/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/enum/fixture.ts", + "declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts", +} +`; diff --git a/packages/ast-spec/tests/fixtures.test.ts b/packages/ast-spec/tests/fixtures.test.ts new file mode 100644 index 000000000000..e9685f2a425e --- /dev/null +++ b/packages/ast-spec/tests/fixtures.test.ts @@ -0,0 +1,281 @@ +import fs from 'fs'; +import glob from 'glob'; +import makeDir from 'make-dir'; +import path from 'path'; +import { parseBabel } from './util/parsers/babel'; +import { + Fixture, + ParserResponse, + ParserResponseError, + ParserResponseSuccess, + ParserResponseType, +} from './util/parsers/parser-types'; +import { parseTSESTree } from './util/parsers/typescript-estree'; +import { snapshotDiff, diffHasChanges } from './util/snapshot-diff'; + +const PACKAGE_ROOT = path.resolve(__dirname, '..'); +const SRC_DIR = path.resolve(PACKAGE_ROOT, 'src'); + +// Assign a segment set to this variable to limit the test to only this segment +// This is super helpful if you need to debug why a specific fixture isn't producing the correct output +// eg. ['declaration', 'ClassDeclaration', 'abstract'] will only test /declaration/ClassDeclaration/fixtures/abstract/fixture.ts +// prettier-ignore +const ONLY = [].join(path.sep); + +const fixturesWithASTDifferences = new Set(); +const fixturesWithTokenDifferences = new Set(); +enum ErrorLabel { + TSESTree = "TSESTree errored but Babel didn't", + Babel = "Babel errored but TSESTree didn't", + Both = 'Both errored', + None = 'No errors', +} +const fixturesWithErrorDifferences = { + [ErrorLabel.TSESTree]: new Set(), + [ErrorLabel.Babel]: new Set(), +} as const; + +const validFixtures = glob.sync(`${SRC_DIR}/**/fixtures/*/*.{ts,tsx}`); +const errorFixtures = glob.sync(`${SRC_DIR}/**/fixtures/_error_/*/*.{ts,tsx}`); + +const fixtures: readonly Fixture[] = [...validFixtures, ...errorFixtures].map( + absolute => { + const relativeToSrc = path.relative(SRC_DIR, absolute); + const { dir, ext } = path.parse(relativeToSrc); + const segments = dir.split(path.sep).filter(s => s !== 'fixtures'); + const name = segments.pop()!; + const snapshotPath = path.join(SRC_DIR, dir, 'snapshots'); + return { + absolute, + name, + ext, + isError: absolute.includes('/_error_/'), + isJSX: ext.endsWith('x'), + relative: path.relative(SRC_DIR, absolute), + segments, + snapshotPath, + snapshotFiles: { + success: { + tsestree: { + ast: path.join(snapshotPath, '1-TSESTree-AST.shot'), + tokens: path.join(snapshotPath, '2-TSESTree-Tokens.shot'), + }, + babel: { + ast: path.join(snapshotPath, '3-Babel-AST.shot'), + tokens: path.join(snapshotPath, '4-Babel-Tokens.shot'), + }, + alignment: { + ast: path.join(snapshotPath, '5-AST-Alignment-AST.shot'), + tokens: path.join(snapshotPath, '6-AST-Alignment-Tokens.shot'), + }, + }, + error: { + tsestree: path.join(snapshotPath, '1-TSESTree-Error.shot'), + babel: path.join(snapshotPath, '2-Babel-Error.shot'), + alignment: path.join(snapshotPath, '3-Alignment-Error.shot'), + }, + }, + }; + }, +); + +function hasErrorCode(e: unknown): e is { code: unknown } { + return typeof e === 'object' && e != null && 'code' in e; +} + +function expectSuccessResponse( + thing: ParserResponse, +): asserts thing is ParserResponseSuccess { + expect(thing.type).toEqual(ParserResponseType.NoError); +} +function expectErrorResponse( + thing: ParserResponse, +): asserts thing is ParserResponseError { + expect(thing.type).toEqual(ParserResponseType.Error); +} + +function nestDescribe(fixture: Fixture, segments = fixture.segments): void { + if (segments.length > 0) { + describe(segments[0], () => { + nestDescribe(fixture, segments.slice(1)); + }); + } else { + const test = (): void => { + const contents = fs.readFileSync(fixture.absolute, 'utf8'); + + try { + makeDir.sync(fixture.snapshotPath); + } catch (e) { + if (hasErrorCode(e) && e.code === 'EEXIST') { + // already exists - ignored + } else { + throw e; + } + } + + const tsestreeParsed = parseTSESTree(fixture, contents); + const babelParsed = parseBabel(fixture, contents); + const babelError = babelParsed.type === ParserResponseType.Error; + const tsestreeError = tsestreeParsed.type === ParserResponseType.Error; + + let errorLabel: ErrorLabel; + if (!babelError && tsestreeError) { + errorLabel = ErrorLabel.TSESTree; + } else if (babelError && !tsestreeError) { + errorLabel = ErrorLabel.Babel; + } else if (babelError && tsestreeError) { + errorLabel = ErrorLabel.Both; + } else { + errorLabel = ErrorLabel.None; + } + + if (fixture.isError) { + if ( + errorLabel === ErrorLabel.TSESTree || + errorLabel === ErrorLabel.Babel + ) { + fixturesWithErrorDifferences[errorLabel].add(fixture.relative); + } + + it('TSESTree - Error', () => { + expect(tsestreeParsed.error).toMatchSpecificSnapshot( + fixture.snapshotFiles.error.tsestree, + ); + }); + it('Babel - Error', () => { + expect(babelParsed.error).toMatchSpecificSnapshot( + fixture.snapshotFiles.error.babel, + ); + }); + it('Error Alignment', () => { + expect(errorLabel).toMatchSpecificSnapshot( + fixture.snapshotFiles.error.alignment, + ); + }); + it('Should parse with errors', () => { + // if this fails and you WEREN'T expecting a parser error, then your fixture should not be in the `_error_` subfolder + // if this fails and you WERE expecting a parser error - then something is broken. + expect(errorLabel).not.toBe(ErrorLabel.None); + }); + } else { + it('TSESTree - AST', () => { + expectSuccessResponse(tsestreeParsed); + expect(tsestreeParsed.ast).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.tsestree.ast, + ); + }); + it('TSESTree - Tokens', () => { + expectSuccessResponse(tsestreeParsed); + expect(tsestreeParsed.tokens).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.tsestree.tokens, + ); + }); + + it('Babel - AST', () => { + expectSuccessResponse(babelParsed); + expect(babelParsed.ast).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.babel.ast, + ); + }); + it('Babel - Tokens', () => { + expectSuccessResponse(babelParsed); + expect(babelParsed.tokens).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.babel.tokens, + ); + }); + + it('AST Alignment - AST', () => { + expectSuccessResponse(tsestreeParsed); + expectSuccessResponse(babelParsed); + const diffResult = snapshotDiff( + 'TSESTree', + tsestreeParsed.ast, + 'Babel', + babelParsed.ast, + ); + expect(diffResult).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.alignment.ast, + ); + + if (diffHasChanges(diffResult)) { + fixturesWithASTDifferences.add(fixture.relative); + } + }); + it('AST Alignment - Token', () => { + expectSuccessResponse(tsestreeParsed); + expectSuccessResponse(babelParsed); + const diffResult = snapshotDiff( + 'TSESTree', + tsestreeParsed.tokens, + 'Babel', + babelParsed.tokens, + ); + expect(diffResult).toMatchSpecificSnapshot( + fixture.snapshotFiles.success.alignment.tokens, + ); + + if (diffHasChanges(diffResult)) { + fixturesWithTokenDifferences.add(fixture.relative); + } + }); + + it('Should parse with no errors', () => { + // log the error for debug purposes in case there wasn't supposed to be an error + switch (errorLabel) { + case ErrorLabel.None: + return; + + case ErrorLabel.Babel: + expectErrorResponse(babelParsed); + console.error('Babel:\n', babelParsed.error); + break; + + case ErrorLabel.TSESTree: + expectErrorResponse(tsestreeParsed); + console.error('TSESTree:\n', tsestreeParsed.error); + break; + + case ErrorLabel.Both: + expectErrorResponse(babelParsed); + expectErrorResponse(tsestreeParsed); + console.error('Babel:\n', babelParsed.error); + console.error('TSESTree:\n', tsestreeParsed.error); + break; + } + + // if this fails and you WERE expecting a parser error, then your fixture should be in the `_error_` subfolder + // if this fails and you WEREN'T expecting a parser error - then something is broken. + expect(errorLabel).toBe(ErrorLabel.None); + }); + } + }; + + if ([...fixture.segments, fixture.name].join(path.sep) === ONLY) { + // eslint-disable-next-line jest/no-focused-tests + describe.only(fixture.name, test); + } else { + describe(fixture.name, test); + } + } +} + +describe('AST Fixtures', () => { + fixtures.forEach(f => nestDescribe(f)); + + // once we've run all the tests, snapshot the list of fixtures that have differences for easy reference + it('List fixtures with AST differences', () => { + expect(fixturesWithASTDifferences).toMatchSpecificSnapshot( + path.resolve(__dirname, 'fixtures-with-differences-ast.shot'), + ); + }); + it('List fixtures with Token differences', () => { + expect(fixturesWithTokenDifferences).toMatchSpecificSnapshot( + path.resolve(__dirname, 'fixtures-with-differences-tokens.shot'), + ); + }); + it('List fixtures with Error differences', () => { + expect(fixturesWithErrorDifferences).toMatchSpecificSnapshot( + path.resolve(__dirname, 'fixtures-with-differences-errors.shot'), + ); + }); +}); diff --git a/packages/ast-spec/tests/util/parsers/babel.ts b/packages/ast-spec/tests/util/parsers/babel.ts new file mode 100644 index 000000000000..d5995880a802 --- /dev/null +++ b/packages/ast-spec/tests/util/parsers/babel.ts @@ -0,0 +1,47 @@ +import { parse, ParserPlugin } from '@babel/eslint-parser'; +import { ParserResponseType, Fixture, ParserResponse } from './parser-types'; + +const PLUGINS: ParserPlugin[] = [ + // TODO - enable classFeatures instead of classProperties when we support it + // 'classFeatures', + 'classProperties', + 'decorators-legacy', + 'importAssertions', + 'typescript', +]; + +export function parseBabel(fixture: Fixture, contents: string): ParserResponse { + const plugins = [...PLUGINS]; + if (fixture.isJSX) { + plugins.push('jsx'); + } + + try { + const result = parse(contents, { + allowImportExportEverywhere: true, + babelOptions: { + parserOpts: { + plugins, + }, + }, + ecmaFeatures: { + globalReturn: true, + }, + requireConfigFile: false, + sourceType: 'unambiguous', + }); + const { tokens: _, comments: __, ...program } = result; + + return { + type: ParserResponseType.NoError, + ast: program, + error: 'NO ERROR', + tokens: result.tokens, + }; + } catch (error: unknown) { + return { + type: ParserResponseType.Error, + error, + }; + } +} diff --git a/packages/ast-spec/tests/util/parsers/parser-types.ts b/packages/ast-spec/tests/util/parsers/parser-types.ts new file mode 100644 index 000000000000..1278d43a99ef --- /dev/null +++ b/packages/ast-spec/tests/util/parsers/parser-types.ts @@ -0,0 +1,45 @@ +interface SuccessSnapshotPaths { + readonly ast: string; + readonly tokens: string; +} + +export interface Fixture { + readonly absolute: string; + readonly name: string; + readonly ext: string; + readonly isError: boolean; + readonly isJSX: boolean; + readonly relative: string; + readonly segments: string[]; + readonly snapshotPath: string; + readonly snapshotFiles: { + readonly success: { + readonly tsestree: SuccessSnapshotPaths; + readonly babel: SuccessSnapshotPaths; + readonly alignment: SuccessSnapshotPaths; + }; + readonly error: { + readonly tsestree: string; + readonly babel: string; + readonly alignment: string; + }; + }; +} + +export enum ParserResponseType { + Error = 'Error', + NoError = 'NoError', +} + +export interface ParserResponseSuccess { + readonly type: ParserResponseType.NoError; + readonly ast: unknown; + // this exists for the error alignment test snapshots + readonly error: 'NO ERROR'; + readonly tokens: unknown; +} +export interface ParserResponseError { + readonly type: ParserResponseType.Error; + readonly error: unknown; +} +export type ParserResponse = ParserResponseSuccess | ParserResponseError; diff --git a/packages/ast-spec/tests/util/parsers/typescript-estree.ts b/packages/ast-spec/tests/util/parsers/typescript-estree.ts new file mode 100644 index 000000000000..664b2caa8d33 --- /dev/null +++ b/packages/ast-spec/tests/util/parsers/typescript-estree.ts @@ -0,0 +1,45 @@ +/** + * Nx is picking up on the fact that we technically have a circular dependency between ast-spec + * and typescript-estree. + * + * This circular dependency only occurs in the tests/ for ast-spec and not in the main package source. + * + * We could therefore solve this by separating the ast-spec tests out into their own package, but the + * other option is to get Nx to turn a blind eye to the circular dependency by removing + * @typescript-eslint/typescript-estree as an explicit devDependency in the package.json and just doing an import here. + * + * This should be the only place in the package that we import from typescript-estree. + */ + +// We need to ignore this lint error regarding it being missing from the package.json, see above. +// eslint-disable-next-line import/no-extraneous-dependencies +import { parse } from '@typescript-eslint/typescript-estree'; +import { ParserResponseType, Fixture, ParserResponse } from './parser-types'; + +export function parseTSESTree( + fixture: Fixture, + contents: string, +): ParserResponse { + try { + const result = parse(contents, { + comment: false, + jsx: fixture.ext.endsWith('x'), + loc: true, + range: true, + tokens: true, + }); + const { tokens: _, comments: __, ...program } = result; + + return { + type: ParserResponseType.NoError, + ast: program, + error: 'NO ERROR', + tokens: result.tokens, + }; + } catch (error: unknown) { + return { + type: ParserResponseType.Error, + error, + }; + } +} diff --git a/packages/ast-spec/tests/util/serializers/Node.ts b/packages/ast-spec/tests/util/serializers/Node.ts new file mode 100644 index 000000000000..a9e6b4ddf06c --- /dev/null +++ b/packages/ast-spec/tests/util/serializers/Node.ts @@ -0,0 +1,83 @@ +import type * as TSESTree from '../../../src'; +import { NewPlugin } from 'pretty-format'; +import { AST_NODE_TYPES } from '../../../src'; + +function sortKeys(node: TSESTree.Node): (keyof typeof node)[] { + const keySet = new Set(Object.keys(node)); + + // type place as first key + keySet.delete('type'); + // range and loc we place after all properties + keySet.delete('range'); + keySet.delete('loc'); + + // babel keys + keySet.delete('start'); + keySet.delete('end'); + if (node.type === AST_NODE_TYPES.Program) { + keySet.delete('interpreter'); + } + + return Array.from(keySet).sort((a, b) => + a.localeCompare(b), + ) as (keyof typeof node)[]; +} + +function stringifyLineAndColumn(loc: TSESTree.Position): string { + return `{ column: ${loc.column}, line: ${loc.line} }`; +} + +function isObject(val: unknown): val is Record { + return val != null && typeof val === 'object'; +} +function hasValidType(type: unknown): type is string { + return typeof type === 'string'; +} + +const serializer: NewPlugin = { + test(val: unknown) { + return isObject(val) && hasValidType(val.type); + }, + serialize(node: TSESTree.Node, config, indentation, depth, refs, printer) { + const keys = sortKeys(node); + const type = node.type; + const loc = node.loc; + const range = node.range; + + const outputLines = []; + const childIndentation = indentation + config.indent; + + const printValue = (value: unknown): string => + printer(value, config, childIndentation, depth, refs); + + outputLines.push(`${type} {`); + outputLines.push(`${childIndentation}type: ${printValue(type)},`); + + for (const key of keys) { + const value = node[key]; + if (value === undefined) { + continue; + } + + outputLines.push(`${childIndentation}${key}: ${printValue(value)},`); + } + + outputLines.push(''); + outputLines.push(`${childIndentation}range: [${range.join(', ')}],`); + outputLines.push( + `${childIndentation}loc: {`, + `${childIndentation}${config.indent}start: ${stringifyLineAndColumn( + loc.start, + )},`, + `${childIndentation}${config.indent}end: ${stringifyLineAndColumn( + loc.end, + )},`, + `${childIndentation}},`, + ); + outputLines.push(`${indentation}}`); + + return outputLines.join('\n'); + }, +}; + +export { serializer }; diff --git a/packages/ast-spec/tests/util/serializers/index.ts b/packages/ast-spec/tests/util/serializers/index.ts new file mode 100644 index 000000000000..c9c0e3c54bef --- /dev/null +++ b/packages/ast-spec/tests/util/serializers/index.ts @@ -0,0 +1,6 @@ +import * as Node from './Node'; + +export const serializers = [ + // + Node.serializer, +] as const; diff --git a/packages/ast-spec/tests/util/serializers/string.ts b/packages/ast-spec/tests/util/serializers/string.ts new file mode 100644 index 000000000000..81750c260098 --- /dev/null +++ b/packages/ast-spec/tests/util/serializers/string.ts @@ -0,0 +1,38 @@ +import { NewPlugin } from 'pretty-format'; + +// custom string serializer so that we can use single-quoted strings instead of double quoted strings +// this plays nicer with the way that the snapshot diff result, which is a pure string +const serializer: NewPlugin = { + test(val: unknown) { + return typeof val === 'string'; + }, + serialize( + str: string, + // config, + // indentation, + // depth, + // refs, + // printer, + ) { + const characters: string[] = []; + + characters.push("'"); + for (const character of str) { + switch (character) { + case "'": + characters.push('\\'); + break; + + case '\\': + characters.push('\\'); + break; + } + characters.push(character); + } + characters.push("'"); + + return characters.join(''); + }, +}; + +export { serializer }; diff --git a/packages/ast-spec/tests/util/setupJest.ts b/packages/ast-spec/tests/util/setupJest.ts new file mode 100644 index 000000000000..6b9e99943bf9 --- /dev/null +++ b/packages/ast-spec/tests/util/setupJest.ts @@ -0,0 +1,8 @@ +import { addSerializer } from 'jest-specific-snapshot'; +import { serializers } from './serializers'; + +for (const serializer of serializers) { + // the jest types are wrong here + expect.addSnapshotSerializer(serializer); + addSerializer(serializer); +} diff --git a/packages/ast-spec/tests/util/snapshot-diff.ts b/packages/ast-spec/tests/util/snapshot-diff.ts new file mode 100644 index 000000000000..4bf6546eeecb --- /dev/null +++ b/packages/ast-spec/tests/util/snapshot-diff.ts @@ -0,0 +1,67 @@ +import { diff } from 'jest-diff'; +import defaultPrinter from 'pretty-format'; +import * as NodeSerializer from './serializers/Node'; +import * as StringSerializer from './serializers/string'; + +function identity(value: T): T { + return value; +} + +function diffStrings( + valueA: unknown, + valueB: unknown, + valueAName: string, + valueBName: string, +): string | null { + return diff(valueA, valueB, { + expand: false, + // we want to show the entire file in the diff + // that way you don't have to try and figure out what lines map to which sections + contextLines: Number.MAX_SAFE_INTEGER, + aAnnotation: valueAName, + bAnnotation: valueBName, + aColor: identity, + bColor: identity, + changeColor: identity, + commonColor: identity, + patchColor: identity, + }); +} + +export function snapshotDiff( + valueAName: string, + valueA: unknown, + valueBName: string, + valueB: unknown, +): string { + const OPTIONS = { + plugins: [ + NodeSerializer.serializer, + // by default jest will quote the string with double quotes + // this means the diff string will have double quotes escaped and look ugly + // this is a single-quote string serializer which won't clash with the outer double quotes + // so we get a nicer looking diff because of it! + StringSerializer.serializer, + ], + }; + + const difference = diffStrings( + defaultPrinter(valueA, OPTIONS), + defaultPrinter(valueB, OPTIONS), + valueAName, + valueBName, + ); + + if (difference == null) { + throw new Error('Unexpected null when diffing snapshots.'); + } + + return 'Snapshot Diff:\n' + difference; +} + +// https://github.com/facebook/jest/blob/a293b75310cfc209713df1d34d243eb258995316/packages/jest-diff/src/constants.ts#L8 +const NO_DIFF_MESSAGE = 'Compared values have no visual difference.'; + +export function diffHasChanges(diff: string): boolean { + return !diff.includes(NO_DIFF_MESSAGE); +} diff --git a/packages/ast-spec/tsconfig.build.json b/packages/ast-spec/tsconfig.build.json index 215a0282df2b..89b0284199a6 100644 --- a/packages/ast-spec/tsconfig.build.json +++ b/packages/ast-spec/tsconfig.build.json @@ -6,5 +6,6 @@ "rootDir": "./src", "resolveJsonModule": true }, - "include": ["src", "typings"] + "include": ["src", "typings"], + "exclude": ["**/fixtures/**"] } diff --git a/packages/ast-spec/tsconfig.json b/packages/ast-spec/tsconfig.json index 4b76ef4253b9..fd3827cd5bae 100644 --- a/packages/ast-spec/tsconfig.json +++ b/packages/ast-spec/tsconfig.json @@ -4,5 +4,7 @@ "composite": false, "rootDir": "." }, - "include": ["src", "typings", "tests", "tools", "./rollup.config.ts"] + "include": ["src", "typings", "tests", "tools", "./rollup.config.ts"], + "exclude": ["**/fixtures/**"], + "references": [{ "path": "../typescript-estree/tsconfig.build.json" }] } diff --git a/packages/ast-spec/typings/babel-eslint-parser.d.ts b/packages/ast-spec/typings/babel-eslint-parser.d.ts new file mode 100644 index 000000000000..4bcf8911caf3 --- /dev/null +++ b/packages/ast-spec/typings/babel-eslint-parser.d.ts @@ -0,0 +1,23 @@ +declare module '@babel/eslint-parser' { + import type { TransformOptions } from '@babel/core'; + + export type { ParserPlugin } from '@babel/parser'; + + export interface Options { + readonly allowImportExportEverywhere?: boolean; + readonly babelOptions?: TransformOptions; + readonly ecmaFeatures?: { + readonly globalReturn?: boolean; + }; + readonly requireConfigFile?: boolean; + readonly sourceType?: string; + } + + export interface BabelAST { + readonly tokens: unknown; + readonly comments: unknown; + readonly [k: string]: unknown; + } + + export function parse(code: string, options: Options): BabelAST; +} diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 6d091947492b..18345cb36f7e 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 61143c056c00..72b8849316d8 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "5.21.0", + "version": "5.22.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,8 +14,8 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/utils": "5.22.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 1afcdc8ab02f..d0a62abd34cc 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 9c82b9eb5e34..a194d91efcfc 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "5.21.0", + "version": "5.22.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/utils": "5.22.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.21.0" + "@typescript-eslint/parser": "5.22.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index f09db7a1d2ef..5e0b1a0ceb74 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Bug Fixes + +* **eslint-plugin:** [comma-spacing] verify `nextToken` exists ([#4868](https://github.com/typescript-eslint/typescript-eslint/issues/4868)) ([23746f8](https://github.com/typescript-eslint/typescript-eslint/commit/23746f8babace7c2354368d6fb0881be26e19c41)) + + +### Features + +* **eslint-plugin:** [no-duplicate-enum-values] add rule ([#4833](https://github.com/typescript-eslint/typescript-eslint/issues/4833)) ([5899164](https://github.com/typescript-eslint/typescript-eslint/commit/5899164b35d91106512a2720b23ba92e1893132f)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index f9126c5f1334..7b1d5d03cc2c 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -119,6 +119,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | | | :thought_balloon: | | [`@typescript-eslint/no-confusing-non-null-assertion`](./docs/rules/no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | | :wrench: | | | [`@typescript-eslint/no-confusing-void-expression`](./docs/rules/no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: | +| [`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md) | Disallow duplicate enum member values | | | | | [`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | | :wrench: | | | [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | | | [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | | diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index ab54967aa3ab..6c476e4f411e 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -2,318 +2,58 @@ Require a consistent member declaration order. -A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate and edit. +A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate, and edit. ## Rule Details This rule aims to standardize the way class declarations, class expressions, interfaces and type literals are structured and ordered. -### Grouping and sorting member groups - -It allows to group members by their type (e.g. `public-static-field`, `protected-static-field`, `private-static-field`, `public-instance-field`, ...) and enforce a certain order for these groups. By default, their order is the same inside `classes`, `classExpressions`, `interfaces` and `typeLiterals` (note: not all member types apply to `interfaces` and `typeLiterals`). It is possible to define the order for any of those individually or to change the default order for all of them by setting the `default` option. - -### Sorting members - -Besides grouping the members and sorting their groups, this rule also allows to sort the members themselves (e.g. `a`, `b`, `c`, ...). You have 2 options: Sort all of them while ignoring their type or sort them while respecting their types (e.g. sort all fields in an interface alphabetically). - ## Options -These options allow to specify how to group the members and sort their groups. - -- Sort groups, don't enforce member order: Use `memberTypes` -- Sort members, don't enforce group order: Use `order` -- Sort members within groups: Use `memberTypes` and `order` - ```ts -type SortedOrderConfig = { - memberTypes?: MemberType[] | 'never'; - order: 'alphabetically' | 'alphabetically-case-insensitive' | 'as-written'; -}; - -type OrderConfig = MemberType[] | SortedOrderConfig | 'never'; - -type Options = { +interface Options { default?: OrderConfig; classes?: OrderConfig; classExpressions?: OrderConfig; interfaces?: OrderConfig; typeLiterals?: OrderConfig; -}; -``` - -See below for the possible definitions of `MemberType`. - -### Deprecated syntax - -Note: There is a deprecated syntax to specify the member types as an array. - -### Member types (granular form) - -There are multiple ways to specify the member types. The most explicit and granular form is the following: - -```jsonc -[ - // Index signature - "signature", - - // Fields - "public-static-field", - "protected-static-field", - "private-static-field", - "public-decorated-field", - "protected-decorated-field", - "private-decorated-field", - "public-instance-field", - "protected-instance-field", - "private-instance-field", - "public-abstract-field", - "protected-abstract-field", - "private-abstract-field", - - // Constructors - "public-constructor", - "protected-constructor", - "private-constructor", - - // Getters - "public-static-get", - "protected-static-get", - "private-static-get", - - "public-decorated-get", - "protected-decorated-get", - "private-decorated-get", - - "public-instance-get", - "protected-instance-get", - "private-instance-get", - - "public-abstract-get", - "protected-abstract-get", - "private-abstract-get", - - "public-get", - "protected-get", - "private-get", - - "static-get", - "instance-get", - "abstract-get", - - "decorated-get", - - "get", - - // Setters - "public-static-set", - "protected-static-set", - "private-static-set", - - "public-decorated-set", - "protected-decorated-set", - "private-decorated-set", - - "public-instance-set", - "protected-instance-set", - "private-instance-set", - - "public-abstract-set", - "protected-abstract-set", - "private-abstract-set", - - "public-set", - "protected-set", - "private-set", - - "static-set", - "instance-set", - "abstract-set", - - "decorated-set", - - "set", - - // Methods - "public-static-method", - "protected-static-method", - "private-static-method", - "public-decorated-method", - "protected-decorated-method", - "private-decorated-method", - "public-instance-method", - "protected-instance-method", - "private-instance-method", - "public-abstract-method", - "protected-abstract-method", - "private-abstract-method" -] -``` - -Note: If you only specify some of the possible types, the non-specified ones can have any particular order. This means that they can be placed before, within or after the specified types and the linter won't complain about it. - -### Member group types (with accessibility, ignoring scope) - -It is also possible to group member types by their accessibility (`static`, `instance`, `abstract`), ignoring their scope. - -```jsonc -[ - // Index signature - // No accessibility for index signature. See above. - - // Fields - "public-field", // = ["public-static-field", "public-instance-field"] - "protected-field", // = ["protected-static-field", "protected-instance-field"] - "private-field", // = ["private-static-field", "private-instance-field"] - - // Constructors - // Only the accessibility of constructors is configurable. See below. - - // Getters - "public-get", // = ["public-static-get", "public-instance-get"] - "protected-get", // = ["protected-static-get", "protected-instance-get"] - "private-get", // = ["private-static-get", "private-instance-get"] - - // Setters - "public-set", // = ["public-static-set", "public-instance-set"] - "protected-set", // = ["protected-static-set", "protected-instance-set"] - "private-set", // = ["private-static-set", "private-instance-set"] - - // Methods - "public-method", // = ["public-static-method", "public-instance-method"] - "protected-method", // = ["protected-static-method", "protected-instance-method"] - "private-method" // = ["private-static-method", "private-instance-method"] -] -``` - -### Member group types (with accessibility and a decorator) - -It is also possible to group methods or fields with a decorator separately, optionally specifying -their accessibility. - -```jsonc -[ - // Index signature - // No decorators for index signature. - - // Fields - "public-decorated-field", - "protected-decorated-field", - "private-decorated-field", - - "decorated-field", // = ["public-decorated-field", "protected-decorated-field", "private-decorated-field"] - - // Constructors - // There are no decorators for constructors. - - // Getters - "public-decorated-get", - "protected-decorated-get", - "private-decorated-get", - - "decorated-get" // = ["public-decorated-get", "protected-decorated-get", "private-decorated-get"] - - // Setters - "public-decorated-set", - "protected-decorated-set", - "private-decorated-set", - - "decorated-set" // = ["public-decorated-set", "protected-decorated-set", "private-decorated-set"] - - // Methods - "public-decorated-method", - "protected-decorated-method", - "private-decorated-method", - - "decorated-method" // = ["public-decorated-method", "protected-decorated-method", "private-decorated-method"] -] -``` - -### Member group types (with scope, ignoring accessibility) - -Another option is to group the member types by their scope (`public`, `protected`, `private`), ignoring their accessibility. - -```jsonc -[ - // Index signature - // No scope for index signature. See above. - - // Fields - "static-field", // = ["public-static-field", "protected-static-field", "private-static-field"] - "instance-field", // = ["public-instance-field", "protected-instance-field", "private-instance-field"] - "abstract-field", // = ["public-abstract-field", "protected-abstract-field", "private-abstract-field"] - - // Constructors - "constructor", // = ["public-constructor", "protected-constructor", "private-constructor"] +} - // Getters - "static-get", // = ["public-static-get", "protected-static-get", "private-static-get"] - "instance-get", // = ["public-instance-get", "protected-instance-get", "private-instance-get"] - "abstract-get" // = ["public-abstract-get", "protected-abstract-get", "private-abstract-get"] +type OrderConfig = MemberType[] | SortedOrderConfig | 'never'; - // Setters - "static-set", // = ["public-static-set", "protected-static-set", "private-static-set"] - "instance-set", // = ["public-instance-set", "protected-instance-set", "private-instance-set"] - "abstract-set" // = ["public-abstract-set", "protected-abstract-set", "private-abstract-set"] +interface SortedOrderConfig { + memberTypes?: MemberType[] | 'never'; + order: 'alphabetically' | 'alphabetically-case-insensitive' | 'as-written'; +} - // Methods - "static-method", // = ["public-static-method", "protected-static-method", "private-static-method"] - "instance-method", // = ["public-instance-method", "protected-instance-method", "private-instance-method"] - "abstract-method" // = ["public-abstract-method", "protected-abstract-method", "private-abstract-method"] -] +// See below for the more specific MemberType strings +type MemberType = string | string[]; ``` -### Member group types (with scope and accessibility) - -The third grouping option is to ignore both scope and accessibility. - -```jsonc -[ - // Index signature - // No grouping for index signature. See above. - - // Fields - "field", // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field", - // "public-abstract-field", "protected-abstract-field", private-abstract-field"] - - // Constructors - // Only the accessibility of constructors is configurable. See above. - - // Getters - "get" // = ["public-static-get", "protected-static-get", "private-static-get", "public-instance-get", "protected-instance-get", "private-instance-get", - // "public-abstract-get", "protected-abstract-get", "private-abstract-get"] - - // Setters - "set" // = ["public-static-set", "protected-static-set", "private-static-set", "public-instance-set", "protected-instance-set", "private-instance-set", - // "public-abstract-set", "protected-abstract-set", "private-abstract-set"] - - // Methods - "method" // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method", - // "public-abstract-method", "protected-abstract-method", "private-abstract-method"] -] -``` +You can configure `OrderConfig` options for: -### Grouping different member types at the same rank +- **`default`**: all constructs (used as a fallback) +- **`classes`**?: override ordering specifically for classes +- **`classExpressions`**?: override ordering specifically for class expressions +- **`interfaces`**?: override ordering specifically for interfaces +- **`typeLiterals`**?: override ordering specifically for type literals -It is also possible to group different member types at the same rank. +The `OrderConfig` settings for each kind of construct may configure sorting on one or both two levels: -```jsonc -[ - // Index signature - "signature", +- **`memberType`**: organizing on member type groups such as methods vs. properties +- **`order`**: organizing based on member names, such as alphabetically - // Fields - "field", +### Groups - // Constructors - "constructor", +You can define many different groups based on different attributes of members. +The supported member attributes are, in order: - // Getters and Setters at the same rank - ["get", "set"], +- **Accessibility** (`'public' | 'protected' | 'private'`) +- **Decoration** (`'decorated'`): Whether the member has an explicit accessibility decorator +- **Kind** (`'call-signature' | 'constructor' | 'field' | 'get' | 'method' | 'set' | 'signature'`) - // Methods - "method" -] -``` +Member attributes may be joined with a `'-'` to combine into more specific groups. +For example, `'public-field'` would come before `'private-field'`. ### Default configuration @@ -451,19 +191,39 @@ The default configuration looks as follows: } ``` -Note: The default configuration contains member group types which contain other member types (see above). This is intentional to provide better error messages. +:::note +The default configuration contains member group types which contain other member types. +This is intentional to provide better error messages. +::: -Note: By default, the members are not sorted. If you want to sort them alphabetically, you have to provide a custom configuration. +:::tip +By default, the members are not sorted. +If you want to sort them alphabetically, you have to provide a custom configuration. +::: ## Examples -### Custom `default` configuration +### General Order on All Constructs -Note: The `default` options are overwritten in these examples. +This config specifies the order for all constructs. +It ignores member types other than signatures, methods, constructors, and fields. +It also ignores accessibility and scope. + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "default": ["signature", "method", "constructor", "field"] } + ] + } +} +``` -#### Configuration: `{ "default": ["signature", "method", "constructor", "field"] }` + -##### Incorrect examples +#### ❌ Incorrect ```ts interface Foo { @@ -477,8 +237,6 @@ interface Foo { } ``` -Note: Wrong order. - ```ts type Foo = { B: string; // -> field @@ -491,8 +249,6 @@ type Foo = { }; ``` -Note: Not all specified member types have to exist. - ```ts class Foo { private C: string; // -> field @@ -508,8 +264,6 @@ class Foo { } ``` -Note: Accessibility or scope are ignored with this configuration. - ```ts const Foo = class { private C: string; // -> field @@ -526,9 +280,7 @@ const Foo = class { }; ``` -Note: Not all members have to be grouped to find rule violations. - -##### Correct examples +#### ✅ Correct ```ts interface Foo { @@ -584,11 +336,29 @@ const Foo = class { }; ``` -#### Configuration: `{ "default": ["public-instance-method", "public-static-field"] }` +### Classes + +#### Public Instance Methods Before Public Static Fields + +This config specifies that public instance methods should come first before public static fields. +Everything else can be placed anywhere. +It doesn't apply to interfaces or type literals as accessibility and scope are not part of them. + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "default": ["public-instance-method", "public-static-field"] } + ] + } +} +``` -Note: This configuration does not apply to interfaces/type literals as accessibility and scope are not part of interfaces/type literals. + -##### Incorrect examples +##### ❌ Incorrect ```ts class Foo { @@ -608,8 +378,6 @@ class Foo { } ``` -Note: Public instance methods should come first before public static fields. Everything else can be placed anywhere. - ```ts const Foo = class { private C: string; // (irrelevant) @@ -628,9 +396,7 @@ const Foo = class { }; ``` -Note: Public instance methods should come first before public static fields. Everything else can be placed anywhere. - -##### Correct examples +##### ✅ Correct ```ts class Foo { @@ -668,11 +434,25 @@ const Foo = class { }; ``` -#### Configuration: `{ "default": ["public-static-field", "static-field", "instance-field"] }` +#### Static Fields Before Instance Fields + +This config specifies that static fields should come before instance fields, with public static fields first. +It doesn't apply to interfaces or type literals as accessibility and scope are not part of them. + +```jsonc +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "default": ["public-static-field", "static-field", "instance-field"] } + ] + } +} +``` -Note: This configuration does not apply to interfaces/type literals as accessibility and scope are not part of interfaces/type literals. + -##### Incorrect examples +##### ❌ Incorrect ```ts class Foo { @@ -688,30 +468,26 @@ class Foo { } ``` -Note: Public static fields should come first, followed by static fields and instance fields. - ```ts const foo = class { - public T(): void {} // (irrelevant) + public T(): void {} // method (irrelevant) private static B: string; // -> static field - constructor() {} // (irrelevant) + constructor() {} // constructor (irrelevant) private E: string; // -> instance field protected static C: string; // -> static field private static D: string; // -> static field - [Z: string]: any; // (irrelevant) + [Z: string]: any; // signature (irrelevant) public static A: string; // -> public static field }; ``` -Note: Public static fields should come first, followed by static fields and instance fields. - -##### Correct examples +##### ✅ Correct ```ts class Foo { @@ -722,16 +498,18 @@ class Foo { private static D: string; // -> static field private E: string; // -> instance field + + [Z: string]: any; // (irrelevant) } ``` ```ts const foo = class { - [Z: string]: any; // -> signature + [Z: string]: any; // -> signature (irrelevant) public static A: string; // -> public static field - constructor() {} // -> constructor + constructor() {} // -> constructor (irrelevant) private static B: string; // -> static field protected static C: string; // -> static field @@ -739,19 +517,31 @@ const foo = class { private E: string; // -> instance field - public T(): void {} // -> method + public T(): void {} // -> method (irrelevant) }; ``` -### Custom `classes` configuration +#### Class Declarations -Note: If this is not set, the `default` will automatically be applied to classes as well. If a `classes` configuration is provided, only this configuration will be used for `classes` (i.e. nothing will be merged with `default`). +This config only specifies an order for classes: methods, then the constructor, then fields. +It does not apply to class expressions (use `classExpressions` for them). +Default settings will be used for class declarations and all other syntax constructs other than class declarations. -Note: The configuration for `classes` does not apply to class expressions (use `classExpressions` for them). +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "classes": ["method", "constructor", "field"] } + ] + } +} +``` -#### Configuration: `{ "classes": ["method", "constructor", "field"] }` + -##### Incorrect example +##### ❌ Incorrect ```ts class Foo { @@ -766,7 +556,7 @@ class Foo { } ``` -##### Correct example +##### ✅ Correct ```ts class Foo { @@ -781,333 +571,594 @@ class Foo { } ``` -#### Configuration: `{ "classes": ["public-instance-method", "public-static-field"] }` +#### Class Expressions + +This config only specifies an order for classes expressions: methods, then the constructor, then fields. +It does not apply to class declarations (use `classes` for them). +Default settings will be used for class declarations and all other syntax constructs other than class expressions. + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "classExpressions": ["method", "constructor", "field"] } + ] + } +} +``` + + -##### Incorrect example +##### ❌ Incorrect ```ts -class Foo { - private C: string; // (irrelevant) +const foo = class { + private C: string; // -> field + public D: string; // -> field + protected static E: string; // -> field - public D: string; // (irrelevant) + constructor() {} // -> constructor - public static E: string; // -> public static field + public static A(): void {} // -> method + public B(): void {} // -> method +}; +``` - constructor() {} // (irrelevant) +##### ✅ Correct - public static A(): void {} // (irrelevant) +```ts +const foo = class { + public static A(): void {} // -> method + public B(): void {} // -> method - public B(): void {} // -> public instance method + constructor() {} // -> constructor + + private C: string; // -> field + public D: string; // -> field + protected static E: string; // -> field +}; +``` + +### Interfaces + +This config only specifies an order for interfaces: signatures, then methods, then constructors, then fields. +It does not apply to type literals (use `typeLiterals` for them). +Default settings will be used for type literals and all other syntax constructs other than class expressions. + +:::note +These member types are the only ones allowed for `interfaces`. +::: + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "interfaces": ["signature", "method", "constructor", "field"] } + ] + } } ``` -##### Correct example + + +#### ❌ Incorrect ```ts -class Foo { - private C: string; // (irrelevant) +interface Foo { + B: string; // -> field - public D: string; // (irrelevant) + new (); // -> constructor - public B(): void {} // -> public instance method + A(): void; // -> method - constructor() {} // (irrelevant) + [Z: string]: any; // -> signature +} +``` - public static A(): void {} // (irrelevant) +#### ✅ Correct - public static E: string; // -> public static field +```ts +interface Foo { + [Z: string]: any; // -> signature + + A(): void; // -> method + + new (); // -> constructor + + B: string; // -> field } ``` -### Custom `classExpressions` configuration +### Type Literals -Note: If this is not set, the `default` will automatically be applied to classes expressions as well. If a `classExpressions` configuration is provided, only this configuration will be used for `classExpressions` (i.e. nothing will be merged with `default`). +This config only specifies an order for type literals: signatures, then methods, then constructors, then fields. +It does not apply to interfaces (use `interfaces` for them). +Default settings will be used for interfaces and all other syntax constructs other than class expressions. -Note: The configuration for `classExpressions` does not apply to classes (use `classes` for them). +:::note +These member types are the only ones allowed for `typeLiterals`. +::: + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "typeLiterals": ["signature", "method", "constructor", "field"] } + ] + } +} +``` -#### Configuration: `{ "classExpressions": ["method", "constructor", "field"] }` + -##### Incorrect example +#### ❌ Incorrect ```ts -const foo = class { - private C: string; // -> field - public D: string; // -> field - protected static E: string; // -> field +type Foo = { + B: string; // -> field - constructor() {} // -> constructor + A(): void; // -> method - public static A(): void {} // -> method - public B(): void {} // -> method + new (); // -> constructor + + [Z: string]: any; // -> signature }; ``` -##### Correct example +#### ✅ Correct ```ts -const foo = class { - public static A(): void {} // -> method - public B(): void {} // -> method +type Foo = { + [Z: string]: any; // -> signature - constructor() {} // -> constructor + A(): void; // -> method - private C: string; // -> field - public D: string; // -> field - protected static E: string; // -> field + new (); // -> constructor + + B: string; // -> field }; ``` -#### Configuration: `{ "classExpressions": ["public-instance-method", "public-static-field"] }` +### Sorting Options + +#### Sorting Alphabetically Within Member Groups + +This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order. +You can copy and paste the default order from [Default Configuration](#default-configuration). + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { + "default": { + "memberTypes": [ + /* */ + ], + "order": "alphabetically" + } + } + ] + } +} +``` + + -##### Incorrect example +##### ❌ Incorrect ```ts -const foo = class { - private C: string; // (irrelevant) +interface Foo { + a: x; + B: x; + c: x; - public D: string; // (irrelevant) + B(): void; + c(): void; + a(): void; +} +``` - public static E: string; // -> public static field +##### ✅ Correct - constructor() {} // (irrelevant) +```ts +interface Foo { + B: x; + a: x; + c: x; - public static A(): void {} // (irrelevant) + B(): void; + a(): void; + c(): void; +} +``` - public B(): void {} // -> public instance method -}; +#### Sorting Alphabetically Case Insensitive Within Member Groups + +This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order. +You can copy and paste the default order from [Default Configuration](#default-configuration). + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { + "default": { + "memberTypes": [ + /* */ + ], + "order": "alphabetically-case-insensitive" + } + } + ] + } +} ``` -##### Correct example + + +##### ❌ Incorrect ```ts -const foo = class { - private C: string; // (irrelevant) +interface Foo { + B: x; + a: x; + c: x; - public D: string; // (irrelevant) + B(): void; + c(): void; + a(): void; +} +``` - public B(): void {} // -> public instance method +##### ✅ Correct - public static E: string; // -> public static field +```ts +interface Foo { + a: x; + B: x; + c: x; - constructor() {} // (irrelevant) + a(): void; + B(): void; + c(): void; +} +``` - public static A(): void {} // (irrelevant) -}; +#### Sorting Alphabetically Ignoring Member Groups + +This config specifies that members are all sorted in an alphabetic case-sensitive order. +It ignores any member group types completely by specifying `"never"` for `memberTypes`. + +```jsonc +// .eslintrc.json +{ + "rules": { + "@typescript-eslint/no-non-null-assertion": [ + "error", + { "default": { "memberTypes": "never", "order": "alphabetically" } } + ] + } +} +``` + + + +##### ❌ Incorrect + +```ts +interface Foo { + static c = 0; + b(): void; + a: boolean; + + [a: string]: number; // Order doesn't matter (no sortable identifier) + new (): Bar; // Order doesn't matter (no sortable identifier) + (): Baz; // Order doesn't matter (no sortable identifier) +} +``` + +##### ✅ Correct + +```ts +interface Foo { + a: boolean; + b(): void; + static c = 0; + + [a: string]: number; // Order doesn't matter (no sortable identifier) + new (): Bar; // Order doesn't matter (no sortable identifier) + (): Baz; // Order doesn't matter (no sortable identifier) +} ``` -### Custom `interfaces` configuration +## All Supported Options + +### Member Types (Granular Form) -Note: If this is not set, the `default` will automatically be applied to classes expressions as well. If a `interfaces` configuration is provided, only this configuration will be used for `interfaces` (i.e. nothing will be merged with `default`). +There are multiple ways to specify the member types. +The most explicit and granular form is the following: + +```jsonc +[ + // Index signature + "signature", -Note: The configuration for `interfaces` only allows a limited set of member types: `signature`, `field`, `constructor` and `method`. + // Fields + "public-static-field", + "protected-static-field", + "private-static-field", + "public-decorated-field", + "protected-decorated-field", + "private-decorated-field", + "public-instance-field", + "protected-instance-field", + "private-instance-field", + "public-abstract-field", + "protected-abstract-field", + "private-abstract-field", -Note: The configuration for `interfaces` does not apply to type literals (use `typeLiterals` for them). + // Constructors + "public-constructor", + "protected-constructor", + "private-constructor", -#### Configuration: `{ "interfaces": ["signature", "method", "constructor", "field"] }` + // Getters + "public-static-get", + "protected-static-get", + "private-static-get", -##### Incorrect example + "public-decorated-get", + "protected-decorated-get", + "private-decorated-get", -```ts -interface Foo { - B: string; // -> field + "public-instance-get", + "protected-instance-get", + "private-instance-get", - new (); // -> constructor + "public-abstract-get", + "protected-abstract-get", + "private-abstract-get", - A(): void; // -> method + "public-get", + "protected-get", + "private-get", - [Z: string]: any; // -> signature -} -``` + "static-get", + "instance-get", + "abstract-get", -##### Correct example + "decorated-get", -```ts -interface Foo { - [Z: string]: any; // -> signature + "get", - A(): void; // -> method + // Setters + "public-static-set", + "protected-static-set", + "private-static-set", - new (); // -> constructor + "public-decorated-set", + "protected-decorated-set", + "private-decorated-set", - B: string; // -> field -} -``` + "public-instance-set", + "protected-instance-set", + "private-instance-set", -### Custom `typeLiterals` configuration + "public-abstract-set", + "protected-abstract-set", + "private-abstract-set", -Note: If this is not set, the `default` will automatically be applied to classes expressions as well. If a `typeLiterals` configuration is provided, only this configuration will be used for `typeLiterals` (i.e. nothing will be merged with `default`). + "public-set", + "protected-set", + "private-set", -Note: The configuration for `typeLiterals` only allows a limited set of member types: `signature`, `field`, `constructor` and `method`. + "static-set", + "instance-set", + "abstract-set", -Note: The configuration for `typeLiterals` does not apply to interfaces (use `interfaces` for them). + "decorated-set", -#### Configuration: `{ "typeLiterals": ["signature", "method", "constructor", "field"] }` + "set", -##### Incorrect example + // Methods + "public-static-method", + "protected-static-method", + "private-static-method", + "public-decorated-method", + "protected-decorated-method", + "private-decorated-method", + "public-instance-method", + "protected-instance-method", + "private-instance-method", + "public-abstract-method", + "protected-abstract-method", + "private-abstract-method" +] +``` -```ts -type Foo = { - B: string; // -> field +:::note +If you only specify some of the possible types, the non-specified ones can have any particular order. +This means that they can be placed before, within or after the specified types and the linter won't complain about it. +::: - A(): void; // -> method +### Member Group Types (With Accessibility, Ignoring Scope) - new (); // -> constructor +It is also possible to group member types by their accessibility (`static`, `instance`, `abstract`), ignoring their scope. - [Z: string]: any; // -> signature -}; -``` +```jsonc +[ + // Index signature + // No accessibility for index signature. -##### Correct example + // Fields + "public-field", // = ["public-static-field", "public-instance-field"] + "protected-field", // = ["protected-static-field", "protected-instance-field"] + "private-field", // = ["private-static-field", "private-instance-field"] -```ts -type Foo = { - [Z: string]: any; // -> signature + // Constructors + // Only the accessibility of constructors is configurable. See below. - A(): void; // -> method + // Getters + "public-get", // = ["public-static-get", "public-instance-get"] + "protected-get", // = ["protected-static-get", "protected-instance-get"] + "private-get", // = ["private-static-get", "private-instance-get"] - new (); // -> constructor + // Setters + "public-set", // = ["public-static-set", "public-instance-set"] + "protected-set", // = ["protected-static-set", "protected-instance-set"] + "private-set", // = ["private-static-set", "private-instance-set"] - B: string; // -> field -}; + // Methods + "public-method", // = ["public-static-method", "public-instance-method"] + "protected-method", // = ["protected-static-method", "protected-instance-method"] + "private-method" // = ["private-static-method", "private-instance-method"] +] ``` -### Sorting alphabetically within member groups - -It is possible to sort all members within a group alphabetically. +### Member Group Types (With Accessibility and a Decorator) -#### Configuration: `{ "default": { "memberTypes": , "order": "alphabetically" } }` +It is also possible to group methods or fields with a decorator separately, optionally specifying +their accessibility. -This will apply the default order (see above) and enforce an alphabetic case-sensitive order within each group. +```jsonc +[ + // Index signature + // No decorators for index signature. -##### Incorrect examples + // Fields + "public-decorated-field", + "protected-decorated-field", + "private-decorated-field", -```ts -interface Foo { - B: x; - a: x; - c: x; + "decorated-field", // = ["public-decorated-field", "protected-decorated-field", "private-decorated-field"] - new (): Bar; - (): Baz; + // Constructors + // There are no decorators for constructors. - B(): void; - a(): void; - c(): void; + // Getters + "public-decorated-get", + "protected-decorated-get", + "private-decorated-get", - // Wrong group order, should be placed before all field definitions - [a: string]: number; -} -``` + "decorated-get" // = ["public-decorated-get", "protected-decorated-get", "private-decorated-get"] -```ts -interface Foo { - [a: string]: number; + // Setters + "public-decorated-set", + "protected-decorated-set", + "private-decorated-set", - B: x; - a: x; - c: x; + "decorated-set" // = ["public-decorated-set", "protected-decorated-set", "private-decorated-set"] - new (): Bar; - (): Baz; + // Methods + "public-decorated-method", + "protected-decorated-method", + "private-decorated-method", - // Wrong alphabetic order within group - c(): void; - B(): void; - a(): void; -} + "decorated-method" // = ["public-decorated-method", "protected-decorated-method", "private-decorated-method"] +] ``` -### Sorting alphabetically while ignoring member groups +### Member Group Types (With Scope, Ignoring Accessibility) -It is also possible to sort all members and ignore the member groups completely. +Another option is to group the member types by their scope (`public`, `protected`, `private`), ignoring their accessibility. -#### Configuration: `{ "default": { "memberTypes": "never", "order": "alphabetically" } }` +```jsonc +[ + // Index signature + // No scope for index signature. -##### Incorrect example + // Fields + "static-field", // = ["public-static-field", "protected-static-field", "private-static-field"] + "instance-field", // = ["public-instance-field", "protected-instance-field", "private-instance-field"] + "abstract-field", // = ["public-abstract-field", "protected-abstract-field", "private-abstract-field"] -```ts -interface Foo { - b(): void; - a: b; + // Constructors + "constructor", // = ["public-constructor", "protected-constructor", "private-constructor"] - [a: string]: number; // Order doesn't matter (no sortable identifier) - new (): Bar; // Order doesn't matter (no sortable identifier) - (): Baz; // Order doesn't matter (no sortable identifier) -} -``` + // Getters + "static-get", // = ["public-static-get", "protected-static-get", "private-static-get"] + "instance-get", // = ["public-instance-get", "protected-instance-get", "private-instance-get"] + "abstract-get" // = ["public-abstract-get", "protected-abstract-get", "private-abstract-get"] -Note: Wrong alphabetic order `b(): void` should come after `a: b`. + // Setters + "static-set", // = ["public-static-set", "protected-static-set", "private-static-set"] + "instance-set", // = ["public-instance-set", "protected-instance-set", "private-instance-set"] + "abstract-set" // = ["public-abstract-set", "protected-abstract-set", "private-abstract-set"] -### Sorting alphabetically case-insensitive within member groups + // Methods + "static-method", // = ["public-static-method", "protected-static-method", "private-static-method"] + "instance-method", // = ["public-instance-method", "protected-instance-method", "private-instance-method"] + "abstract-method" // = ["public-abstract-method", "protected-abstract-method", "private-abstract-method"] +] +``` -It is possible to sort all members within a group alphabetically with case insensitivity. +### Member Group Types (With Scope and Accessibility) -#### Configuration: `{ "default": { "memberTypes": , "order": "alphabetically-case-insensitive" } }` +The third grouping option is to ignore both scope and accessibility. -This will apply the default order (see above) and enforce an alphabetic case-insensitive order within each group. +```jsonc +[ + // Index signature + // No grouping for index signature. -##### Incorrect examples + // Fields + "field", // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field", + // "public-abstract-field", "protected-abstract-field", private-abstract-field"] -```ts -interface Foo { - a: x; - B: x; - c: x; + // Constructors + // Only the accessibility of constructors is configurable. - new (): Bar; - (): Baz; + // Getters + "get" // = ["public-static-get", "protected-static-get", "private-static-get", "public-instance-get", "protected-instance-get", "private-instance-get", + // "public-abstract-get", "protected-abstract-get", "private-abstract-get"] - a(): void; - b(): void; - C(): void; + // Setters + "set" // = ["public-static-set", "protected-static-set", "private-static-set", "public-instance-set", "protected-instance-set", "private-instance-set", + // "public-abstract-set", "protected-abstract-set", "private-abstract-set"] - // Wrong group order, should be placed before all field definitions - [a: string]: number; -} + // Methods + "method" // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method", + // "public-abstract-method", "protected-abstract-method", "private-abstract-method"] +] ``` -```ts -interface Foo { - [a: string]: number; - - a: x; - B: x; - c: x; - - new (): Bar; - (): Baz; - - // Wrong alphabetic order within group - C(): void; - b(): void; - a(): void; -} -``` +### Grouping Different Member Types at the Same Rank -### Sorting alphabetically case-insensitive while ignoring member groups +It is also possible to group different member types at the same rank. -It is also possible to sort all members with case insensitivity and ignore the member groups completely. +```jsonc +[ + // Index signature + "signature", -#### Configuration: `{ "default": { "memberTypes": "never", "order": "alphabetically-case-insensitive" } }` + // Fields + "field", -##### Incorrect example + // Constructors + "constructor", -```ts -interface Foo { - B(): void; - a: number; + // Getters and Setters at the same rank + ["get", "set"], - [a: string]: number; // Order doesn't matter (no sortable identifier) - new (): Bar; // Order doesn't matter (no sortable identifier) - (): Baz; // Order doesn't matter (no sortable identifier) -} + // Methods + "method" +] ``` -Note: Wrong alphabetic order `B(): void` should come after `a: number`. - ## When Not To Use It -If you don't care about the general structure of your classes and interfaces, then you will not need this rule. +If you don't care about the general order of your members, then you will not need this rule. ## Related To diff --git a/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md new file mode 100644 index 000000000000..2146d6039803 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/no-duplicate-enum-values.md @@ -0,0 +1,51 @@ +# `no-duplicate-enum-values` + +Disallow duplicate enum member values. + +Although TypeScript supports duplicate enum member values, people usually expect members to have unique values within the same enum. Duplicate values can lead to bugs that are hard to track down. + +## Rule Details + +This rule disallows defining an enum with multiple members initialized to the same value. Now it only enforces on enum members initialized with String or Number literals. Members without initializer or initialized with an expression are not checked by this rule. + + + +### ❌ Incorrect + +```ts +enum E { + A = 0, + B = 0, +} +``` + +```ts +enum E { + A = 'A' + B = 'A' +} +``` + +### ✅ Correct + +```ts +enum E { + A = 0, + B = 1, +} +``` + +```ts +enum E { + A = 'A' + B = 'B' +} +``` + +This rule is not configurable. + +## Attributes + +- [ ] ✅ Recommended +- [ ] 🔧 Fixable +- [ ] 💭 Requires type information diff --git a/packages/eslint-plugin/docs/rules/parameter-properties.md b/packages/eslint-plugin/docs/rules/parameter-properties.md index 0974300bce3d..55320177c0a3 100644 --- a/packages/eslint-plugin/docs/rules/parameter-properties.md +++ b/packages/eslint-plugin/docs/rules/parameter-properties.md @@ -15,10 +15,10 @@ declare all properties in the class. This rule, in its default state, does not require any argument and would completely disallow the use of parameter properties. It may take an options object containing either or both of: -- `"allows"`: allowing certain kinds of properties to be ignored -- `"prefer"`: either `"class-properties"` _(default)_ or `"parameter-properties"` +- `"allow"`: allowing certain kinds of properties to be ignored +- `"prefer"`: either `"class-property"` _(default)_ or `"parameter-property"` -### `"allows"` +### `"allow"` If you would like to ignore certain kinds of properties then you may pass an object containing `"allows"` as an array of any of the following options: @@ -46,10 +46,10 @@ For example, to ignore `public` properties: ### `"prefer"` -By default, the rule prefers class properties (`"class-properties"`). -You can switch it to instead preferring parameter properties with (`"parameter-properties"`). +By default, the rule prefers class property (`"class-property"`). +You can switch it to instead preferring parameter property with (`"parameter-property"`). -In `"parameter-properties"` mode, the rule will issue a report when: +In `"parameter-property"` mode, the rule will issue a report when: - A class property and constructor parameter have the same name and type - The constructor parameter is assigned to the class property at the beginning of the constructor diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md index 0446c34de46c..a50fdc4fb84d 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md @@ -234,7 +234,7 @@ export const acceptsCallback: AcceptsCallback; ### `treatMethodsAsReadonly` -This option allows you to treat all mutable methods as though they were readonly. This may be desirable in when you are never reassigning methods. +This option allows you to treat all mutable methods as though they were readonly. This may be desirable when you are never reassigning methods. Examples of code for this rule with `{treatMethodsAsReadonly: false}`: diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index b32bfd51d988..9d9b76a75135 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.21.0", + "version": "5.22.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/type-utils": "5.21.0", - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/type-utils": "5.22.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index c55e0e6ac37a..b3adbd1a3ac7 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -21,8 +21,8 @@ export = { '@typescript-eslint/consistent-indexed-object-style': 'error', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/consistent-type-definitions': 'error', - '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/consistent-type-exports': 'error', + '@typescript-eslint/consistent-type-imports': 'error', 'default-param-last': 'off', '@typescript-eslint/default-param-last': 'error', 'dot-notation': 'off', @@ -51,6 +51,7 @@ export = { '@typescript-eslint/no-confusing-void-expression': 'error', 'no-dupe-class-members': 'off', '@typescript-eslint/no-dupe-class-members': 'error', + '@typescript-eslint/no-duplicate-enum-values': 'error', 'no-duplicate-imports': 'off', '@typescript-eslint/no-duplicate-imports': 'error', '@typescript-eslint/no-dynamic-delete': 'error', @@ -115,9 +116,9 @@ export = { '@typescript-eslint/no-unused-vars': 'error', 'no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': 'error', - '@typescript-eslint/no-useless-empty-export': 'error', 'no-useless-constructor': 'off', '@typescript-eslint/no-useless-constructor': 'error', + '@typescript-eslint/no-useless-empty-export': 'error', '@typescript-eslint/no-var-requires': 'error', '@typescript-eslint/non-nullable-type-assertion-style': 'error', 'object-curly-spacing': 'off', @@ -153,12 +154,12 @@ export = { semi: 'off', '@typescript-eslint/semi': 'error', '@typescript-eslint/sort-type-union-intersection-members': 'error', + 'space-before-blocks': 'off', + '@typescript-eslint/space-before-blocks': 'error', 'space-before-function-paren': 'off', '@typescript-eslint/space-before-function-paren': 'error', 'space-infix-ops': 'off', '@typescript-eslint/space-infix-ops': 'error', - 'space-before-blocks': 'off', - '@typescript-eslint/space-before-blocks': 'error', '@typescript-eslint/strict-boolean-expressions': 'error', '@typescript-eslint/switch-exhaustiveness-check': 'error', '@typescript-eslint/triple-slash-reference': 'error', diff --git a/packages/eslint-plugin/src/rules/comma-spacing.ts b/packages/eslint-plugin/src/rules/comma-spacing.ts index 2774324d259b..336017db1b37 100644 --- a/packages/eslint-plugin/src/rules/comma-spacing.ts +++ b/packages/eslint-plugin/src/rules/comma-spacing.ts @@ -177,7 +177,7 @@ export default createRule({ isCommaToken(prevToken) || ignoredTokens.has(token) ? null : prevToken, - isCommaToken(nextToken) || ignoredTokens.has(token) + (nextToken && isCommaToken(nextToken)) || ignoredTokens.has(token) ? null : nextToken, ); diff --git a/packages/eslint-plugin/src/rules/index.ts b/packages/eslint-plugin/src/rules/index.ts index fb48ee5cadc2..41afc88199f2 100644 --- a/packages/eslint-plugin/src/rules/index.ts +++ b/packages/eslint-plugin/src/rules/index.ts @@ -32,6 +32,7 @@ import noBaseToString from './no-base-to-string'; import confusingNonNullAssertionLikeNotEqual from './no-confusing-non-null-assertion'; import noConfusingVoidExpression from './no-confusing-void-expression'; import noDupeClassMembers from './no-dupe-class-members'; +import noDuplicateEnumValues from './no-duplicate-enum-values'; import noDuplicateImports from './no-duplicate-imports'; import noDynamicDelete from './no-dynamic-delete'; import noEmptyFunction from './no-empty-function'; @@ -159,6 +160,7 @@ export default { 'no-confusing-non-null-assertion': confusingNonNullAssertionLikeNotEqual, 'no-confusing-void-expression': noConfusingVoidExpression, 'no-dupe-class-members': noDupeClassMembers, + 'no-duplicate-enum-values': noDuplicateEnumValues, 'no-duplicate-imports': noDuplicateImports, 'no-dynamic-delete': noDynamicDelete, 'no-empty-function': noEmptyFunction, diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 8c423b2f1044..4ddb49545933 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -8,13 +8,36 @@ import * as util from '../util'; export type MessageIds = 'incorrectGroupOrder' | 'incorrectOrder'; +type MemberKind = + | 'call-signature' + | 'constructor' + | 'field' + | 'get' + | 'method' + | 'set' + | 'signature'; + +type DecoratedMemberKind = 'field' | 'method' | 'get' | 'set'; + +type NonCallableMemberKind = Exclude; + +type MemberScope = 'static' | 'instance' | 'abstract'; + +type BaseMemberType = + | MemberKind + | `${TSESTree.Accessibility}-${Exclude}` + | `${TSESTree.Accessibility}-decorated-${DecoratedMemberKind}` + | `decorated-${DecoratedMemberKind}` + | `${TSESTree.Accessibility}-${MemberScope}-${NonCallableMemberKind}` + | `${MemberScope}-${NonCallableMemberKind}`; + +type MemberType = BaseMemberType | BaseMemberType[]; + type Order = | 'alphabetically' | 'alphabetically-case-insensitive' | 'as-written'; -type MemberType = string | string[]; - interface SortedOrderConfig { memberTypes?: MemberType[] | 'never'; order: Order; @@ -69,7 +92,7 @@ const objectConfig = (memberTypes: MemberType[]): JSONSchema.JSONSchema4 => ({ additionalProperties: false, }); -export const defaultOrder = [ +export const defaultOrder: MemberType[] = [ // Index signature 'signature', 'call-signature', @@ -198,53 +221,48 @@ export const defaultOrder = [ 'method', ]; -const allMemberTypes = [ - 'signature', - 'field', - 'method', - 'call-signature', - 'constructor', - 'get', - 'set', -].reduce((all, type) => { - all.push(type); - - ['public', 'protected', 'private'].forEach(accessibility => { - if (type !== 'signature') { - all.push(`${accessibility}-${type}`); // e.g. `public-field` - } - - // Only class instance fields, methods, get and set can have decorators attached to them - if ( - type === 'field' || - type === 'method' || - type === 'get' || - type === 'set' - ) { - const decoratedMemberType = `${accessibility}-decorated-${type}`; - const decoratedMemberTypeNoAccessibility = `decorated-${type}`; - if (!all.includes(decoratedMemberType)) { - all.push(decoratedMemberType); +const allMemberTypes = Array.from( + ( + [ + 'signature', + 'field', + 'method', + 'call-signature', + 'constructor', + 'get', + 'set', + ] as const + ).reduce>((all, type) => { + all.add(type); + + (['public', 'protected', 'private'] as const).forEach(accessibility => { + if (type !== 'signature') { + all.add(`${accessibility}-${type}`); // e.g. `public-field` } - if (!all.includes(decoratedMemberTypeNoAccessibility)) { - all.push(decoratedMemberTypeNoAccessibility); - } - } - if (type !== 'constructor' && type !== 'signature') { - // There is no `static-constructor` or `instance-constructor` or `abstract-constructor` - ['static', 'instance', 'abstract'].forEach(scope => { - if (!all.includes(`${scope}-${type}`)) { - all.push(`${scope}-${type}`); - } + // Only class instance fields, methods, get and set can have decorators attached to them + if ( + type === 'field' || + type === 'method' || + type === 'get' || + type === 'set' + ) { + all.add(`${accessibility}-decorated-${type}`); + all.add(`decorated-${type}`); + } - all.push(`${accessibility}-${scope}-${type}`); - }); - } - }); + if (type !== 'constructor' && type !== 'signature') { + // There is no `static-constructor` or `instance-constructor` or `abstract-constructor` + (['static', 'instance', 'abstract'] as const).forEach(scope => { + all.add(`${scope}-${type}`); + all.add(`${accessibility}-${scope}-${type}`); + }); + } + }); - return all; -}, []); + return all; + }, new Set()), +); const functionExpressions = [ AST_NODE_TYPES.FunctionExpression, @@ -256,7 +274,7 @@ const functionExpressions = [ * * @param node the node to be evaluated. */ -function getNodeType(node: Member): string | null { +function getNodeType(node: Member): MemberKind | null { switch (node.type) { case AST_NODE_TYPES.TSAbstractMethodDefinition: case AST_NODE_TYPES.MethodDefinition: @@ -352,7 +370,7 @@ function getMemberName( * @return Index of the matching member type in the order configuration. */ function getRankOrder( - memberGroups: string[], + memberGroups: BaseMemberType[], orderConfig: MemberType[], ): number { let rank = -1; @@ -403,8 +421,9 @@ function getRank( ? node.accessibility : 'public'; - // Collect all existing member groups (e.g. 'public-instance-field', 'instance-field', 'public-field', 'constructor' etc.) - const memberGroups = []; + // Collect all existing member groups that apply to this node... + // (e.g. 'public-instance-field', 'instance-field', 'public-field', 'constructor' etc.) + const memberGroups: BaseMemberType[] = []; if (supportsModifiers) { const decorated = 'decorators' in node && node.decorators!.length > 0; @@ -419,17 +438,20 @@ function getRank( memberGroups.push(`decorated-${type}`); } - if (type !== 'constructor') { - // Constructors have no scope - memberGroups.push(`${accessibility}-${scope}-${type}`); - memberGroups.push(`${scope}-${type}`); - } + if (type !== 'signature') { + if (type !== 'constructor') { + // Constructors have no scope + memberGroups.push(`${accessibility}-${scope}-${type}`); + memberGroups.push(`${scope}-${type}`); + } - memberGroups.push(`${accessibility}-${type}`); + memberGroups.push(`${accessibility}-${type}`); + } } memberGroups.push(type); + // ...then get the rank order for those member groups based on the node return getRankOrder(memberGroups, orderConfig); } diff --git a/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts b/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts new file mode 100644 index 000000000000..3ede60b9fc37 --- /dev/null +++ b/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts @@ -0,0 +1,72 @@ +import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils'; +import * as util from '../util'; + +export default util.createRule({ + name: 'no-duplicate-enum-values', + meta: { + type: 'problem', + docs: { + description: 'Disallow duplicate enum member values', + recommended: false, + }, + hasSuggestions: true, + messages: { + duplicateValue: 'Duplicate enum member value {{value}}.', + }, + schema: [], + }, + defaultOptions: [], + create(context) { + function isStringLiteral( + node: TSESTree.Expression, + ): node is TSESTree.StringLiteral { + return ( + node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string' + ); + } + + function isNumberLiteral( + node: TSESTree.Expression, + ): node is TSESTree.NumberLiteral { + return ( + node.type === AST_NODE_TYPES.Literal && typeof node.value === 'number' + ); + } + + return { + TSEnumDeclaration(node: TSESTree.TSEnumDeclaration): void { + const enumMembers = node.members; + const seenValues = new Set(); + + enumMembers.forEach(member => { + if (member.initializer === undefined) { + return; + } + + let value: string | number | undefined; + if (isStringLiteral(member.initializer)) { + value = String(member.initializer.value); + } else if (isNumberLiteral(member.initializer)) { + value = Number(member.initializer.value); + } + + if (value === undefined) { + return; + } + + if (seenValues.has(value)) { + context.report({ + node: member, + messageId: 'duplicateValue', + data: { + value, + }, + }); + } else { + seenValues.add(value); + } + }); + }, + }; + }, +}); diff --git a/packages/eslint-plugin/tests/rules/comma-spacing.test.ts b/packages/eslint-plugin/tests/rules/comma-spacing.test.ts index 9ab7def96d97..37eb6e2e3adc 100644 --- a/packages/eslint-plugin/tests/rules/comma-spacing.test.ts +++ b/packages/eslint-plugin/tests/rules/comma-spacing.test.ts @@ -281,6 +281,7 @@ ruleTester.run('comma-spacing', rule, { 'class Foo {}', 'interface Foo{}', 'interface A<> {}', + 'let foo,', ], invalid: [ @@ -787,5 +788,17 @@ ruleTester.run('comma-spacing', rule, { }, ], }, + { + code: 'let foo ,', + output: 'let foo,', + errors: [ + { + messageId: 'unexpected', + column: 9, + line: 1, + data: { loc: 'before' }, + }, + ], + }, ], }); diff --git a/packages/eslint-plugin/tests/rules/no-duplicate-enum-values.test.ts b/packages/eslint-plugin/tests/rules/no-duplicate-enum-values.test.ts new file mode 100644 index 000000000000..037579d12bba --- /dev/null +++ b/packages/eslint-plugin/tests/rules/no-duplicate-enum-values.test.ts @@ -0,0 +1,136 @@ +import rule from '../../src/rules/no-duplicate-enum-values'; +import { RuleTester } from '../RuleTester'; + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', +}); + +ruleTester.run('no-duplicate-enum-values', rule, { + valid: [ + ` +enum E { + A, + B, +} + `, + ` +enum E { + A = 1, + B, +} + `, + ` +enum E { + A = 1, + B = 2, +} + `, + ` +enum E { + A = 'A', + B = 'B', +} + `, + ` +enum E { + A = 'A', + B = 'B', + C, +} + `, + ` +enum E { + A = 'A', + B = 'B', + C = 2, + D = 1 + 1, +} + `, + ` +enum E { + A = 3, + B = 2, + C, +} + `, + ` +enum E { + A = 'A', + B = 'B', + C = 2, + D = foo(), +} + `, + ` +enum E { + A = '', + B = 0, +} + `, + ` +enum E { + A = 0, + B = -0, + C = NaN, +} + `, + ], + invalid: [ + { + code: ` +enum E { + A = 1, + B = 1, +} + `, + errors: [ + { + line: 4, + column: 3, + messageId: 'duplicateValue', + data: { value: 1 }, + }, + ], + }, + { + code: ` +enum E { + A = 'A', + B = 'A', +} + `, + errors: [ + { + line: 4, + column: 3, + messageId: 'duplicateValue', + data: { value: 'A' }, + }, + ], + }, + { + code: ` +enum E { + A = 'A', + B = 'A', + C = 1, + D = 1, +} + `, + errors: [ + { + line: 4, + column: 3, + messageId: 'duplicateValue', + data: { value: 'A' }, + }, + { + line: 6, + column: 3, + messageId: 'duplicateValue', + data: { value: 1 }, + }, + ], + }, + ], +}); diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 2e1f2ec28f1c..161881147694 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index a28a0be4c67a..c27cebbd9b7f 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.21.0", + "version": "5.22.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.21.0" + "@typescript-eslint/utils": "5.22.0" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index ac463d49436b..279aac74e2bd 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 12e53d98fe4f..1ee55272ea7f 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.21.0", + "version": "5.22.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,9 +44,9 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "debug": "^4.3.2" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 9bec3b8e353d..f9417b2d1dea 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Features + +* **ast-spec:** add fixture test framework and some initial fixtures ([#3258](https://github.com/typescript-eslint/typescript-eslint/issues/3258)) ([f3cf87b](https://github.com/typescript-eslint/typescript-eslint/commit/f3cf87bf20fd0542f92a96a318aa9ee5bf23c1f6)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 70be1bc08962..e68ebef742a2 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.21.0", + "version": "5.22.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -30,6 +30,7 @@ "scripts": { "build": "cd ../../ && nx build @typescript-eslint/scope-manager", "clean": "cd ../../ && nx clean @typescript-eslint/scope-manager", + "clean-fixtures": "cd ../../ && nx clean-fixtures @typescript-eslint/scope-manager", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", "generate:lib": "cd ../../ && nx generate-lib @typescript-eslint/scope-manager", "lint": "cd ../../ && nx lint @typescript-eslint/scope-manager", @@ -37,12 +38,12 @@ "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, "dependencies": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0" + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/typescript-estree": "5.22.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/scope-manager/project.json b/packages/scope-manager/project.json index 71a628c64aab..f60c2fd75a92 100644 --- a/packages/scope-manager/project.json +++ b/packages/scope-manager/project.json @@ -43,6 +43,16 @@ ] } }, + "clean-fixtures": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "parallel": false, + "cwd": "packages/scope-manager", + "commands": [ + "rimraf -g \"./src/**/fixtures/**/snapshots\"" + ] + } + }, "lint": { "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], diff --git a/packages/scope-manager/tests/fixtures.test.ts b/packages/scope-manager/tests/fixtures.test.ts index b504710c4cfd..f029367ba06e 100644 --- a/packages/scope-manager/tests/fixtures.test.ts +++ b/packages/scope-manager/tests/fixtures.test.ts @@ -185,7 +185,7 @@ if (ONLY === '') { describe('ast snapshots should have an associated test', () => { for (const snap of snapshots) { it(snap.relative, () => { - fs.existsSync(snap.fixturePath); + expect(fs.existsSync(snap.fixturePath)).toBeTruthy(); }); } }); diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 17b2797a5aa6..309bd93f16d4 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index afeaa54ddd2a..23c21b5205d7 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.21.0", + "version": "5.22.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 401678683066..abab1673fda2 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/type-utils + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/type-utils diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index 993052441c0f..f7765c3ecb5a 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.21.0", + "version": "5.22.0", "description": "Type utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.21.0", + "@typescript-eslint/utils": "5.22.0", "debug": "^4.3.2", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.21.0", + "@typescript-eslint/parser": "5.22.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 1f4dfaf3512c..1a134a90d6ca 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Features + +* **ast-spec:** add fixture test framework and some initial fixtures ([#3258](https://github.com/typescript-eslint/typescript-eslint/issues/3258)) ([f3cf87b](https://github.com/typescript-eslint/typescript-eslint/commit/f3cf87bf20fd0542f92a96a318aa9ee5bf23c1f6)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 8f2d2c4d3b4b..9dad30757a52 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.21.0", + "version": "5.22.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/types/tools/copy-ast-spec.ts b/packages/types/tools/copy-ast-spec.ts index bd1a0b1120ca..8b7848d9a71e 100644 --- a/packages/types/tools/copy-ast-spec.ts +++ b/packages/types/tools/copy-ast-spec.ts @@ -1,11 +1,28 @@ -import chlidProcess from 'child_process'; +import childProcess from 'child_process'; import fs from 'fs'; import path from 'path'; import { promisify } from 'util'; const readFile = promisify(fs.readFile); const writeFile = promisify(fs.writeFile); -const execAsync = promisify(chlidProcess.exec); + +// the promisify util will eat the stderr logs +async function execAsync( + command: string, + args: ReadonlyArray, + options: childProcess.SpawnOptions, +): Promise { + return new Promise((resolve, reject) => { + const child = childProcess.spawn(command, args, { + ...options, + stdio: 'inherit', + }); + + child.on('error', e => reject(e)); + child.on('exit', () => resolve()); + child.on('close', () => resolve()); + }); +} const AST_SPEC_PATH = path.resolve(__dirname, '../../ast-spec'); const OUTPUT_PATH = path.join(path.resolve(__dirname, '../src/generated')); @@ -43,12 +60,15 @@ async function copyFile( encoding: 'utf-8', }); - await execAsync(`yarn prettier --write ${outpath}`); + await execAsync('yarn', ['prettier', '--write', outpath], {}); console.log('Copied', fileName); } async function main(): Promise { + // ensure the package is built + await execAsync('yarn', ['build'], { cwd: AST_SPEC_PATH }); + await Promise.all([ copyFile('dist', 'ast-spec.ts', code => code.replace(/export declare enum/g, 'export enum'), diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index b973417ee5fa..874d89e5a1e4 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index b499a4c4f9c4..19a6891b91a5 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.21.0", + "version": "5.22.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -58,7 +58,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "5.21.0", + "@typescript-eslint/shared-fixtures": "5.22.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 50842c31a066..6c9fe9f41e85 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/utils + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 570588b4bd86..dd54badb428d 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.21.0", + "version": "5.22.0", "description": "Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 60329890bea8..e5e7ce3f401c 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + + +### Features + +* **ast-spec:** add fixture test framework and some initial fixtures ([#3258](https://github.com/typescript-eslint/typescript-eslint/issues/3258)) ([f3cf87b](https://github.com/typescript-eslint/typescript-eslint/commit/f3cf87bf20fd0542f92a96a318aa9ee5bf23c1f6)) + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index c22a67b9ce57..ea7a6690dc62 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.21.0", + "version": "5.22.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.21.0", + "@typescript-eslint/types": "5.22.0", "eslint-visitor-keys": "^3.0.0" }, "devDependencies": { diff --git a/packages/visitor-keys/tests/visitor-keys.test.ts b/packages/visitor-keys/tests/visitor-keys.test.ts index a6fe66bc5408..ca727a5de335 100644 --- a/packages/visitor-keys/tests/visitor-keys.test.ts +++ b/packages/visitor-keys/tests/visitor-keys.test.ts @@ -20,6 +20,11 @@ const IGNORED_KEYS = new Set([ describe('Every visitor key should have an ast node type defined', () => { for (const key of keys) { if (IGNORED_KEYS.has(key)) { + if (types.has(key)) { + it(`${key} should not be ignored as it has an AST_NODE_TYPE defined`, () => { + expect(true).toBeFalsy(); + }); + } continue; } diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 2fd9cf6831ac..98c1f2e92683 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package @typescript-eslint/website-eslint diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json index 0a7ad8423c23..65d39777a5f7 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.21.0", + "version": "5.22.0", "private": true, "description": "ESLint which works in browsers.", "engines": { @@ -16,19 +16,19 @@ "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore" }, "dependencies": { - "@typescript-eslint/types": "5.21.0", - "@typescript-eslint/utils": "5.21.0" + "@typescript-eslint/types": "5.22.0", + "@typescript-eslint/utils": "5.22.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/pluginutils": "^4.2.0", - "@typescript-eslint/eslint-plugin": "5.21.0", - "@typescript-eslint/parser": "5.21.0", - "@typescript-eslint/scope-manager": "5.21.0", - "@typescript-eslint/typescript-estree": "5.21.0", - "@typescript-eslint/visitor-keys": "5.21.0", + "@typescript-eslint/eslint-plugin": "5.22.0", + "@typescript-eslint/parser": "5.22.0", + "@typescript-eslint/scope-manager": "5.22.0", + "@typescript-eslint/typescript-estree": "5.22.0", + "@typescript-eslint/visitor-keys": "5.22.0", "eslint": "*", "rollup": "^2.59.0", "semver": "^7.3.5" diff --git a/packages/website/CHANGELOG.md b/packages/website/CHANGELOG.md index 763d1817b34d..19a5c4d00648 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.21.0...v5.22.0) (2022-05-02) + +**Note:** Version bump only for package website + + + + + # [5.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.20.0...v5.21.0) (2022-04-25) **Note:** Version bump only for package website diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index 42de64539f59..0b0b20788d13 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -4,7 +4,7 @@ "image": "https://images.opencollective.com/nx/0efbe42/logo.png", "name": "Nx (by Nrwl)", "tier": "sponsor", - "totalDonations": 375000, + "totalDonations": 400000, "website": "https://nx.dev" }, { @@ -12,7 +12,7 @@ "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", "name": "ESLint", "tier": "sponsor", - "totalDonations": 110000, + "totalDonations": 125000, "website": "https://eslint.org/" }, { @@ -20,7 +20,7 @@ "image": "https://images.opencollective.com/airbnb/d327d66/logo.png", "name": "Airbnb", "tier": "sponsor", - "totalDonations": 105800, + "totalDonations": 110800, "website": "https://www.airbnb.com/" }, { @@ -31,6 +31,14 @@ "totalDonations": 100000, "website": "https://blog.coinbase.com/engineering-and-security/home" }, + { + "id": "n8n.io - n8n GmbH", + "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", + "name": "n8n.io - n8n GmbH", + "tier": "sponsor", + "totalDonations": 85000, + "website": "https://n8n.io" + }, { "id": "EY Doberman", "image": "https://images.opencollective.com/ey-doberman/b269462/logo.png", @@ -39,14 +47,6 @@ "totalDonations": 80400, "website": "https://doberman.co" }, - { - "id": "n8n.io - n8n GmbH", - "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", - "name": "n8n.io - n8n GmbH", - "tier": "sponsor", - "totalDonations": 80000, - "website": "https://n8n.io" - }, { "id": "Future Processing", "image": "https://images.opencollective.com/future-processing/1410d26/logo.png", @@ -63,6 +63,14 @@ "totalDonations": 50000, "website": "https://sentry.io/welcome/" }, + { + "id": "GitBook", + "image": "https://images.opencollective.com/gitbook/d35a8e7/logo.png", + "name": "GitBook", + "tier": "sponsor", + "totalDonations": 50000, + "website": "https://www.gitbook.com" + }, { "id": "Whitebox", "image": "https://images.opencollective.com/whiteboxinc/ef0d11d/logo.png", @@ -71,20 +79,12 @@ "totalDonations": 40000, "website": "https://whitebox.com" }, - { - "id": "GitBook", - "image": "https://images.opencollective.com/gitbook/d35a8e7/logo.png", - "name": "GitBook", - "tier": "sponsor", - "totalDonations": 40000, - "website": "https://www.gitbook.com" - }, { "id": "Codecademy", "image": "https://images.opencollective.com/codecademy/d56a48d/logo.png", "name": "Codecademy", "tier": "sponsor", - "totalDonations": 30000, + "totalDonations": 40000, "website": "https://codecademy.com" }, { @@ -92,7 +92,7 @@ "image": "https://images.opencollective.com/monito/50fc878/logo.png", "name": "Monito", "tier": "supporter", - "totalDonations": 27500, + "totalDonations": 30000, "website": "https://www.monito.com" }, { @@ -116,7 +116,7 @@ "image": "https://images.opencollective.com/storis/dfb0e13/logo.png", "name": "STORIS", "tier": "supporter", - "totalDonations": 16500, + "totalDonations": 18000, "website": "https://www.storis.com/" }, { @@ -124,7 +124,7 @@ "image": "https://images.opencollective.com/michael-ranciglio/avatar.png", "name": "Michael Ranciglio", "tier": "supporter", - "totalDonations": 15000 + "totalDonations": 15500 }, { "id": "Joe Alden", @@ -139,7 +139,7 @@ "image": "https://images.opencollective.com/blacksheepcode/976d69a/avatar.png", "name": "David Johnston", "tier": "supporter", - "totalDonations": 11500, + "totalDonations": 12000, "website": "https://blacksheepcode.com" }, { @@ -163,7 +163,7 @@ "image": "https://images.opencollective.com/tripwire/7599e30/logo.png", "name": "Tripwire, Inc.", "tier": "supporter", - "totalDonations": 7000, + "totalDonations": 7500, "website": "https://tripwire.com" }, { @@ -171,7 +171,7 @@ "image": "https://images.opencollective.com/evilmartians/707ab4d/logo.png", "name": "Evil Martians", "tier": "supporter", - "totalDonations": 6500, + "totalDonations": 7000, "website": "https://evilmartians.com/" }, { @@ -179,7 +179,7 @@ "image": "https://images.opencollective.com/balsa/77de498/logo.png", "name": "Balsa", "tier": "supporter", - "totalDonations": 6500, + "totalDonations": 7000, "website": "https://balsa.com" }, { @@ -187,7 +187,7 @@ "image": "https://images.opencollective.com/jeffrey-rennie/avatar.png", "name": "Jeffrey Rennie", "tier": "supporter", - "totalDonations": 6000 + "totalDonations": 6500 }, { "id": "Pete Gonzalez", @@ -226,7 +226,7 @@ "image": "https://images.opencollective.com/corellium/aa8c228/logo.png", "name": "Corellium", "tier": "supporter", - "totalDonations": 3000, + "totalDonations": 3600, "website": "https://www.corellium.com" }, { @@ -287,6 +287,14 @@ "tier": "contributor", "totalDonations": 2000 }, + { + "id": "MySportsInjury", + "image": "https://images.opencollective.com/my-sports-injury-ltd/518c583/logo.png", + "name": "MySportsInjury", + "tier": "supporter", + "totalDonations": 1500, + "website": "https://www.mysportsinjury.co.uk" + }, { "id": "Philip Keiter", "image": "https://images.opencollective.com/philip-keiter/1c359c0/avatar.png", @@ -314,13 +322,5 @@ "name": "Masafumi Koba", "tier": "contributor", "totalDonations": 1000 - }, - { - "id": "MySportsInjury", - "image": "https://images.opencollective.com/my-sports-injury-ltd/518c583/logo.png", - "name": "MySportsInjury", - "tier": "supporter", - "totalDonations": 1000, - "website": "https://www.mysportsinjury.co.uk" } ] diff --git a/packages/website/package.json b/packages/website/package.json index bce4a06d1e6e..9aaafb72d826 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.21.0", + "version": "5.22.0", "private": true, "scripts": { "build": "docusaurus build", @@ -24,7 +24,7 @@ "@docusaurus/theme-common": "^2.0.0-beta.18", "@docusaurus/theme-search-algolia": "^2.0.0-beta.18", "@mdx-js/react": "1.6.22", - "@typescript-eslint/website-eslint": "5.21.0", + "@typescript-eslint/website-eslint": "5.22.0", "clsx": "^1.1.1", "eslint": "*", "json5": "^2.2.0", diff --git a/packages/website/src/components/editor/useSandboxServices.ts b/packages/website/src/components/editor/useSandboxServices.ts index 9e07408cc3f8..3fe7d7e1ddcb 100644 --- a/packages/website/src/components/editor/useSandboxServices.ts +++ b/packages/website/src/components/editor/useSandboxServices.ts @@ -10,6 +10,7 @@ import type { import { sandboxSingleton } from './loadSandbox'; import { editorEmbedId } from './EditorEmbed'; +import { useColorMode } from '@docusaurus/theme-common'; export interface SandboxServicesProps { readonly jsx?: boolean; @@ -34,6 +35,7 @@ export const useSandboxServices = ( ): Error | SandboxServices | undefined => { const [services, setServices] = useState(); const [loadedTs, setLoadedTs] = useState(props.ts); + const { isDarkTheme } = useColorMode(); useEffect(() => { if (props.ts !== loadedTs) { @@ -74,6 +76,9 @@ export const useSandboxServices = ( main, ts, ); + sandboxInstance.monaco.editor.setTheme( + isDarkTheme ? 'vs-dark' : 'vs-light', + ); const libMap = await sandboxInstance.tsvfs.createDefaultMapFromCDN( sandboxInstance.getCompilerOptions(), diff --git a/tsconfig.base.json b/tsconfig.base.json index c490a4a2eee2..7bb2b5a7fa8f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,8 +9,6 @@ "module": "commonjs", "moduleResolution": "node", "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, "pretty": true, "skipLibCheck": true, "sourceMap": true, diff --git a/yarn.lock b/yarn.lock index cdad65ef8165..2cf20651a528 100644 --- a/yarn.lock +++ b/yarn.lock @@ -137,7 +137,7 @@ dependencies: "@jridgewell/trace-mapping" "^0.3.0" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.8.3": +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.14.5", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.8.3": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== @@ -149,6 +149,27 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.7.tgz#078d8b833fbbcc95286613be8c716cef2b519fa2" integrity sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ== +"@babel/core@*", "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.15.5", "@babel/core@^7.17.8", "@babel/core@^7.7.2", "@babel/core@^7.7.5", "@babel/core@^7.8.0": + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" + integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.17.7" + "@babel/helper-compilation-targets" "^7.17.7" + "@babel/helper-module-transforms" "^7.17.7" + "@babel/helpers" "^7.17.8" + "@babel/parser" "^7.17.8" + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.17.3" + "@babel/types" "^7.17.0" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.1.2" + semver "^6.3.0" + "@babel/core@7.12.9": version "7.12.9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.9.tgz#fd450c4ec10cdbb980e2928b7aa7a28484593fc8" @@ -171,31 +192,19 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.15.5", "@babel/core@^7.17.8", "@babel/core@^7.7.2", "@babel/core@^7.7.5", "@babel/core@^7.8.0": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" - integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== +"@babel/eslint-parser@*", "@babel/eslint-parser@^7.15.4": + version "7.15.4" + resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.15.4.tgz#46385943726291fb3e8db99522c8099b15684387" + integrity sha512-hPMIAmGNbmQzXJIo2P43Zj9UhRmGev5f9nqdBFOWNGDGh6XKmjby79woBvg6y0Jur6yRfQBneDbUQ8ZVc1krFw== dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.7" - "@babel/helper-compilation-targets" "^7.17.7" - "@babel/helper-module-transforms" "^7.17.7" - "@babel/helpers" "^7.17.8" - "@babel/parser" "^7.17.8" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.3" - "@babel/types" "^7.17.0" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.1.2" + eslint-scope "^5.1.1" + eslint-visitor-keys "^2.1.0" semver "^6.3.0" -"@babel/generator@^7.12.5", "@babel/generator@^7.17.3", "@babel/generator@^7.17.7", "@babel/generator@^7.7.2": - version "7.17.7" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" - integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w== +"@babel/generator@^7.12.5", "@babel/generator@^7.17.7", "@babel/generator@^7.17.9", "@babel/generator@^7.7.2": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.9.tgz#f4af9fd38fa8de143c29fce3f71852406fc1e2fc" + integrity sha512-rAdDousTwxbIxbz5I7GEQ3lUip+xVCXooZNbsydCWs3xA7ZsYOv+CFRdzGxRX78BmQHu9B1Eso59AOZQOJDEdQ== dependencies: "@babel/types" "^7.17.0" jsesc "^2.5.1" @@ -275,21 +284,13 @@ dependencies: "@babel/types" "^7.16.7" -"@babel/helper-function-name@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz#f1ec51551fb1c8956bc8dd95f38523b6cf375f8f" - integrity sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA== +"@babel/helper-function-name@^7.16.7", "@babel/helper-function-name@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz#136fcd54bc1da82fcb47565cf16fd8e444b1ff12" + integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== dependencies: - "@babel/helper-get-function-arity" "^7.16.7" "@babel/template" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/helper-get-function-arity@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz#ea08ac753117a669f1508ba06ebcc49156387419" - integrity sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw== - dependencies: - "@babel/types" "^7.16.7" + "@babel/types" "^7.17.0" "@babel/helper-hoist-variables@^7.16.7": version "7.16.7" @@ -414,18 +415,18 @@ "@babel/types" "^7.17.0" "@babel/highlight@^7.16.7": - version "7.16.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88" - integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw== + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.17.9.tgz#61b2ee7f32ea0454612def4fccdae0de232b73e3" + integrity sha512-J9PfEKCbFIv2X5bjTMiZu6Vf341N05QIY+d6FvVKynkG1S7G0j3I0QoRtWIrXhZ+/Nlb5Q0MzqL7TokEJ5BNHg== dependencies: "@babel/helper-validator-identifier" "^7.16.7" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.3", "@babel/parser@^7.17.8": - version "7.17.8" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.8.tgz#2817fb9d885dd8132ea0f8eb615a6388cca1c240" - integrity sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ== +"@babel/parser@*", "@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.15.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.8", "@babel/parser@^7.17.9": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.9.tgz#9c94189a6062f0291418ca021077983058e171ef" + integrity sha512-vqUSBLP8dQHFPdPi9bc5GK9vRkYHJ49fsZdtoJ8EQ8ibpwk5rPKfvNIwChB0KVXcIjcepEBBd2VHC5r9Gy8ueg== "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": version "7.16.7" @@ -1161,17 +1162,17 @@ "@babel/types" "^7.16.7" "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.3", "@babel/traverse@^7.7.2": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" - integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw== + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.9.tgz#1f9b207435d9ae4a8ed6998b2b82300d83c37a0d" + integrity sha512-PQO8sDIJ8SIwipTPiR71kJQCKQYB5NGImbOviK8K+kg5xkNSYXLBupuX9QhatFowrsvo9Hj8WgArg3W7ijNAQw== dependencies: "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.3" + "@babel/generator" "^7.17.9" "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" + "@babel/helper-function-name" "^7.17.9" "@babel/helper-hoist-variables" "^7.16.7" "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/parser" "^7.17.3" + "@babel/parser" "^7.17.9" "@babel/types" "^7.17.0" debug "^4.1.0" globals "^11.1.0" @@ -3589,89 +3590,89 @@ dependencies: source-map-support "^0.5.21" -"@swc/core-android-arm-eabi@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.168.tgz#c5f06b41c9916e1dcff72ba44dd642f79663b79d" - integrity sha512-RjjudVdJxm1KoNrbFxQIppJQjB1mzMYKW6+HYKVl8ktc7i/mnjwcl0cXVBWGbw1xsRWbTjHMHPs/kJ3hOESoeg== - -"@swc/core-android-arm64@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.168.tgz#c8ebe58b94ae0472c92ccff3bbf672268455d048" - integrity sha512-K83gxb578LJid4GI047oSdaK90REnaXfXa+f+DT3Ud5hKFDrF7zkpyF6oxfHJGTl9LCUMXhijwg8aRXaFZFqWQ== - -"@swc/core-darwin-arm64@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.168.tgz#4dedaadc5ce853167bd911c3881cb96dee56f300" - integrity sha512-/kciTqYbEryg3e2C+/Twpww7LBc+zaF7yhz2AmxOrA7nQKuUNHA3Q/Y4sXthSXD2BLqPABJETbRmfmumNi8gQA== - -"@swc/core-darwin-x64@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.168.tgz#589fb258c4743f8adfaae15510b71aa5103089a4" - integrity sha512-PbciVgB24OX6QCUmJmkD2hfZQh9LostC89vALfasUwT/wj3rHeg2SD2rvoPlIf0lYZjUPNfpbhDoxkUeEt+SEg== - -"@swc/core-freebsd-x64@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.168.tgz#5b6a99d9e5789461f72b65d353a8f559e4ac0ba8" - integrity sha512-lp3lNrjF2vNSOtsRFVRDs0EBpwoXQSD0MeZugX9EwHbHXavPlY+Kmo6cNqHfdrxIVOoVOYMlqQn+kO3/4mwYAQ== - -"@swc/core-linux-arm-gnueabihf@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.168.tgz#f52db200702925a12ebf45cb36c6e64619e07e3d" - integrity sha512-TVYXoITQTCPOthHXhmBHFR77mXKE3tGN8CRAHtFYC0mUb42LY5nUQ8yc6peNpcvSqAUzK9K079koDltWIDfWKw== - -"@swc/core-linux-arm64-gnu@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.168.tgz#3f7bc4b769396c13f4529331f0f2f8d6f512a675" - integrity sha512-Xw7Vj/4EJA5V8kQ5cziUbj3qZQSt8n5Pr2TnFCZ3NkCL8og2JYf2N1mOTAI+PIknaDqh1boz+k9xEs1araQ2lA== - -"@swc/core-linux-arm64-musl@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.168.tgz#c1cab1955da332e7af4f7344cdad57cc08805d2d" - integrity sha512-71HHYhyNxpv1Maiqv/U5cHFMitU3MP2TN77vTi5ifPw+6H7A3fG86aqE8zr7YEGsSmOzgQUrMMblqvwe52IrlQ== - -"@swc/core-linux-x64-gnu@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.168.tgz#c68eefab5055e864663cfcc60c5142cc06369c00" - integrity sha512-kEP3VN6Seoz73Fyu+80qkKtIURl/FvlT6NNju55uTMqeeiF3su0CRC60A2/IWHwAZ8sjlorgcXQeaiNTyJmWBQ== - -"@swc/core-linux-x64-musl@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.168.tgz#d7eb458c1d89c6167a6cfa30a6996cc31715f5db" - integrity sha512-IEDB4T5KyUB0BEdIsSJuFm1CV9Y1wIEG15870J0dONkvO1iv5lqWZ7GwA52w/YaI61iNC8+cZYWqfwr4MWj1EQ== - -"@swc/core-win32-arm64-msvc@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.168.tgz#390b20b7933508cf43c77784ed359fe8626c39cd" - integrity sha512-cBiYhBdrW+GdfKJdNhIE/7Pw+45Kn7SKZ78TPc/0ibGXDdx2IkuDhO7x1eZy0eLlS+Br6OLUs9FkgbcMrpZAGw== - -"@swc/core-win32-ia32-msvc@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.168.tgz#3ed63ee6e1be5145e7265d3f3b84886454418cfc" - integrity sha512-ShbX43+hFqDWLU4R8FnDFIPXR8OzC0zBwJBj8QPV3YmeoQD+wyA7NGBccm/8UbnEY5uE2t7P4Pz8891d6TW3Ww== - -"@swc/core-win32-x64-msvc@1.2.168": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.168.tgz#2a7b1a13cf15247690857a3f3e7fbca77f30078d" - integrity sha512-e+SPSiBHSlAI4+RM+Fcz8HVqpHQaGFiDL4b8LwguVgRdoDVeJAjamw53r2UJ23X++9PXamT3rhzPs5XEH0PQhg== +"@swc/core-android-arm-eabi@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.171.tgz#e8f496d03fa0af5c4c76abbe204ea846f7330fa0" + integrity sha512-0DZBYN8PX9GPWw2fJqKfVsctAFRVgQBM2Rin5ZRyJQehzTsI0HnandvFOZAS/I3T3YsiH4b5vH/S8KwRx+eCVg== + +"@swc/core-android-arm64@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.171.tgz#ba73ad5fb308c50d6f2e0d360c05280959470708" + integrity sha512-9ul8XoIeXf0iHt+S2R2GedWmv/iZPrmlAj81esf/mg541kajt3kfdHD+YMKFn753iOmgTfCM+TlU82XT4nEe3w== + +"@swc/core-darwin-arm64@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.171.tgz#c501775b8ca3fe8d58be612a23561f0bad288127" + integrity sha512-bZQLVbCRVU577LGXfhrDMqD0/cVvAFKRob3w2t/aZGY72rp9Mt56IPJcTIgah+5IeCapa4qwWwVQQVOP2DCcRA== + +"@swc/core-darwin-x64@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.171.tgz#2e80b9baf9fee1734fd3fbd198f2c98fe726b457" + integrity sha512-Geb3e9/o0h4VCky6dvQmHXwG+wpq0B4M0pkYySUMC3wVsqdun3rP2dF3i1FWG7F3t92sDOl3ba42JUweTtC2eA== + +"@swc/core-freebsd-x64@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.171.tgz#556f1861cb9bfaae8a727c1cb6dd49efe1137548" + integrity sha512-JSsetNvKghKTXFyAu4+vW0pVY8sDGwZSBd3foyqyx5XXEQMDVlhQEs3AVtojp7+DQrh+PmUdyCB+zS74p70nzg== + +"@swc/core-linux-arm-gnueabihf@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.171.tgz#416c243043e13bd77d4eba6eecadf6bd0332d6fe" + integrity sha512-ZYf5rED8Dw1dbYXolVEnexT7SYVpPJhsuKa4162Onsm/3S3xw1e+qmxJfTVdZG7jI8F2RDoZTHMLH+0y3iH98Q== + +"@swc/core-linux-arm64-gnu@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.171.tgz#b58ef612630aed06925ab3ade2f99b00ecd8c06e" + integrity sha512-uteuIg77MoEwdQ0BZPGFKmbDr+V2OP1rp/Dx9sU5/O9nd1Vju/tuCycMEv8X/k0Riza6sbK6xIFVAQlrPUTZ7g== + +"@swc/core-linux-arm64-musl@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.171.tgz#57a581527abc9920cb3be39d12fa9595bf44f898" + integrity sha512-d1mKKb9QaIOp3KQKvPT8pFgPvZXpYc/YHnyyI667BUboKuznB9VDpHeXk6+C/SWUIT9QdStc0fcf/Tnwni+ivA== + +"@swc/core-linux-x64-gnu@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.171.tgz#73bd3fcca7a8d8b87590a869be3f5fe4d2381015" + integrity sha512-CUNv0yNFuO4y0AnOq9Zbs44nBEuS+eLqC3gv2nEFovdUeVy71rRVelMjvdF5ZWXitHk+WjhfBznF+vP9pye3HA== + +"@swc/core-linux-x64-musl@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.171.tgz#18ad5d9b6efed8b8471e0dad3eb32fd1a81e5fff" + integrity sha512-orHpb/THPJOaDJkJvzGRppwOd0tmpk3ZUGTgRD6FhzYrGzESxEhXuPYNE2jlaXx9hBxu9YDRMUvJWsmLDZW3GQ== + +"@swc/core-win32-arm64-msvc@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.171.tgz#f1a32c80dca0ad63e964591648f65a055d33b327" + integrity sha512-zdoPPnTC5li+4ijatjZA+qyrPTQzpmOqjtQ6HAx1yLoJriGLteLfYmjplx5sFI3JrcDXzITVjaGmu3Ep4Jmhtw== + +"@swc/core-win32-ia32-msvc@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.171.tgz#feefca37a3cb6bad1226c4d92678d40ccef5a224" + integrity sha512-AmaOwrjnIQffwqrCL1MfSpG//ZbtdcCVqhY3+UtVmfKoSsSSkgWXSV++PQlJApAgRn/iwjZiR816B7zLg6535g== + +"@swc/core-win32-x64-msvc@1.2.171": + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.171.tgz#bc229b3a324f33efc2898cf4b9cf4a0b0768d345" + integrity sha512-DrOqi27Lagn/wy2QYDOiNr0KAJX4yR0areDcli2NQ875tva5uVFgvZo5sJFsHiLU/x6yBcxVpVAbzg8a1jRUAA== "@swc/core@^1.2.119", "@swc/core@^1.2.146", "@swc/core@^1.2.159": - version "1.2.168" - resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.168.tgz#e641b5bfb2a8775fcc938324eeb113abf93fbee3" - integrity sha512-O/PzeeSBqNQcpT/+62AGjXJ/TGQ2/jAkJc5aRtT/SyvwA/wQ+gSMOGc3mdFobD7SvgnXX+oS4/I/es84HhrhUA== + version "1.2.171" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.171.tgz#c7e6bf1316bcc45fd914dd032bae014ee1fed7da" + integrity sha512-WE1Nn+LQOqMb41jDTt78REE29elW4QvbAIECpAI9wUP4SJpt9uo9ItJQ3UbXE4BECQ0JgkLz5x7l9uWUAt4YUw== optionalDependencies: - "@swc/core-android-arm-eabi" "1.2.168" - "@swc/core-android-arm64" "1.2.168" - "@swc/core-darwin-arm64" "1.2.168" - "@swc/core-darwin-x64" "1.2.168" - "@swc/core-freebsd-x64" "1.2.168" - "@swc/core-linux-arm-gnueabihf" "1.2.168" - "@swc/core-linux-arm64-gnu" "1.2.168" - "@swc/core-linux-arm64-musl" "1.2.168" - "@swc/core-linux-x64-gnu" "1.2.168" - "@swc/core-linux-x64-musl" "1.2.168" - "@swc/core-win32-arm64-msvc" "1.2.168" - "@swc/core-win32-ia32-msvc" "1.2.168" - "@swc/core-win32-x64-msvc" "1.2.168" + "@swc/core-android-arm-eabi" "1.2.171" + "@swc/core-android-arm64" "1.2.171" + "@swc/core-darwin-arm64" "1.2.171" + "@swc/core-darwin-x64" "1.2.171" + "@swc/core-freebsd-x64" "1.2.171" + "@swc/core-linux-arm-gnueabihf" "1.2.171" + "@swc/core-linux-arm64-gnu" "1.2.171" + "@swc/core-linux-arm64-musl" "1.2.171" + "@swc/core-linux-x64-gnu" "1.2.171" + "@swc/core-linux-x64-musl" "1.2.171" + "@swc/core-win32-arm64-msvc" "1.2.171" + "@swc/core-win32-ia32-msvc" "1.2.171" + "@swc/core-win32-x64-msvc" "1.2.171" "@swc/jest@^0.2.20": version "0.2.20" @@ -3727,10 +3728,10 @@ resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.3.tgz#eda94e1b7c9326700a4b69c485ebbc9498a0b63f" integrity sha512-2TN6oiwtNjOezilFVl77zwdNPwQWaDBBCCWWxyo1ctiO3vAtd7H/aB/CBJdw9+kqq3+latD0SXoedIuHySSZWw== -"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": - version "7.1.16" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.16.tgz#bc12c74b7d65e82d29876b5d0baf5c625ac58702" - integrity sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ== +"@types/babel__core@*", "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": + version "7.1.14" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.14.tgz#faaeefc4185ec71c389f4501ee5ec84b170cc402" + integrity sha512-zGZJzzBUVDo/eV6KgbE0f0ZI7dInEYvo12Rb70uNQDshC3SkRMb67ja0GgRHZgAX3Za6rhaWlvbDO8rrGyAb1g== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" @@ -6838,9 +6839,9 @@ end-of-stream@^1.1.0: once "^1.4.0" enhanced-resolve@^5.8.3, enhanced-resolve@^5.9.2: - version "5.9.2" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz#0224dcd6a43389ebfb2d55efee517e5466772dd9" - integrity sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA== + version "5.9.3" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.3.tgz#44a342c012cbc473254af5cc6ae20ebd0aae5d88" + integrity sha512-Bq9VSor+kjvW3f9/MiiR4eE3XYgOl7/rS8lnSxbRbF3kS0B2r+Y9w5krBWxZgDxASVZbdYrn5wT4j/Wb0J9qow== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -7105,7 +7106,7 @@ eslint-utils@^3.0.0: dependencies: eslint-visitor-keys "^2.0.0" -eslint-visitor-keys@^2.0.0: +eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== @@ -9317,7 +9318,7 @@ jest-config@^27.5.1: slash "^3.0.0" strip-json-comments "^3.1.1" -jest-diff@^27.5.1: +jest-diff@*, jest-diff@^27.3.1, jest-diff@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def" integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw== @@ -9573,7 +9574,7 @@ jest-serializer@^27.5.1: "@types/node" "*" graceful-fs "^4.2.9" -jest-snapshot@^27.0.2, jest-snapshot@^27.5.1: +jest-snapshot@*, jest-snapshot@^27.0.2, jest-snapshot@^27.3.1, jest-snapshot@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-27.5.1.tgz#b668d50d23d38054a51b42c4039cab59ae6eb6a1" integrity sha512-yYykXI5a0I31xX67mgeLw1DZ0bJB+gpq5IpSuCAoyDi0+BhgU/RIrL+RTzDmkNTchvDFWKP8lp+w/42Z3us5sA== @@ -11725,9 +11726,9 @@ pify@^5.0.0: integrity sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA== pirates@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.4.tgz#07df81e61028e402735cdd49db701e4885b4e6e6" - integrity sha512-ZIrVPH+A52Dw84R0L3/VS9Op04PuQ2SEoJL6bkshmiTic/HldyW9Tf7oH5mhJZBK7NmDx27vSMrYEXPXclpDKw== + version "4.0.5" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b" + integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== pkg-dir@^4.1.0, pkg-dir@^4.2.0: version "4.2.0"