Skip to content

move to Biome for linting #267

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

Merged
merged 2 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Please explain the changes you made here.
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to
this PR
- [ ] Tests added for new functionality, or regression tests for bug fixes added as applicable
- [ ] For public APIs, new features, etc., PR on
[docs repo](https://github.com/hypermodeinc/docs) staged and linked here
- [ ] For public APIs, new features, etc., PR on [docs repo](https://github.com/hypermodeinc/docs)
staged and linked here

**Instructions**

Expand Down
6 changes: 3 additions & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>hypermodeinc/renovate-config"],
"rangeStrategy": "widen"
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>hypermodeinc/renovate-config"],
"rangeStrategy": "widen"
}
12 changes: 6 additions & 6 deletions .trunk/configs/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"line-length": { "line_length": 150, "tables": false },
"no-inline-html": false,
"no-bare-urls": false,
"no-space-in-emphasis": false,
"no-emphasis-as-heading": false,
"first-line-heading": false
"line-length": { "line_length": 150, "tables": false },
"no-inline-html": false,
"no-bare-urls": false,
"no-space-in-emphasis": false,
"no-emphasis-as-heading": false,
"first-line-heading": false
}
10 changes: 0 additions & 10 deletions .trunk/configs/eslint.config.js

This file was deleted.

26 changes: 18 additions & 8 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
version: 0.1

cli:
version: 1.22.10
version: 1.22.12

# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
Expand All @@ -25,19 +25,29 @@ lint:
- linters: [ALL]
paths:
- generated/**
- linters: [prettier]
paths:
- "**/*.ts"
- "**/*.tsx"
- "**/*.js"
- "**/*.jsx"
- "**/*.css"
- "**/*.html"
- "**/*.json"
enabled:
- trivy@0.59.1
- trivy@0.61.0
- [email protected]
- [email protected].365
- [email protected].396
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected].4
- yamllint@1.35.1
- [email protected].22
- yamllint@1.37.0
actions:
enabled:
- trunk-announce
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["trunk.io"]
"recommendations": ["trunk.io"]
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "trunk.io",
"editor.trimAutoWhitespace": true,
"trunk.autoInit": false
"editor.formatOnSave": true,
"editor.defaultFormatter": "trunk.io",
"editor.trimAutoWhitespace": true,
"trunk.autoInit": false
}
180 changes: 94 additions & 86 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,97 @@
const dgraph = require("dgraph-js")
const dgraph = require("dgraph-js");
// Drop All - discard all data, schema and start from a clean slate.
async function dropAll(dgraphClient) {
const op = new dgraph.Operation()
op.setDropAll(true)
await dgraphClient.alter(op)
const op = new dgraph.Operation();
op.setDropAll(true);
await dgraphClient.alter(op);
}

// Drop All Data, but keep the schema.
async function dropData(dgraphClient) {
const op = new dgraph.Operation()
op.setDropOp(dgraph.Operation.DropOp.DATA)
await dgraphClient.alter(op)
const op = new dgraph.Operation();
op.setDropOp(dgraph.Operation.DropOp.DATA);
await dgraphClient.alter(op);
}

// Set schema.
async function setSchema(dgraphClient) {
const schema = `
const schema = `
name: string @index(exact) .
age: int .
married: bool .
loc: geo .
dob: datetime .
friend: [uid] @reverse .
`
const op = new dgraph.Operation()
op.setSchema(schema)
await dgraphClient.alter(op)
`;
const op = new dgraph.Operation();
op.setSchema(schema);
await dgraphClient.alter(op);
}

