tstyche 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,7 @@ interface ConfigFileOptions {
43
43
  checkSourceFiles?: boolean;
44
44
  checkSuppressedErrors?: boolean;
45
45
  failFast?: boolean;
46
+ fixtureFileMatch?: Array<string>;
46
47
  plugins?: Array<string>;
47
48
  rejectAnyType?: boolean;
48
49
  rejectNeverType?: boolean;
@@ -95,13 +96,13 @@ declare class ConfigDiagnosticText {
95
96
  static expectsListItemType(optionName: string, optionBrand: OptionBrand): string;
96
97
  static expectsValue(optionName: string): string;
97
98
  static fileDoesNotExist(filePath: string): string;
99
+ static fileMatchPatternCannotStartWith(optionName: string, segment: string): Array<string>;
98
100
  static inspectSupportedVersions(): string;
99
101
  static moduleWasNotFound(specifier: string): string;
100
102
  static rangeIsNotValid(value: string): string;
101
103
  static rangeUsage(): Array<string>;
102
104
  static requiresValueType(optionName: string, optionBrand: OptionBrand): string;
103
105
  static seen(element: string): string;
104
- static testFileMatchCannotStartWith(segment: string): Array<string>;
105
106
  static unexpected(element: string): string;
106
107
  static unknownOption(optionName: string): string;
107
108
  static usage(optionName: string, optionBrand: OptionBrand): Array<string>;
@@ -722,6 +723,7 @@ declare class Runner {
722
723
 
723
724
  declare class Select {
724
725
  #private;
726
+ static isFixtureFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
725
727
  static isTestFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
726
728
  static selectFiles(resolvedConfig: ResolvedConfig): Promise<Array<string>>;
727
729
  }
package/build/tstyche.js CHANGED
@@ -225,6 +225,12 @@ class ConfigDiagnosticText {
225
225
  static fileDoesNotExist(filePath) {
226
226
  return `The specified path '${filePath}' does not exist.`;
227
227
  }
228
+ static fileMatchPatternCannotStartWith(optionName, segment) {
229
+ return [
230
+ `A '${optionName}' pattern cannot start with '${segment}'.`,
231
+ "The files are only collected within the 'rootPath' directory.",
232
+ ];
233
+ }
228
234
  static inspectSupportedVersions() {
229
235
  return "Use the '--list' command line option to inspect the list of supported versions.";
230
236
  }
@@ -247,12 +253,6 @@ class ConfigDiagnosticText {
247
253
  static seen(element) {
248
254
  return `The ${element} was seen here.`;
249
255
  }
250
- static testFileMatchCannotStartWith(segment) {
251
- return [
252
- `A test file match pattern cannot start with '${segment}'.`,
253
- "The test files are only collected within the 'rootPath' directory.",
254
- ];
255
- }
256
256
  static unexpected(element) {
257
257
  return `Unexpected ${element}.`;
258
258
  }
@@ -934,6 +934,16 @@ class Options {
934
934
  group: OptionGroup.CommandLine,
935
935
  name: "fetch",
936
936
  },
937
+ {
938
+ brand: OptionBrand.List,
939
+ description: "The list of glob patterns matching the fixture files.",
940
+ group: OptionGroup.ConfigFile,
941
+ items: {
942
+ brand: OptionBrand.String,
943
+ name: "fixtureFileMatch",
944
+ },
945
+ name: "fixtureFileMatch",
946
+ },
937
947
  {
938
948
  brand: OptionBrand.BareTrue,
939
949
  description: "Print the list of command line options with brief descriptions and exit.",
@@ -1147,10 +1157,11 @@ class Options {
1147
1157
  }
1148
1158
  break;
1149
1159
  }
1160
+ case "fixtureFileMatch":
1150
1161
  case "testFileMatch":
1151
1162
  for (const segment of ["/", "../"]) {
1152
1163
  if (optionValue.startsWith(segment)) {
1153
- onDiagnostics(Diagnostic.error(ConfigDiagnosticText.testFileMatchCannotStartWith(segment), origin));
1164
+ onDiagnostics(Diagnostic.error(ConfigDiagnosticText.fileMatchPatternCannotStartWith(canonicalOptionName, segment), origin));
1154
1165
  }
1155
1166
  }
1156
1167
  break;
@@ -1402,6 +1413,7 @@ const defaultOptions = {
1402
1413
  checkSourceFiles: true,
1403
1414
  checkSuppressedErrors: false,
1404
1415
  failFast: false,
1416
+ fixtureFileMatch: ["**/__fixtures__/*.{ts,tsx}", "**/fixtures/*.{ts,tsx}"],
1405
1417
  plugins: [],
1406
1418
  rejectAnyType: true,
1407
1419
  rejectNeverType: true,
@@ -2916,6 +2928,10 @@ class Select {
2916
2928
  }
2917
2929
  return matchPatterns.includedFile.test(filePath);
2918
2930
  }
2931
+ static isFixtureFile(filePath, resolvedConfig) {
2932
+ const matchPatterns = Select.#getMatchPatterns(resolvedConfig.fixtureFileMatch);
2933
+ return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns, resolvedConfig);
2934
+ }
2919
2935
  static isTestFile(filePath, resolvedConfig) {
2920
2936
  const matchPatterns = Select.#getMatchPatterns(resolvedConfig.testFileMatch);
2921
2937
  return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns, resolvedConfig);
@@ -3750,7 +3766,7 @@ class ProjectService {
3750
3766
  { diagnostics: Diagnostic.fromDiagnostics(configFileErrors) },
3751
3767
  ]);
3752
3768
  }
3753
- if (this.#resolvedConfig.checkSourceFiles && !this.#seenTestFiles.has(filePath)) {
3769
+ if (!this.#seenTestFiles.has(filePath)) {
3754
3770
  this.#seenTestFiles.add(filePath);
3755
3771
  const languageService = this.getLanguageService(filePath);
3756
3772
  const program = languageService?.getProgram();
@@ -3762,10 +3778,13 @@ class ProjectService {
3762
3778
  if (program.isSourceFileFromExternalLibrary(sourceFile) || program.isSourceFileDefaultLibrary(sourceFile)) {
3763
3779
  return false;
3764
3780
  }
3781
+ if (Select.isFixtureFile(sourceFile.fileName, { ...this.#resolvedConfig, pathMatch: [] })) {
3782
+ return true;
3783
+ }
3765
3784
  if (Select.isTestFile(sourceFile.fileName, { ...this.#resolvedConfig, pathMatch: [] })) {
3766
3785
  return false;
3767
3786
  }
3768
- return true;
3787
+ return this.#resolvedConfig.checkSourceFiles;
3769
3788
  });
3770
3789
  const diagnostics = [];
3771
3790
  for (const sourceFile of sourceFilesToCheck) {
@@ -5084,7 +5103,7 @@ class TaskRunner {
5084
5103
  class Runner {
5085
5104
  #eventEmitter = new EventEmitter();
5086
5105
  #resolvedConfig;
5087
- static version = "4.2.0";
5106
+ static version = "4.3.0";
5088
5107
  constructor(resolvedConfig) {
5089
5108
  this.#resolvedConfig = resolvedConfig;
5090
5109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tstyche",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Everything You Need for Type Testing.",
5
5
  "keywords": [
6
6
  "typescript",