Skip to content

Commit

Permalink
Enable eslint-expect-type for all projects (#1616)
Browse files Browse the repository at this point in the history
It's a really useful plugin:
https://github.com/JoshuaKGoldberg/eslint-plugin-expect-type

You use it like this:

```ts
// $ExpectType string
const foo = "123"
```

It will fail `lint` if the type doesn't exactly match what you say.
  • Loading branch information
aomarks authored May 1, 2024
1 parent 3b2bb4a commit c5ea046
Show file tree
Hide file tree
Showing 64 changed files with 225 additions and 26 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:expect-type/recommended"
],
"overrides": [],
"ignorePatterns": ["dist"],

Expand All @@ -12,7 +16,7 @@
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "eslint-plugin-expect-type"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"@typescript-eslint/parser": "^7.8.0",
"ava": "^5.2.0",
"eslint": "^8.57.0",
"eslint-plugin-expect-type": "^0.4.0",
"npm-ci": "^0.0.2",
"rimraf": "^5.0.5",
"rollup": "^4.17.2",
Expand Down
5 changes: 5 additions & 0 deletions packages/agent-kit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/agent-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
16 changes: 16 additions & 0 deletions packages/breadboard-cli/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
"overrides": [
{
"files": ["!./vite.config.ts"],
"parserOptions": {
"project": false,
},
"rules": {
"expect-type/expect": "off",
},
},
],
}
1 change: 1 addition & 0 deletions packages/breadboard-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/breadboard-extension/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/breadboard-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/breadboard-python/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
5 changes: 5 additions & 0 deletions packages/breadboard-server/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/breadboard-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
16 changes: 16 additions & 0 deletions packages/breadboard-ui/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
"overrides": [
{
"files": ["!./vite.config.ts"],
"parserOptions": {
"project": false,
},
"rules": {
"expect-type/expect": "off",
},
},
],
}
1 change: 1 addition & 0 deletions packages/breadboard-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/breadboard-web/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
15 changes: 1 addition & 14 deletions packages/breadboard/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
{
"plugins": ["eslint-plugin-expect-type"],
"extends": ["plugin:expect-type/recommended"],
"parserOptions": {
"project": ["./tsconfig.json"]
"project": ["./tsconfig.json"],
},
"rules": {
"@typescript-eslint/ban-types": [
"warn",
{
"types": {
"Function": false
},
"extendDefaults": true
}
]
}
}
1 change: 0 additions & 1 deletion packages/breadboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.8.0",
"ava": "^5.2.0",
"eslint-plugin-expect-type": "^0.4.0",
"jsonschema": "^1.4.1",
"rollup": "^4.17.2",
"typedoc": "^0.25.12",
Expand Down
2 changes: 2 additions & 0 deletions packages/breadboard/src/kits/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class KitBuilder {
} as KitConstructor<GenericKit<Handlers>>;
}

// eslint-disable-next-line @typescript-eslint/ban-types
static wrap<F extends Record<string, Function>>(
params: KitBuilderOptions,
functions: F
Expand All @@ -114,6 +115,7 @@ export class KitBuilder {
> {
const createHandler = (
previous: NodeHandlers,
// eslint-disable-next-line @typescript-eslint/ban-types
current: [string, Function]
) => {
const [name, fn] = current;
Expand Down
1 change: 1 addition & 0 deletions packages/breadboard/src/new/grammar/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { BuilderScope } from "./scope.js";
import { Value, isValue } from "./value.js";
import { isLambda } from "./board.js";

// eslint-disable-next-line @typescript-eslint/ban-types
const serializeFunction = (name: string, handlerFn: Function) => {
let code = handlerFn.toString();

Expand Down
16 changes: 16 additions & 0 deletions packages/breadbuddy/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
"overrides": [
{
"files": ["!./vite.config.ts"],
"parserOptions": {
"project": false,
},
"rules": {
"expect-type/expect": "off",
},
},
],
}
1 change: 1 addition & 0 deletions packages/breadbuddy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
8 changes: 0 additions & 8 deletions packages/build/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"plugins": ["eslint-plugin-expect-type"],
"extends": ["plugin:expect-type/recommended"],
"parserOptions": {
"project": ["./tsconfig.json"],
},
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "_.*" },
],
},
}
5 changes: 5 additions & 0 deletions packages/cloud-function/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
5 changes: 5 additions & 0 deletions packages/coffee-bot-board/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/coffee-bot-board/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/core-kit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/core-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/create-breadboard-kit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json", "./assets/tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/create-breadboard-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
},
"files": [
"src/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/create-breadboard/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/create-breadboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"files": [
"src/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/discovery-types/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/discovery-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/gemini-kit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/gemini-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/graph-integrity/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/graph-integrity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/graph-playground/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/graph-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"src/**/*.ts",
"wild/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/graph-runner/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/graph-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/hello-world/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
5 changes: 5 additions & 0 deletions packages/import/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
1 change: 1 addition & 0 deletions packages/import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"files": [
"src/**/*.ts",
"tests/**/*.ts",
".eslintrc",
"../../.eslintrc.json"
],
"output": []
Expand Down
5 changes: 5 additions & 0 deletions packages/json-kit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"project": ["./tsconfig.json"],
},
}
Loading

0 comments on commit c5ea046

Please sign in to comment.