diff --git a/.chronus/changes/fix-test-path-2024-6-5-14-0-33.md b/.chronus/changes/fix-test-path-2024-6-5-14-0-33.md new file mode 100644 index 0000000000..b65a45b1a7 --- /dev/null +++ b/.chronus/changes/fix-test-path-2024-6-5-14-0-33.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/compiler" +--- + +Fix templates initialized on node 22 \ No newline at end of file diff --git a/docs/extending-typespec/basics.md b/docs/extending-typespec/basics.md index af1c749488..05d3cb92a8 100644 --- a/docs/extending-typespec/basics.md +++ b/docs/extending-typespec/basics.md @@ -154,7 +154,8 @@ Alternatively, you can add these as scripts in your `package.json` to make them "clean": "rimraf ./dist ./temp", "build": "tsc -p .", "watch": "tsc -p . --watch", - "test": "node --test ./dist/test" + "test": "node --test ./dist/test/**/*.test.js", // Node 22+ + "test": "node --test ./dist/test/" // Node 18, 20 } ``` diff --git a/eng/tsp-core/pipelines/stages/ci-stages.yml b/eng/tsp-core/pipelines/stages/ci-stages.yml index 8b0b08dc8a..8b1488182a 100644 --- a/eng/tsp-core/pipelines/stages/ci-stages.yml +++ b/eng/tsp-core/pipelines/stages/ci-stages.yml @@ -21,6 +21,9 @@ stages: "Node 20.x": nodeVersion: 20.x + "Node 22.x": + nodeVersion: 22.x + pool: name: $(WINDOWSPOOL) image: $(WINDOWSVMIMAGE) diff --git a/packages/compiler/templates/__snapshots__/emitter-ts/.eslintrc.yml b/packages/compiler/templates/__snapshots__/emitter-ts/.eslintrc.yml deleted file mode 100644 index 985e6b890c..0000000000 --- a/packages/compiler/templates/__snapshots__/emitter-ts/.eslintrc.yml +++ /dev/null @@ -1,14 +0,0 @@ -root: true -env: - es2021: true - node: true -extends: - - eslint:recommended - - plugin:@typescript-eslint/recommended -parser: "@typescript-eslint/parser" -parserOptions: - ecmaVersion: latest - sourceType: module -plugins: - - "@typescript-eslint" -rules: {} diff --git a/packages/compiler/templates/__snapshots__/emitter-ts/eslint.config.js b/packages/compiler/templates/__snapshots__/emitter-ts/eslint.config.js new file mode 100644 index 0000000000..308a894777 --- /dev/null +++ b/packages/compiler/templates/__snapshots__/emitter-ts/eslint.config.js @@ -0,0 +1,11 @@ +// @ts-check +import eslint from "@eslint/js"; +import tsEslint from "typescript-eslint"; + +export default tsEslint.config( + { + ignores: ["**/dist/**/*", "**/.temp/**/*"], + }, + eslint.configs.recommended, + ...tsEslint.configs.recommended +); diff --git a/packages/compiler/templates/__snapshots__/emitter-ts/package.json b/packages/compiler/templates/__snapshots__/emitter-ts/package.json index c8c39fd6c3..e08b6c9604 100644 --- a/packages/compiler/templates/__snapshots__/emitter-ts/package.json +++ b/packages/compiler/templates/__snapshots__/emitter-ts/package.json @@ -27,7 +27,7 @@ "scripts": { "build": "tsc", "watch": "tsc --watch", - "test": "node --test ./dist/test/", + "test": "node --test", "lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0", "lint:fix": "eslint . --report-unused-disable-directives --fix", "format": "prettier . --write", diff --git a/packages/compiler/templates/__snapshots__/library-ts/.eslintrc.yml b/packages/compiler/templates/__snapshots__/library-ts/.eslintrc.yml deleted file mode 100644 index 985e6b890c..0000000000 --- a/packages/compiler/templates/__snapshots__/library-ts/.eslintrc.yml +++ /dev/null @@ -1,14 +0,0 @@ -root: true -env: - es2021: true - node: true -extends: - - eslint:recommended - - plugin:@typescript-eslint/recommended -parser: "@typescript-eslint/parser" -parserOptions: - ecmaVersion: latest - sourceType: module -plugins: - - "@typescript-eslint" -rules: {} diff --git a/packages/compiler/templates/__snapshots__/library-ts/eslint.config.js b/packages/compiler/templates/__snapshots__/library-ts/eslint.config.js new file mode 100644 index 0000000000..308a894777 --- /dev/null +++ b/packages/compiler/templates/__snapshots__/library-ts/eslint.config.js @@ -0,0 +1,11 @@ +// @ts-check +import eslint from "@eslint/js"; +import tsEslint from "typescript-eslint"; + +export default tsEslint.config( + { + ignores: ["**/dist/**/*", "**/.temp/**/*"], + }, + eslint.configs.recommended, + ...tsEslint.configs.recommended +); diff --git a/packages/compiler/templates/__snapshots__/library-ts/package.json b/packages/compiler/templates/__snapshots__/library-ts/package.json index 31a203a46a..079f06ca5a 100644 --- a/packages/compiler/templates/__snapshots__/library-ts/package.json +++ b/packages/compiler/templates/__snapshots__/library-ts/package.json @@ -30,7 +30,7 @@ "build": "tsc && npm run build:tsp", "watch": "tsc --watch", "build:tsp": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit", - "test": "node --test ./dist/test/", + "test": "node --test", "lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0", "lint:fix": "eslint . --report-unused-disable-directives --fix", "format": "prettier . --write", diff --git a/packages/compiler/templates/emitter-ts/package.json b/packages/compiler/templates/emitter-ts/package.json index 80490323c8..4806800b1b 100644 --- a/packages/compiler/templates/emitter-ts/package.json +++ b/packages/compiler/templates/emitter-ts/package.json @@ -27,7 +27,7 @@ "scripts": { "build": "tsc", "watch": "tsc --watch", - "test": "node --test ./dist/test/", + "test": "node --test", "lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0", "lint:fix": "eslint . --report-unused-disable-directives --fix", "format": "prettier . --write", diff --git a/packages/compiler/templates/library-ts/package.json b/packages/compiler/templates/library-ts/package.json index 6c0e6a413d..99014148a6 100644 --- a/packages/compiler/templates/library-ts/package.json +++ b/packages/compiler/templates/library-ts/package.json @@ -30,7 +30,7 @@ "build": "tsc && npm run build:tsp", "watch": "tsc --watch", "build:tsp": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit", - "test": "node --test ./dist/test/", + "test": "node --test", "lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0", "lint:fix": "eslint . --report-unused-disable-directives --fix", "format": "prettier . --write", diff --git a/packages/website/versioned_docs/version-latest/extending-typespec/basics.md b/packages/website/versioned_docs/version-latest/extending-typespec/basics.md index af1c749488..1922ef1e33 100644 --- a/packages/website/versioned_docs/version-latest/extending-typespec/basics.md +++ b/packages/website/versioned_docs/version-latest/extending-typespec/basics.md @@ -154,7 +154,7 @@ Alternatively, you can add these as scripts in your `package.json` to make them "clean": "rimraf ./dist ./temp", "build": "tsc -p .", "watch": "tsc -p . --watch", - "test": "node --test ./dist/test" + "test": "node --test ./dist/test/**/*.test.js", } ```