Skip to content

Commit 2a3848f

Browse files
authored
Use ESLint+Prettier to lint the whole repo, and fix Benchmark per each PR (contra#58)
1 parent d2163bb commit 2a3848f

File tree

17 files changed

+805
-359
lines changed

17 files changed

+805
-359
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages/core/lib/render-graphiql.ts
2+
packages/deno/

.eslintrc.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"eslint:recommended",
5+
"standard",
6+
"prettier",
7+
"plugin:@typescript-eslint/recommended"
8+
],
9+
"plugins": ["@typescript-eslint", "promise"],
10+
"rules": {
11+
"no-empty": "off",
12+
"no-console": "error",
13+
"no-prototype-builtins": "off",
14+
"no-useless-constructor": "off",
15+
"@typescript-eslint/no-unused-vars": ["warn", {"args": "none"}],
16+
"@typescript-eslint/no-use-before-define": "off",
17+
"@typescript-eslint/no-namespace": "off",
18+
"@typescript-eslint/no-empty-interface": "off",
19+
"@typescript-eslint/no-empty-function": "off",
20+
"@typescript-eslint/no-var-requires": "off",
21+
"@typescript-eslint/no-explicit-any": "off",
22+
"@typescript-eslint/no-non-null-assertion": "off",
23+
"@typescript-eslint/explicit-function-return-type": "off",
24+
"@typescript-eslint/ban-ts-ignore": "off",
25+
"@typescript-eslint/ban-types": "off",
26+
"no-use-before-define": "off"
27+
},
28+
"env": {
29+
"es6": true,
30+
"node": true
31+
},
32+
"overrides": [
33+
{
34+
"files": [
35+
"./packages/deno/**/*.ts",
36+
"./benchmark/**/*.js"
37+
],
38+
"rules": {
39+
}
40+
},
41+
{
42+
"files": [
43+
"./examples/**/*.ts"
44+
],
45+
"rules": {
46+
"no-console": "off"
47+
}
48+
},
49+
{
50+
"files": [
51+
"**/tests/**/*.ts",
52+
"**/test/**/*.ts",
53+
"*.spec.ts"
54+
],
55+
"env": {
56+
"jest": true
57+
},
58+
"rules": {
59+
"@typescript-eslint/no-unused-vars": "off",
60+
"@typescript-eslint/explicit-module-boundary-types": "off"
61+
}
62+
}
63+
],
64+
"ignorePatterns": ["dist", "node_modules", "dev-test", "website"]
65+
}

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
run: |
4040
yarn loadtest:start-server &
4141
yarn wait-on tcp:5000
42-
k6 -e GITHUB_PR=${{ github.event.number }} -e GITHUB_SHA=${{ github.sha }} -e GITHUB_TOKEN=${{secrets.GH_API_TOKEN}} -e GRAPHQL_HOSTNAME=0.0.0.0 run ./benchmark/k6.js
42+
k6 -e GITHUB_PR=${{ github.event.number }} -e GITHUB_SHA=${{ github.sha }} -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} -e GRAPHQL_HOSTNAME=0.0.0.0 run ./benchmark/k6.js

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ jobs:
1717
with:
1818
node-version: ${{ matrix.node-version }}
1919
- run: yarn install --frozen-lockfile
20-
- run: yarn workspace graphql-helix lint
21-
- run: yarn workspace @graphql-helix/graphiql lint
20+
- run: yarn lint
2221
- run: yarn workspace graphql-helix build
2322
- run: yarn workspace graphql-helix test
2423
env:

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ node_modules
66
!.github
77
!.prettierignore
88
!.prettierrc
9-
9+
!.eslintrc.json
10+
!.eslintignore

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 80,
2+
"printWidth": 130,
33
"jsxSingleQuote": false,
44
"tabWidth": 2,
55
"useTabs": false,

benchmark/github.js

-200
This file was deleted.

benchmark/k6.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { check } from "k6";
33
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
44
import { graphql, checkNoErrors } from "./utils.js";
5-
import { githubComment } from "./github.js";
5+
import { githubComment } from "https://raw.githubusercontent.com/dotansimha/k6-github-pr-comment/master/lib.js";
66

77
export const options = {
88
vus: 1,
@@ -19,8 +19,8 @@ export function handleSummary(data) {
1919
token: __ENV.GITHUB_TOKEN,
2020
commit: __ENV.GITHUB_SHA,
2121
pr: __ENV.GITHUB_PR,
22-
org: "dotansimha",
23-
repo: "envelop",
22+
org: "contrawork",
23+
repo: "graphql-helix",
2424
renderTitle({ passes }) {
2525
return passes ? "✅ Benchmark Results" : "❌ Benchmark Failed";
2626
},
@@ -34,15 +34,11 @@ export function handleSummary(data) {
3434
}
3535

3636
if (checks.failures) {
37-
result.push(
38-
"**Failed assertions detected**: some GraphQL operations included in the loadtest are failing."
39-
);
37+
result.push("**Failed assertions detected**: some GraphQL operations included in the loadtest are failing.");
4038
}
4139

4240
if (!passes) {
43-
result.push(
44-
`> If the performance regression is expected, please increase the failing threshold.`
45-
);
41+
result.push(`> If the performance regression is expected, please increase the failing threshold.`);
4642
}
4743

4844
return result.join("\n");

package.json

+19-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"examples/*"
1414
],
1515
"scripts": {
16+
"lint": "eslint --ext .ts,.tsx .",
1617
"publish": "node scripts/publish",
1718
"update-examples": "node scripts/update-examples",
1819
"loadtest:start-server": "node ./benchmark/server.js"
@@ -23,14 +24,30 @@
2324
}
2425
},
2526
"lint-staged": {
26-
"*.{js,ts,tsx,json,css}": "prettier --write"
27+
"*.{ts,tsx}": [
28+
"eslint --fix"
29+
],
30+
"**/*.{ts,tsx,graphql,yml}": [
31+
"prettier --write"
32+
],
33+
"**/*.json": [
34+
"prettier --write"
35+
]
2736
},
2837
"devDependencies": {
2938
"@changesets/cli": "2.17.0",
3039
"@types/k6": "0.32.2",
40+
"@typescript-eslint/eslint-plugin": "^4.31.2",
41+
"@typescript-eslint/parser": "4.31.2",
42+
"eslint": "7.32.0",
43+
"eslint-config-prettier": "8.3.0",
44+
"eslint-config-standard": "16.0.3",
45+
"eslint-plugin-import": "2.24.2",
46+
"eslint-plugin-node": "11.1.0",
47+
"eslint-plugin-promise": "5.1.0",
3148
"husky": "7.0.2",
3249
"lint-staged": "11.1.2",
33-
"prettier": "2.4.0",
50+
"prettier": "2.4.1",
3451
"wait-on": "6.0.0"
3552
},
3653
"resolutions": {

0 commit comments

Comments
 (0)