Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-2457: Improved ESLint configuration #5847

Merged
merged 51 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0243c48
feat: restore config
indietyp Dec 2, 2024
b468527
feat: use the correct typescript types
indietyp Dec 2, 2024
6e4c62f
feat: deprecated
indietyp Dec 2, 2024
4e843d6
chore: update TODO
indietyp Dec 2, 2024
152b75b
feat: try to split
indietyp Dec 9, 2024
a1e8f40
feat: auto generate config from previous version
indietyp Dec 9, 2024
652a134
fix: lint the package itself
indietyp Dec 9, 2024
3112744
fix: eslint
indietyp Dec 9, 2024
8d9fab4
fix: eslint issues in eslint
indietyp Dec 9, 2024
4a5a12a
feat: convert hash-api
indietyp Dec 9, 2024
7a9dd24
feat: convert hash-ai-worker-ts
indietyp Dec 9, 2024
88b4bae
fix: hash-ai-worker-ts
indietyp Dec 9, 2024
2b92447
feat: eslint for hash-frontend
indietyp Dec 9, 2024
03120f8
fix: hash-frontend
indietyp Dec 9, 2024
3fec8c6
feat: hash-integration-worker
indietyp Dec 9, 2024
749f3e8
feat: hash-realtime
indietyp Dec 9, 2024
108222b
feat: convert hash-search-loader
indietyp Dec 9, 2024
5314e58
feat: convert hashdotdesign?
indietyp Dec 9, 2024
de850e9
feat: convert hashdotdev
indietyp Dec 9, 2024
897f345
feat: convert plugin-browser
indietyp Dec 9, 2024
b12e8c0
feat: convert blocks
indietyp Dec 9, 2024
5848a31
feat: convert blockprotocol
indietyp Dec 9, 2024
bfc39a5
feat: convert @hashintel packages
indietyp Dec 10, 2024
be120fc
feat: convert advandec-types, sdk, client
indietyp Dec 10, 2024
e61f7d6
feat: convert type-defs, types, (WIP) harpc
indietyp Dec 10, 2024
5d80e0b
feat: harpc
indietyp Dec 10, 2024
d488248
feat: convert hash-backend-utils, hash-isomorphic-utils
indietyp Dec 10, 2024
33b2ba0
feat: convert the rest
indietyp Dec 10, 2024
69563e7
fix: constraints
indietyp Dec 10, 2024
387fe03
feat: make lint dependent on build
indietyp Dec 10, 2024
f069376
fix: dependencies
indietyp Dec 10, 2024
911f91d
feat: add explicit parser
indietyp Dec 10, 2024
c2f933a
feat: pin `@types/scheduler`
indietyp Dec 10, 2024
efaa781
chore: remove outdated @types
indietyp Dec 10, 2024
668b509
fix: eslint build
indietyp Dec 10, 2024
8c91bb5
fix: CI
indietyp Dec 10, 2024
ef388ea
fix: turbo
indietyp Dec 10, 2024
df374a8
fix: rust impl
indietyp Dec 10, 2024
8a9e38d
fix: build
indietyp Dec 10, 2024
458e4f7
fix: tsconfig includes
indietyp Dec 10, 2024
e6de3be
fix: explicit @babel/core dependency
indietyp Dec 10, 2024
f088b74
chore: force turbo cache
indietyp Dec 10, 2024
2430e82
chore: remove eslint from tsconfig
indietyp Dec 10, 2024
8fe0dcd
fix: eslint
indietyp Dec 10, 2024
9bd2f77
fix: tsconfig
indietyp Dec 10, 2024
4e15a32
fix: unused variable errors
indietyp Dec 10, 2024
c5535c4
fix: eslint
indietyp Dec 10, 2024
cf3e35a
chore: remove offending plugin
indietyp Dec 10, 2024
ee2cac6
fix: adjust rules to allow empty interface extends
indietyp Dec 11, 2024
d1fdbfc
fix: yarn install
indietyp Dec 11, 2024
eceafca
fix: yarn dedupe
indietyp Dec 11, 2024
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: 0 additions & 7 deletions apps/hash-ai-worker-ts/.eslintrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions apps/hash-ai-worker-ts/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createBase } from "@local/eslint/deprecated";

