Brought to you by Allons-y Studio

Type Alias: Detector

type Detector = {
  concern: "lint" | "test" | "build" | "release";
  displayName: string;
  fileTypes?: string[];
  id: DetectorId;
  shortName: string;
  cleanup?: CleanupSuggestion[];
  describe: DetectorDescription;
  detect: boolean | Promise<boolean>;
  run?: Promise<number>;
};

Defined in: detector.ts:152

The contract every opx plugin implements: decide when it applies, then run.

Properties

Property Type Description Defined in
concern "lint" | "test" | "build" | "release" The task this detector belongs to. detector.ts:160
displayName string The name shown to people. detector.ts:158
fileTypes? string[] File extensions this detector owns, with the leading dot. detector.ts:162
id DetectorId The package id, such as @allons-y/opx-lint-js. detector.ts:154
shortName string The short name used in config and commands, such as js. detector.ts:156

Methods

cleanup()?

optional cleanup(ctx): CleanupSuggestion[];

Defined in: detector.ts:176

Suggest what the project can drop now that this plugin is enabled.

Suggestions are advice. opx prints them, and deletes only a suggested file that is empty and unchanged in git.

Parameters

Parameter Type Description
ctx DetectorContext The detector context.

Returns

CleanupSuggestion[]

The suggestions, or none.


describe()

describe(ctx): DetectorDescription;

Defined in: detector.ts:166

Describe the detector for display.

Parameters

Parameter Type
ctx DetectorContext

Returns

DetectorDescription


detect()

detect(ctx): boolean | Promise<boolean>;

Defined in: detector.ts:164

Whether the detector applies to this project.

Parameters

Parameter Type
ctx DetectorContext

Returns

boolean | Promise<boolean>


run()?

optional run(ctx, args): Promise<number>;

Defined in: detector.ts:184

Run the tool.

Parameters

Parameter Type Description
ctx DetectorContext The detector context.
args string[] Paths and flags forwarded from the command line.

Returns

Promise<number>

The exit code: 0 for success.