// Create data using JSON.
async function createData(dgraphClient) {
// Create a new transaction.
const txn = dgraphClient.newTxn()
try {
// Create data.
const p = {
uid: "_:alice",
name: "Alice",
age: 26,
married: true,
loc: {
type: "Point",
coordinates: [1.1, 2],
},
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
friend: [
{
name: "Bob",
age: 24,
},
{
name: "Charlie",
age: 29,
},
],
school: [
{
name: "Crown Public School",
},
],
}
// Create a new transaction.
const txn = dgraphClient.newTxn();
try {
// Create data.
const p = {
uid: "_:alice",
name: "Alice",
age: 26,
married: true,
loc: {
type: "Point",
coordinates: [1.1, 2],
},
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
friend: [
{
name: "Bob",
age: 24,
},
{
name: "Charlie",
age: 29,
},
],
school: [
{
name: "Crown Public School",
},
],
};

// Run mutation.
const mu = new dgraph.Mutation()
mu.setSetJson(p)
const response = await txn.mutate(mu)
// Run mutation.
const mu = new dgraph.Mutation();
mu.setSetJson(p);
const response = await txn.mutate(mu);

// Commit transaction.
await txn.commit()
// Commit transaction.
await txn.commit();

// Get uid of the outermost object (person named "Alice").
// Response#getUidsMap() returns a map from blank node names to uids.
// For a json mutation, blank node label is used for the name of the created nodes.
console.log(`Created person named "Alice" with uid = ${response.getUidsMap().get("alice")}\n`)
// Get uid of the outermost object (person named "Alice").
// Response#getUidsMap() returns a map from blank node names to uids.
// For a json mutation, blank node label is used for the name of the created nodes.
console.log(
`Created person named "Alice" with uid = ${response.getUidsMap().get("alice")}\n`,
);

console.log("All created nodes (map from blank node names to uids):")
response.getUidsMap().forEach((uid, key) => console.log(`${key} => ${uid}`))
console.log()
} finally {
// Clean up. Calling this after txn.commit() is a no-op
// and hence safe.
await txn.discard()
}
console.log("All created nodes (map from blank node names to uids):");
response
.getUidsMap()
.forEach((uid, key) => console.log(`${key} => ${uid}`));
console.log();
} finally {
// Clean up. Calling this after txn.commit() is a no-op
// and hence safe.
await txn.discard();
}
}

// Query for data.
async function queryData(dgraphClient) {
// Run query.
const query = `query all($a: string) {
// Run query.
const query = `query all($a: string) {
all(func: eq(name, $a)) {
uid
name
Expand All @@ -103,35 +107,39 @@ async function queryData(dgraphClient) {
name
}
}
}`
const vars = { $a: "Alice" }
const res = await dgraphClient.newTxn({ readOnly: true }).queryWithVars(query, vars)
const ppl = res.getJson()
}`;
const vars = { $a: "Alice" };
const res = await dgraphClient
.newTxn({ readOnly: true })
.queryWithVars(query, vars);
const ppl = res.getJson();

// Print results.
console.log(`Number of people named "Alice": ${ppl.all.length}`)
ppl.all.forEach((person) => console.log(person))
// Print results.
console.log(`Number of people named "Alice": ${ppl.all.length}`);
ppl.all.forEach((person) => console.log(person));
}

async function main() {
const dgraphClient = await dgraph.open("dgraph://groot:password@localhost:9080")
await dropAll(dgraphClient)
await setSchema(dgraphClient)
await createData(dgraphClient)
await queryData(dgraphClient)
await dropData(dgraphClient)
await queryData(dgraphClient)
await createData(dgraphClient)
await queryData(dgraphClient)
const dgraphClient = await dgraph.open(
"dgraph://groot:password@localhost:9080",
);
await dropAll(dgraphClient);
await setSchema(dgraphClient);
await createData(dgraphClient);
await queryData(dgraphClient);
await dropData(dgraphClient);
await queryData(dgraphClient);
await createData(dgraphClient);
await queryData(dgraphClient);

// Close the client stub.
dgraphClient.close()
// Close the client stub.
dgraphClient.close();
}

main()
.then(() => {
console.log("\nDONE!")
})
.catch((e) => {
console.log("ERROR: ", e)
})
.then(() => {
console.log("\nDONE!");
})
.catch((e) => {
console.log("ERROR: ", e);
});
18 changes: 9 additions & 9 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "simple",
"dependencies": {
"dgraph-js": "^24.2.0",
"@grpc/grpc-js": "1.8.22"
},
"scripts": {
"example": "node index.js",
"clean": "rm -fr node_modules"
}
"name": "simple",
"dependencies": {
"dgraph-js": "^24.2.0",
"@grpc/grpc-js": "1.8.22"
},
"scripts": {
"example": "node index.js",
"clean": "rm -fr node_modules"
}
}
28 changes: 14 additions & 14 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
testEnvironment: "node",
transform: {
".(ts|tsx)": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$",
coverageDirectory: "coverage",
collectCoverageFrom: [
"src/**/*.{ts,tsx,js,jsx}",
"!src/index.{ts,tsx,js,jsx}",
"!src/generated/**/*.{ts,tsx,js,jsx}",
"!src/**/*.d.ts",
],
}
testEnvironment: "node",
transform: {
".(ts|tsx)": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$",
coverageDirectory: "coverage",
collectCoverageFrom: [
"src/**/*.{ts,tsx,js,jsx}",
"!src/index.{ts,tsx,js,jsx}",
"!src/generated/**/*.{ts,tsx,js,jsx}",
"!src/**/*.d.ts",
],
};
Loading
Loading