export default createBase(import.meta.dirname);
4 changes: 2 additions & 2 deletions apps/hash-ai-worker-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"typescript": "5.6.3"
},
"devDependencies": {
"@local/eslint-config": "0.0.0-private",
"@local/eslint": "0.0.0-private",
"@local/tsconfig": "0.0.0-private",
"@sentry/cli": "^2.39.1",
"@types/dedent": "0.7.2",
Expand All @@ -110,7 +110,7 @@
"@types/papaparse": "5.3.15",
"@types/sanitize-html": "2.13.0",
"@vitest/coverage-istanbul": "2.1.8",
"eslint": "8.57.0",
"eslint": "9.16.0",
"rimraf": "6.0.1",
"typescript": "5.6.3",
"vite-tsconfig-paths": "5.1.4",
Expand Down
5 changes: 2 additions & 3 deletions apps/hash-ai-worker-ts/scripts/bundle-workflow-code.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { writeFile } from "node:fs/promises";
import { createRequire } from "node:module";
import * as path from "node:path";
import { dirname } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { bundleWorkflowCode } from "@temporalio/worker";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const require = createRequire(import.meta.url);

Expand Down
4 changes: 2 additions & 2 deletions apps/hash-ai-worker-ts/scripts/compare-llm-response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkdirSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { type OwnedById } from "@local/hash-graph-types/web";
Expand All @@ -14,7 +14,7 @@ import { getAliceUserAccountId } from "../src/shared/testing-utilities/get-alice
import type { CompareLlmResponseConfig } from "./compare-llm-response/types.js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const configDirectory = `${__dirname}/compare-llm-response/var/config`;

Expand Down
4 changes: 2 additions & 2 deletions apps/hash-ai-worker-ts/scripts/sanitize-html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkdirSync, writeFileSync } from "node:fs";
import path, { dirname } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { getWebPageActivity } from "../src/activities/get-web-page-activity.js";
Expand All @@ -12,7 +12,7 @@ import { getWebPageActivity } from "../src/activities/get-web-page-activity.js";
*/

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const url = process.argv[2];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ const callModel = async (
: dedent(`
The Python code ran successfully.
The stdout from your code was: ${stdout}
The following artifacts were generated:\n${artifacts.join("\n")}
The following artifacts were generated:\n${
// @todo: https://linear.app/hash/issue/H-3769/investigate-new-eslint-errors
// eslint-disable-next-line @typescript-eslint/no-base-to-string
artifacts.join("\n")
}

Please now review the code used and whether it correctly operates on the context data.
If you spot errors in how the code attempts to access the code data, submit another code file with the corrections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const getFileFromUrlAction: FlowActionActivity = async ({ inputs }) => {
}

// @todo look for an existing file with the same originalUrl in the graph, and update it if found?
const operation = "create" as const;
const operation = "create";

const fileEntity = createFileEntityFromUrlStatus.entity.toJSON();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createWriteStream } from "node:fs";
import { mkdir, unlink } from "node:fs/promises";
import { dirname, join } from "node:path";
import path from "node:path";
import { Readable } from "node:stream";
import { finished } from "node:stream/promises";
import type { ReadableStream } from "node:stream/web";
Expand Down Expand Up @@ -47,9 +47,9 @@ import { getLlmAnalysisOfDoc } from "./infer-metadata-from-document-action/get-l
import type { FlowActionActivity } from "./types.js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const baseFilePath = join(__dirname, "/var/tmp_files");
const baseFilePath = path.join(__dirname, "/var/tmp_files");

export const inferMetadataFromDocumentAction: FlowActionActivity = async ({
inputs,
Expand Down Expand Up @@ -200,6 +200,8 @@ export const inferMetadataFromDocumentAction: FlowActionActivity = async ({
resolve(pdfData);
});

// @todo: https://linear.app/hash/issue/H-3769/investigate-new-eslint-errors
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
pdfParser.loadPDF(filePath).catch((err) => reject(err));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
readFileSync,
writeFileSync,
} from "node:fs";
import { dirname, join } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { expect, test } from "vitest";
Expand All @@ -16,9 +16,9 @@ import { researchEntitiesAction } from "./research-entities-action.js";
import type { CoordinatingAgentState } from "./research-entities-action/shared/coordinators.js";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const baseDirectoryPath = join(__dirname, "/var/persisted-state");
const baseDirectoryPath = path.join(__dirname, "/var/persisted-state");

export const retrievePreviousState = (params: {
testName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "../../../../shared/testing-utilities/mock-get-flow-context.js";

import { dirname, join } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import dedent from "dedent";
Expand Down Expand Up @@ -32,7 +32,7 @@ const ftse350Metric: MetricDefinition = {
The user prompt provided to the LLM is: "${ftse350MetricPrompt}".
The text provided to the LLM is the HTML of a web-page containing a table of
FTSE350 constituents, paginated across multiple pages.

The LLM must extract all the paginated links from the FTSE350 constituents page, because
the links must be followed to extract the full list of FTSE350 constituents.

Expand Down Expand Up @@ -118,7 +118,7 @@ const marksAndSpencersAnnualInvestorsReport: MetricDefinition = {
The text provided to the LLM is the HTML of the Marks and Spencers investors page, which
includes links to a variety of documents, including the annual investor report published
by the company every year.

To satisfy the prompt, the LLM must extract the link to the latest annual investor report PDF
published by Marks and Spencers, which is https://corporate.marksandspencer.com/sites/marksandspencer/files/2024-06/M-and-S-2024-Annual-Report.pdf.

Expand Down Expand Up @@ -201,7 +201,7 @@ const graphicsCardSpecificationMetric: MetricDefinition = {

To satisfy the prompt, the LLM must extract the link to the specification page of
the NVIDIA GeForce RTX 4090 graphics card, which is https://www.techpowerup.com/gpu-specs/geforce-rtx-4090.c3889.

The score in this metric is calculated as 1 if the correct link is extracted, and 0 otherwise.
`),
executeMetric: async (params) => {
Expand Down Expand Up @@ -267,9 +267,9 @@ const metrics: MetricDefinition[] = [
];

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const baseDirectoryPath = join(
const baseDirectoryPath = path.join(
__dirname,
"/var/extract-links-from-text-testing",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const getLinkFollowerNextToolCallsSystemPrompt = dedent(`
- complete: complete the research task if the gathered claims fulfill the task
- exploreLinks: call this tool to explore additional links to gather more claims that may fulfill the task
- terminate: terminate the research task if it cannot be progressed further
If you already have enough claims to meet the research brief, call 'complete'.

If you already have enough claims to meet the research brief, call 'complete'.
Don't follow more links unless it is required to meet the goal of the research task.
</TaskDescription>

Balance any need to gather more claims with the need to complete the task in a timely manner.
Consider the research task and the claims already gathered when making your decision.
`);
Expand Down Expand Up @@ -116,9 +116,7 @@ Now decide what to do next. If you have gathered enough information about entiti
};
};

const toolNames = ["exploreLinks", "complete", "terminate"] as const;

type ToolName = (typeof toolNames)[number];
type ToolName = "exploreLinks" | "complete" | "terminate";

const suggestionForNextStepsDefinition = {
type: "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { access, mkdir } from "node:fs/promises";
import { dirname, join } from "node:path";
import path from "node:path";
import { fileURLToPath } from "node:url";

import type { Subtype } from "@local/advanced-types/subtype";
Expand All @@ -20,9 +20,9 @@ export type SimpleStorageContext = Subtype<
>;

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __dirname = path.dirname(__filename);

const baseFilePath = join(__dirname, "/var/tmp_files");
const baseFilePath = path.join(__dirname, "/var/tmp_files");

export const generateSimpleStorageContextFilePaths = (params: {
hash: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export const subCoordinatorOmittedCoordinatorToolNames = [
type SubCoordinatorOmittedCoordinatorToolName =
(typeof subCoordinatorOmittedCoordinatorToolNames)[number];

const subCoordinatingAgentCustomToolNames = ["complete"] as const;

export type SubCoordinatingAgentCustomToolName =
(typeof subCoordinatingAgentCustomToolNames)[number];
export type SubCoordinatingAgentCustomToolName = "complete";

export type SubCoordinatingAgentToolName =
| Exclude<CoordinatorToolName, SubCoordinatorOmittedCoordinatorToolName>
Expand Down Expand Up @@ -179,12 +176,12 @@ export const generateToolDefinitions = <
description: dedent(`
Instruct a colleague to help you with a specific part of the research task.
This is useful when the research task is complex and requires multiple people to work on different parts of it.

Make sure that you take account of any information the user has provided you when instructing your colleague,
including the original research brief and any subsequent clarifications. Pass this information on to your colleague
as part of the instructions where it would be helpful.
Where you are seeking additional information on specific entities, make sure to include their ids as relevantEntityIds

Where you are seeking additional information on specific entities, make sure to include their ids as relevantEntityIds
`),
inputSchema: {
type: "object",
Expand All @@ -198,7 +195,7 @@ export const generateToolDefinitions = <
description: dedent(`
The entityId of the proposed entities which the task is relevant to.
If none, pass an empty array.

${
params.state.entitySummaries.length
? `The possible values are: ${params.state.entitySummaries
Expand All @@ -217,8 +214,8 @@ export const generateToolDefinitions = <
2. If you are seeking more information on specific entities:
a. the names of the entities (their ids should be provided under relevantEntityIds)
b. what specific information you are seeking about them
For example

For example
"Find the technical specifications of product X".
"Find the LinkedIn URL for person X"
"Find the release date, director and box office takings for movie X"
Expand All @@ -239,9 +236,9 @@ export const generateToolDefinitions = <
webSearch: {
name: "webSearch",
description:
dedent(`Perform a web search via a web search engine, returning a list of URLs.
dedent(`Perform a web search via a web search engine, returning a list of URLs.
For best results, the query should be specific and concise.
Bear in mind that all the information you require may not be available via a single web search
Bear in mind that all the information you require may not be available via a single web search
– if you have various attributes to gather about specific entities, it may be worth performing multiple searches
for each entity, or for each entity's attribute, until you find suitable results.
`),
Expand All @@ -266,13 +263,13 @@ export const generateToolDefinitions = <
name: "inferClaimsFromResource",
description: dedent(`
Explore a resource in order to discover entities and 'claims' (possible facts) it contains, as well resources linked from it.

The URLs for the resource must have been provided in messages to you,
or as the result of a previous action (e.g. a web search, or in suggestions for next steps). Don't guess URLs!

If you want additional information about entities you already know about, or to find new entities to link to existing entities,
be sure to specify the existing entities under 'relevantEntityIds'.

You can explore multiple resources at once by making multiple calls, but don't start multiple redundant explorations for the same information.
You can always explore another URL if one doesn't return the information you require.
`),
Expand All @@ -288,7 +285,7 @@ export const generateToolDefinitions = <
type: "string",
description: dedent(`
The goal of exploring this specific resource. This will be used to guide what specific entities and claims are discovered.

DO include:
1. What specifies entities or types of entities you are seeking information on
2. Any guidance from the user, whether in the original instructions or subsequent questions and answers, which is relevant to the task
Expand Down Expand Up @@ -320,7 +317,7 @@ export const generateToolDefinitions = <
The entityIds of already proposed entities which you are seeking further detail on, if any.
If you expect new entities you are seeking to be linked to already-discovered entities, specify the already-discovered entities here.
If you are unsure if an entity is relevant, just include it – it's better to include too many than too few.

If there are absolutely no entities relevant, pass an empty array.
`),
},
Expand Down Expand Up @@ -357,7 +354,7 @@ export const generateToolDefinitions = <
type: "string",
},
description: dedent(`
An array of entityIds to highlight.
An array of entityIds to highlight.
The user will receive all entities discovered, with the highlighted entityIds identified for special attention.
You must have made an effort to find as many properties and outgoing links for each entity as possible,
as long as they relate to the research task in question.
Expand Down Expand Up @@ -385,12 +382,12 @@ export const generateToolDefinitions = <
description: dedent(`
Update the plan for the research task.
You can call this alongside other tool calls to progress towards completing the task.

IMPORTANT: the plan should take account of:
1. The research goal
2. The information gathered so far.
Don't be afraid to deviate from an earlier plan if you've gathered sufficient information to

Don't be afraid to deviate from an earlier plan if you've gathered sufficient information to
meet the research goal, and return the information discovered.
`),
inputSchema: {
Expand Down Expand Up @@ -807,10 +804,10 @@ export const generateOutstandingTasksDescription = (
The following tasks are still outstanding. You may decide to do one of the following:
1. Call 'waitForOutstandingTasks' to wait for outstanding tasks, OR
2. Start new tasks.

You may optionally also call 'stopTasks' to stop specific tasks you think are no longer relevant,
whether or not you're creating new tasks or waiting for outstanding tasks, using their 'toolCallId'.

The outstanding tasks are:
${state.outstandingTasks
.map((task) =>
Expand All @@ -822,7 +819,7 @@ export const generateOutstandingTasksDescription = (
`),
)
.join("\n")}

The results of each will be available in due course – but you can stop any now if you think they are no longer relevant.
`);
};
Expand Down
Loading
Loading