Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(ast-spec): add fixture test framework and some initial fixtures#3258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 1 commit intomainfromseparate-spec-fixtures
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions.github/workflows/ci.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmm, it would be nice to parallelize all these, store the coverage data as an artifact, and have a dependent job pick up the coverage after... not necessary for this PR, just noting down. 📝

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah for sure, once I have finished my Nx refactoring we can opt into the Distributed Task Execution and let Nx Cloud decide how to parallelize and distribute across all available agents, then collect all artifacts


- name: Run unit tests for typescript-estree
run: npx nx test @typescript-eslint/typescript-estree
env:
Expand DownExpand Up@@ -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:
Expand Down
1 change: 1 addition & 0 deletions.prettierignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down
32 changes: 32 additions & 0 deletions.vscode/launch.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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",
],
},
]
}
5 changes: 1 addition & 4 deletions.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,10 +27,7 @@
{
"icon": "jest_snapshot",
"extensions": [
".ts.shot",
".tsx.shot",
".js.shot",
".jsx.shot",
".shot",
],
"extends": "jest_snapshot"
},
Expand Down
7 changes: 7 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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",
Expand All@@ -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",
Expand DownExpand Up@@ -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",
Expand Down
5 changes: 5 additions & 0 deletionspackages/ast-spec/jest.config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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'],
};
12 changes: 12 additions & 0 deletionspackages/ast-spec/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,16 +32,28 @@
"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": {
"type": "opencollective",
"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": "*"
}
}
1 change: 1 addition & 0 deletionspackages/ast-spec/src/base/TSHeritageBase.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
class Foo implements 'thing' {}
Original file line numberDiff line numberDiff line change
@@ -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"`;
Original file line numberDiff line numberDiff line change
@@ -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)]`;
Original file line numberDiff line numberDiff line change
@@ -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"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
class Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AST Fixtures declaration ClassDeclaration _error_ no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`;
Original file line numberDiff line numberDiff line change
@@ -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)]`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AST Fixtures declaration ClassDeclaration _error_ no-body Error Alignment 1`] = `"Both errored"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
class 'Foo' {}
Original file line numberDiff line numberDiff line change
@@ -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.]`;
Original file line numberDiff line numberDiff line change
@@ -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)]`;
Original file line numberDiff line numberDiff line change
@@ -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"`;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
abstract class Foo {}
Original file line numberDiff line numberDiff line change
@@ -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 },
},
}
`;
Original file line numberDiff line numberDiff line change
@@ -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 },
},
},
]
`;
Original file line numberDiff line numberDiff line change
@@ -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 },
},
}
`;
Loading

[8]ページ先頭

©2009-2025 Movatter.jp