Skip to content

Commit 94e9947

Browse files
authored
move to Biome for linting (#267)
1 parent 39ac0c6 commit 94e9947

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+9989
-10956
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Please explain the changes you made here.
88
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to
99
this PR
1010
- [ ] Tests added for new functionality, or regression tests for bug fixes added as applicable
11-
- [ ] For public APIs, new features, etc., PR on
12-
[docs repo](https://github.com/hypermodeinc/docs) staged and linked here
11+
- [ ] For public APIs, new features, etc., PR on [docs repo](https://github.com/hypermodeinc/docs)
12+
staged and linked here
1313

1414
**Instructions**
1515

.github/renovate.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["local>hypermodeinc/renovate-config"],
4-
"rangeStrategy": "widen"
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["local>hypermodeinc/renovate-config"],
4+
"rangeStrategy": "widen"
55
}

.trunk/configs/.markdownlint.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"line-length": { "line_length": 150, "tables": false },
3-
"no-inline-html": false,
4-
"no-bare-urls": false,
5-
"no-space-in-emphasis": false,
6-
"no-emphasis-as-heading": false,
7-
"first-line-heading": false
2+
"line-length": { "line_length": 150, "tables": false },
3+
"no-inline-html": false,
4+
"no-bare-urls": false,
5+
"no-space-in-emphasis": false,
6+
"no-emphasis-as-heading": false,
7+
"first-line-heading": false
88
}

.trunk/configs/eslint.config.js

-10
This file was deleted.

.trunk/trunk.yaml

+18-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
version: 0.1
44

55
cli:
6-
version: 1.22.10
6+
version: 1.22.12
77

88
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
99
plugins:
@@ -25,19 +25,29 @@ lint:
2525
- linters: [ALL]
2626
paths:
2727
- generated/**
28+
- linters: [prettier]
29+
paths:
30+
- "**/*.ts"
31+
- "**/*.tsx"
32+
- "**/*.js"
33+
- "**/*.jsx"
34+
- "**/*.css"
35+
- "**/*.html"
36+
- "**/*.json"
2837
enabled:
29-
- trivy@0.59.1
38+
- trivy@0.61.0
3039
31-
40+
3241
- git-diff-check
3342
34-
35-
36-
43+
44+
45+
46+
3747
3848
39-
40-
- yamllint@1.35.1
49+
50+
- yamllint@1.37.0
4151
actions:
4252
enabled:
4353
- trunk-announce

.vscode/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["trunk.io"]
2+
"recommendations": ["trunk.io"]
33
}

.vscode/settings.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"editor.formatOnSave": true,
3-
"editor.defaultFormatter": "trunk.io",
4-
"editor.trimAutoWhitespace": true,
5-
"trunk.autoInit": false
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "trunk.io",
4+
"editor.trimAutoWhitespace": true,
5+
"trunk.autoInit": false
66
}

examples/simple/index.js

+94-86
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,97 @@
1-
const dgraph = require("dgraph-js")
1+
const dgraph = require("dgraph-js");
22
// Drop All - discard all data, schema and start from a clean slate.
33
async function dropAll(dgraphClient) {
4-
const op = new dgraph.Operation()
5-
op.setDropAll(true)
6-
await dgraphClient.alter(op)
4+
const op = new dgraph.Operation();
5+
op.setDropAll(true);
6+
await dgraphClient.alter(op);
77
}
88

99
// Drop All Data, but keep the schema.
1010
async function dropData(dgraphClient) {
11-
const op = new dgraph.Operation()
12-
op.setDropOp(dgraph.Operation.DropOp.DATA)
13-
await dgraphClient.alter(op)
11+
const op = new dgraph.Operation();
12+
op.setDropOp(dgraph.Operation.DropOp.DATA);
13+
await dgraphClient.alter(op);
1414
}
1515

1616
// Set schema.
1717
async function setSchema(dgraphClient) {
18-
const schema = `
18+
const schema = `
1919
name: string @index(exact) .
2020
age: int .
2121
married: bool .
2222
loc: geo .
2323
dob: datetime .
2424
friend: [uid] @reverse .
25-
`
26-
const op = new dgraph.Operation()
27-
op.setSchema(schema)
28-
await dgraphClient.alter(op)
25+
`;
26+
const op = new dgraph.Operation();
27+
op.setSchema(schema);
28+
await dgraphClient.alter(op);
2929
}
3030

