Skip to content

Commit 7108fad

Browse files
committed
prettier fixes
added pipeline
1 parent bc5b2eb commit 7108fad

31 files changed

+1206
-303
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "restricted",
7+
"baseBranch": "master",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://www.buymeacoffee.com/JDnuAwr

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: '/'
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 20

.github/workflows/canary.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Canary Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
publish-canary:
10+
name: Publish Canary
11+
runs-on: ubuntu-latest
12+
if: github.event.pull_request.head.repo.full_name == github.repository
13+
steps:
14+
- name: Checkout Master
15+
uses: actions/checkout@v1
16+
- name: Use Node
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: '14.x'
20+
- name: Configure Git Credentials
21+
run: |
22+
git config --global user.email "[email protected]"
23+
git config --global user.name "theguild-bot"
24+
echo "machine github.com login theguild-bot password ${{secrets.GH_API_TOKEN}}" > ~/.netrc
25+
- name: Setup NPM credentials
26+
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
29+
- name: Get yarn cache
30+
id: yarn-cache
31+
run: echo "::set-output name=dir::$(yarn cache dir)"
32+
- name: Cache Yarn
33+
uses: actions/cache@v1
34+
with:
35+
path: ${{ steps.yarn-cache.outputs.dir }}
36+
key: ${{ runner.os }}-14-yarn-${{ hashFiles('yarn.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-14-yarn-
39+
- name: Install Dependencies using Yarn
40+
run: yarn install --ignore-engines && git checkout yarn.lock
41+
- name: Release Canary
42+
id: canary
43+
uses: 'kamilkisiela/release-canary@master'
44+
with:
45+
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
46+
npm-script: 'yarn release:canary'
47+
changesets: true
48+
- name: Publish a message
49+
if: steps.canary.outputs.released
50+
uses: 'kamilkisiela/pr-comment@master'
51+
with:
52+
message: |
53+
The latest changes of this PR are available as alpha in npm (based on the declared `changesets`):
54+
55+
```
56+
${{ steps.canary.outputs.changesetsPublishedPackages}}
57+
```
58+
bot-token: ${{ secrets.GH_API_TOKEN }}
59+
bot: 'theguild-bot'
60+
github-token: ${{ secrets.GITHUB_TOKEN }}
61+
- name: Publish a empty message
62+
if: steps.canary.outputs.released == 'false'
63+
uses: 'kamilkisiela/pr-comment@master'
64+
with:
65+
message: |
66+
The latest changes of this PR are not available as alpha, since there are no linked `changesets` for this PR.
67+
bot-token: ${{ secrets.GH_API_TOKEN }}
68+
bot: 'theguild-bot'
69+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
name: Testing on ${{matrix.os}} and Node ${{matrix.node_version}}
14+
runs-on: ${{matrix.os}}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
node_version: [10, 14]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v1
23+
- name: Use Node ${{matrix.node_version}}
24+
uses: actions/setup-node@master
25+
with:
26+
node-version: ${{ matrix.node_version }}
27+
- name: Get yarn cache
28+
id: yarn-cache
29+
run: echo "::set-output name=dir::$(yarn cache dir)"
30+
- name: Cache Yarn
31+
uses: actions/cache@v1
32+
with:
33+
path: ${{ steps.yarn-cache.outputs.dir }}
34+
key: ${{ runner.os }}-${{matrix.node_version}}-yarn-${{ hashFiles('yarn.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-${{matrix.node_version}}-yarn-
37+
- name: Cache Jest
38+
uses: actions/cache@v1
39+
with:
40+
path: .cache/jest
41+
key: ${{ runner.os }}-${{matrix.node_version}}-jest-${{ hashFiles('yarn.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-${{matrix.node_version}}-jest-
44+
- name: Install Dependencies using Yarn
45+
run: yarn install
46+
- name: Lint
47+
run: yarn lint
48+
- name: Build
49+
run: yarn build
50+
- name: Test
51+
run: yarn test --logHeapUsage
52+
env:
53+
CI: true
54+

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Master
11+
uses: actions/checkout@v1
12+
- name: Configure Git Credentials
13+
run: |
14+
git config --global user.email "[email protected]"
15+
git config --global user.name "theguild-bot"
16+
echo "machine github.com login theguild-bot password ${{secrets.GH_API_TOKEN}}" > ~/.netrc
17+
- name: Add origin remote and refetch master
18+
run: |
19+
git remote rm origin
20+
git remote add origin "https://github.com/${{github.repository}}"
21+
git fetch
22+
git checkout master
23+
git reset --hard
24+
- name: Use Node
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: '14.x'
28+
- name: Setup NPM credentials
29+
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
32+
- name: Get yarn cache
33+
id: yarn-cache
34+
run: echo "::set-output name=dir::$(yarn cache dir)"
35+
- name: Cache Yarn
36+
uses: actions/cache@v1
37+
with:
38+
path: ${{ steps.yarn-cache.outputs.dir }}
39+
key: ${{ runner.os }}-14-15-yarn-${{ hashFiles('yarn.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-14-15-yarn-
42+
- name: Install Dependencies using Yarn
43+
run: yarn install && git checkout yarn.lock
44+
- name: Create Release Pull Request or Publish to npm
45+
id: changesets
46+
uses: changesets/action@master
47+
with:
48+
publish: yarn release
49+
commit: 'chore(release): update monorepo packages versions'
50+
title: 'Upcoming Release Changes'
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"trailingComma": "es5",
3+
"printWidth": 120,
4+
"singleQuote": true,
5+
"arrowParens": "avoid",
6+
"overrides": [
7+
{
8+
"files": "*.flow.js",
9+
"options": {
10+
"parser": "flow"
11+
}
12+
}
13+
]
14+
}

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
"lint": "eslint --ext .ts .",
1212
"prebuild": "rimraf packages/*/dist",
1313
"build": "tsc --project tsconfig.json && bob build",
14-
"test": "jest"
14+
"test": "jest",
15+
"prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{ts,tsx,graphql,yml}\""
1516
},
1617
"devDependencies": {
18+
"@changesets/cli": "2.10.3",
1719
"@typescript-eslint/eslint-plugin": "3.7.1",
1820
"@typescript-eslint/parser": "3.7.1",
1921
"eslint": "7.6.0",
2022
"husky": "4.2.5",
2123
"lint-staged": "10.2.11",
2224
"@types/node": "14.0.27",
2325
"bob-the-bundler": "1.1.0",
24-
"eslint-config-prettier": "6.11.0",
2526
"eslint-config-standard": "14.1.1",
2627
"eslint-plugin-import": "2.22.0",
2728
"eslint-plugin-node": "11.1.0",
2829
"eslint-plugin-promise": "4.2.1",
2930
"eslint-plugin-react-hooks": "4.0.8",
3031
"eslint-plugin-standard": "4.0.1",
32+
"eslint-config-prettier": "6.12.0",
3133
"@types/jest": "26.0.12",
3234
"ts-jest": "26.3.0",
3335
"rimraf": "3.0.2",
@@ -37,6 +39,12 @@
3739
"lint-staged": {
3840
"packages/**/src/**/*.{ts,tsx}": [
3941
"eslint --fix"
42+
],
43+
"**/*.{ts,tsx,graphql,yml}": [
44+
"prettier --write"
45+
],
46+
"**/*.json": [
47+
"prettier --write"
4048
]
4149
}
4250
}

packages/plugin/src/estree-parser/converter.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
import {
2-
convertDescription,
3-
convertLocation,
4-
convertRange,
5-
extractCommentsFromAst,
6-
} from "./utils";
7-
import { GraphQLESTreeNode, SafeGraphQLType } from "./estree-ast";
8-
import {
9-
ASTNode,
10-
TypeNode,
11-
TypeInfo,
12-
visit,
13-
visitWithTypeInfo,
14-
Location,
15-
} from "graphql";
16-
import { Comment } from "estree";
1+
import { convertDescription, convertLocation, convertRange, extractCommentsFromAst } from './utils';
2+
import { GraphQLESTreeNode, SafeGraphQLType } from './estree-ast';
3+
import { ASTNode, TypeNode, TypeInfo, visit, visitWithTypeInfo, Location } from 'graphql';
4+
import { Comment } from 'estree';
175

186
export function convertToESTree<T extends ASTNode>(
197
node: T,
@@ -23,30 +11,23 @@ export function convertToESTree<T extends ASTNode>(
2311
const visitor = { leave: convertNode(typeInfo) };
2412

2513
return {
26-
rootTree: visit(
27-
node,
28-
typeInfo ? visitWithTypeInfo(typeInfo, visitor) : visitor
29-
),
14+
rootTree: visit(node, typeInfo ? visitWithTypeInfo(typeInfo, visitor) : visitor),
3015
comments,
3116
};
3217
}
3318

34-
function hasTypeField<T extends ASTNode>(
35-
obj: any
36-
): obj is T & { readonly type: TypeNode } {
19+
function hasTypeField<T extends ASTNode>(obj: any): obj is T & { readonly type: TypeNode } {
3720
return obj && !!(obj as any).type;
3821
}
3922

40-
function stripTokens(location: Location): Pick<Location, "start" | "end"> {
23+
function stripTokens(location: Location): Pick<Location, 'start' | 'end'> {
4124
return {
4225
end: location.end,
4326
start: location.start,
4427
};
4528
}
4629

47-
const convertNode = (typeInfo?: TypeInfo) => <T extends ASTNode>(
48-
node: T
49-
): GraphQLESTreeNode<T> => {
30+
const convertNode = (typeInfo?: TypeInfo) => <T extends ASTNode>(node: T): GraphQLESTreeNode<T> => {
5031
const calculatedTypeInfo = typeInfo
5132
? {
5233
argument: typeInfo.getArgument(),
@@ -85,9 +66,7 @@ const convertNode = (typeInfo?: TypeInfo) => <T extends ASTNode>(
8566
return estreeNode;
8667
} else {
8768
const { loc: gqlLocation, ...rest } = node;
88-
const typeFieldSafe: SafeGraphQLType<T> = rest as SafeGraphQLType<
89-
T & { readonly type: TypeNode }
90-
>;
69+
const typeFieldSafe: SafeGraphQLType<T> = rest as SafeGraphQLType<T & { readonly type: TypeNode }>;
9170
const estreeNode: GraphQLESTreeNode<T> = ({
9271
...typeFieldSafe,
9372
...commonFields,

0 commit comments

Comments
 (0)