3131
// Create data using JSON.
3232
async function createData(dgraphClient) {
33-
// Create a new transaction.
34-
const txn = dgraphClient.newTxn()
35-
try {
36-
// Create data.
37-
const p = {
38-
uid: "_:alice",
39-
name: "Alice",
40-
age: 26,
41-
married: true,
42-
loc: {
43-
type: "Point",
44-
coordinates: [1.1, 2],
45-
},
46-
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
47-
friend: [
48-
{
49-
name: "Bob",
50-
age: 24,
51-
},
52-
{
53-
name: "Charlie",
54-
age: 29,
55-
},
56-
],
57-
school: [
58-
{
59-
name: "Crown Public School",
60-
},
61-
],
62-
}
33+
// Create a new transaction.
34+
const txn = dgraphClient.newTxn();
35+
try {
36+
// Create data.
37+
const p = {
38+
uid: "_:alice",
39+
name: "Alice",
40+
age: 26,
41+
married: true,
42+
loc: {
43+
type: "Point",
44+
coordinates: [1.1, 2],
45+
},
46+
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
47+
friend: [
48+
{
49+
name: "Bob",
50+
age: 24,
51+
},
52+
{
53+
name: "Charlie",
54+
age: 29,
55+
},
56+
],
57+
school: [
58+
{
59+
name: "Crown Public School",
60+
},
61+
],
62+
};
6363

64-
// Run mutation.
65-
const mu = new dgraph.Mutation()
66-
mu.setSetJson(p)
67-
const response = await txn.mutate(mu)
64+
// Run mutation.
65+
const mu = new dgraph.Mutation();
66+
mu.setSetJson(p);
67+
const response = await txn.mutate(mu);
6868

69-
// Commit transaction.
70-
await txn.commit()
69+
// Commit transaction.
70+
await txn.commit();
7171

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

77-
console.log("All created nodes (map from blank node names to uids):")
78-
response.getUidsMap().forEach((uid, key) => console.log(`${key} => ${uid}`))
79-
console.log()
80-
} finally {
81-
// Clean up. Calling this after txn.commit() is a no-op
82-
// and hence safe.
83-
await txn.discard()
84-
}
79+
console.log("All created nodes (map from blank node names to uids):");
80+
response
81+
.getUidsMap()
82+
.forEach((uid, key) => console.log(`${key} => ${uid}`));
83+
console.log();
84+
} finally {
85+
// Clean up. Calling this after txn.commit() is a no-op
86+
// and hence safe.
87+
await txn.discard();
88+
}
8589
}
8690

8791
// Query for data.
8892
async function queryData(dgraphClient) {
89-
// Run query.
90-
const query = `query all($a: string) {
93+
// Run query.
94+
const query = `query all($a: string) {
9195
all(func: eq(name, $a)) {
9296
uid
9397
name
@@ -103,35 +107,39 @@ async function queryData(dgraphClient) {
103107
name
104108
}
105109
}
106-
}`
107-
const vars = { $a: "Alice" }
108-
const res = await dgraphClient.newTxn({ readOnly: true }).queryWithVars(query, vars)
109-
const ppl = res.getJson()
110+
}`;
111+
const vars = { $a: "Alice" };
112+
const res = await dgraphClient
113+
.newTxn({ readOnly: true })
114+
.queryWithVars(query, vars);
115+
const ppl = res.getJson();
110116

111-
// Print results.
112-
console.log(`Number of people named "Alice": ${ppl.all.length}`)
113-
ppl.all.forEach((person) => console.log(person))
117+
// Print results.
118+
console.log(`Number of people named "Alice": ${ppl.all.length}`);
119+
ppl.all.forEach((person) => console.log(person));
114120
}
115121

116122
async function main() {
117-
const dgraphClient = await dgraph.open("dgraph://groot:password@localhost:9080")
118-
await dropAll(dgraphClient)
119-
await setSchema(dgraphClient)
120-
await createData(dgraphClient)
121-
await queryData(dgraphClient)
122-
await dropData(dgraphClient)
123-
await queryData(dgraphClient)
124-
await createData(dgraphClient)
125-
await queryData(dgraphClient)
123+
const dgraphClient = await dgraph.open(
124+
"dgraph://groot:password@localhost:9080",
125+
);
126+
await dropAll(dgraphClient);
127+
await setSchema(dgraphClient);
128+
await createData(dgraphClient);
129+
await queryData(dgraphClient);
130+
await dropData(dgraphClient);
131+
await queryData(dgraphClient);
132+
await createData(dgraphClient);
133+
await queryData(dgraphClient);
126134

127-
// Close the client stub.
128-
dgraphClient.close()
135+
// Close the client stub.
136+
dgraphClient.close();
129137
}
130138

131139
main()
132-
.then(() => {
133-
console.log("\nDONE!")
134-
})
135-
.catch((e) => {
136-
console.log("ERROR: ", e)
137-
})
140+
.then(() => {
141+
console.log("\nDONE!");
142+
})
143+
.catch((e) => {
144+
console.log("ERROR: ", e);
145+
});

examples/simple/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "simple",
3-
"dependencies": {
4-
"dgraph-js": "^24.2.0",
5-
"@grpc/grpc-js": "1.8.22"
6-
},
7-
"scripts": {
8-
"example": "node index.js",
9-
"clean": "rm -fr node_modules"
10-
}
2+
"name": "simple",
3+
"dependencies": {
4+
"dgraph-js": "^24.2.0",
5+
"@grpc/grpc-js": "1.8.22"
6+
},
7+
"scripts": {
8+
"example": "node index.js",
9+
"clean": "rm -fr node_modules"
10+
}
1111
}

jest.config.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module.exports = {
2-
testEnvironment: "node",
3-
transform: {
4-
".(ts|tsx)": "ts-jest",
5-
},
6-
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
7-
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$",
8-
coverageDirectory: "coverage",
9-
collectCoverageFrom: [
10-
"src/**/*.{ts,tsx,js,jsx}",
11-
"!src/index.{ts,tsx,js,jsx}",
12-
"!src/generated/**/*.{ts,tsx,js,jsx}",
13-
"!src/**/*.d.ts",
14-
],
15-
}
2+
testEnvironment: "node",
3+
transform: {
4+
".(ts|tsx)": "ts-jest",
5+
},
6+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
7+
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(ts|js)x?$",
8+
coverageDirectory: "coverage",
9+
collectCoverageFrom: [
10+
"src/**/*.{ts,tsx,js,jsx}",
11+
"!src/index.{ts,tsx,js,jsx}",
12+
"!src/generated/**/*.{ts,tsx,js,jsx}",
13+
"!src/**/*.d.ts",
14+
],
15+
};

0 commit comments

Comments
 (0)