Skip to content

Commit

Permalink
Add Prettier Check GitHub action (#3838)
Browse files Browse the repository at this point in the history
* add `.prettierignore` to ignore invalid test fixtures

* prettify javascript/typescript files

* prettify graphql files

* prettify md,mdx,json,yml files

* add prettier-check github action

* fix tests on ci
  • Loading branch information
Dimitri POSTOLOV authored Nov 7, 2021
1 parent 83b304c commit ca8dc52
Show file tree
Hide file tree
Showing 281 changed files with 10,308 additions and 8,140 deletions.
4 changes: 1 addition & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [
"@graphql-tools/website"
]
"ignore": ["@graphql-tools/website"]
}
16 changes: 4 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"eslint:recommended",
"standard",
"prettier",
"plugin:@typescript-eslint/recommended"
],
"extends": ["eslint:recommended", "standard", "prettier", "plugin:@typescript-eslint/recommended"],
"plugins": ["@typescript-eslint"],
"rules": {
"no-empty": "off",
Expand All @@ -35,18 +30,15 @@
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"default-param-last": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.ts", "**/*.spec.ts"]}]
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/*.test.ts", "**/*.spec.ts"] }]
},
"env": {
"es6": true,
"node": true
},
"overrides": [
{
"files": [
"**/{test,tests,testing}/**/*.{ts,js}",
"*.{spec,test}.{ts,js}"
],
"files": ["**/{test,tests,testing}/**/*.{ts,js}", "*.{spec,test}.{ts,js}"],
"env": {
"jest": true
},
Expand All @@ -65,7 +57,7 @@
"packages/loaders/code-file/tests/test-files",
"packages/loaders/git/tests/test-files"
],
"globals":{
"globals": {
"BigInt": true
}
}
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ about: Create a bug report to help us improve
---

**Describe the bug**

<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
Expand All @@ -12,6 +13,7 @@ Steps to reproduce the behavior:
<!-- Adding a codesandbox can help us understand the bug better and speed up things -->

**Expected behavior**

<!-- A clear and concise description of what you expected to happen. -->

**Environment:**
Expand All @@ -21,4 +23,5 @@ Steps to reproduce the behavior:
- NodeJS:

**Additional context**

<!-- Add any other context about the problem here. -->
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
---
name: Feature Request
about: Suggest an idea for the core of this project

---

**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**

<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**

<!-- Add any other context or screenshots about the feature request here. -->
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

🚨 **IMPORTANT: Please do not create a Pull Request without creating an issue first.**

*Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.*
_Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request._

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Related # (issue)

<!--
Please do not use "Fixed" or "Resolves". Keep "Related" as-is.
-->
Expand All @@ -39,6 +40,7 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] Test B

**Test Environment**:

- OS:
- `@graphql-tools/...`:
- NodeJS:
Expand Down
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]

jobs:
analyze:
Expand All @@ -30,40 +30,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ on:
pull_request: {}

jobs:
prettier-check:
name: 🧹 Prettier Check
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@master
with:
node-version: 17
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{runner.os}}-17-16-yarn-${{hashFiles('yarn.lock')}}
restore-keys: |
${{runner.os}}-17-16-yarn
- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Prettier Check
run: yarn prettier:check
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
23 changes: 20 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
dist
tests
tests
spec
packages/import/tests/schema/fixtures/import-duplicate/all.graphql
packages/import/tests/schema/fixtures/imports-only/all.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/1/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/2/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/3/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/4/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/5/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/6/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/7/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/8/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/9/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/10/index.graphql
packages/import/tests/schema/fixtures/multiple-directories-with-master-schema/index.graphql
packages/import/tests/schema/fixtures/multiple-imports/schema.graphql
packages/import/tests/schema/fixtures/multiple-levels-master-schema/level1.graphql
packages/load/tests/loaders/documents/test-invalid-syntax/invalid-syntax.query.graphql
packages/load/tests/loaders/schema/test-files/error.ts
packages/load/tests/loaders/schema/test-files/schema-dir/invalid.graphql
packages/loaders/git/tests/test-files/type-defs-invalid.graphql
packages/loaders/json-file/tests/test-files/failing/malformed.json
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Here are some ways to contribute to the project, from easiest to most difficult:

* [Reporting bugs](#reporting-bugs)
* [Improving the documentation](#improving-the-documentation)
* [Responding to issues](#responding-to-issues)
* [Small bug fixes](#small-bug-fixes)
* [Suggesting features](#suggesting-features)
* [Big pull requests](#big-prs)
- [Reporting bugs](#reporting-bugs)
- [Improving the documentation](#improving-the-documentation)
- [Responding to issues](#responding-to-issues)
- [Small bug fixes](#small-bug-fixes)
- [Suggesting features](#suggesting-features)
- [Big pull requests](#big-prs)

## Issues

Expand Down
85 changes: 42 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ This package provides a few useful ways to create a GraphQL schema:

1. Use the GraphQL schema language to [generate a schema](https://graphql-tools.com/docs/generate-schema) with full support for resolvers, interfaces, unions, and custom scalars. The schema produced is completely compatible with [GraphQL.js](https://github.com/graphql/graphql-js).
2. [Mock your GraphQL API](https://graphql-tools.com/docs/mocking) with fine-grained per-type mocking
3. Automatically [stitch multiple schemas together](https://www.graphql-tools.com/docs/stitch-combining-schemas
) into one larger API
3. Automatically [stitch multiple schemas together](https://www.graphql-tools.com/docs/stitch-combining-schemas) into one larger API

## Documentation

Expand All @@ -31,43 +30,40 @@ You can develop your JavaScript based GraphQL API with `graphql-tools` and `expr
When using `graphql-tools`, you describe the schema as a GraphQL type language string:

```js

const typeDefs = /* GraphQL */`
type Author {
id: ID! # the ! means that every author object _must_ have an id
firstName: String
lastName: String
"""
the list of Posts by this author
"""
posts: [Post]
}
type Post {
id: ID!
title: String
author: Author
votes: Int
}
# the schema allows the following query:
type Query {
posts: [Post]
}
# this schema allows the following mutation:
type Mutation {
upvotePost (
postId: ID!
): Post
}
# we need to tell the server which types represent the root query
# and root mutation types. We call them RootQuery and RootMutation by convention.
schema {
query: Query
mutation: Mutation
}
const typeDefs = /* GraphQL */ `
type Author {
id: ID! # the ! means that every author object _must_ have an id
firstName: String
lastName: String
"""
the list of Posts by this author
"""
posts: [Post]
}
type Post {
id: ID!
title: String
author: Author
votes: Int
}
# the schema allows the following query:
type Query {
posts: [Post]
}
# this schema allows the following mutation:
type Mutation {
upvotePost(postId: ID!): Post
}
# we need to tell the server which types represent the root query
# and root mutation types. We call them RootQuery and RootMutation by convention.
schema {
query: Query
mutation: Mutation
}
`;

export default typeDefs;
Expand Down Expand Up @@ -126,10 +122,13 @@ var express = require('express');
var { graphqlHTTP } = require('express-graphql');

var app = express();
app.use('/graphql', graphqlHTTP({
schema: executableSchema,
graphiql: true,
}));
app.use(
'/graphql',
graphqlHTTP({
schema: executableSchema,
graphiql: true,
})
);
app.listen(4000);
console.log('Running a GraphQL API server at http://localhost:4000/graphql');
```
Expand Down
1 change: 0 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Security Policy

## Supported Versions
Expand Down
2 changes: 1 addition & 1 deletion benchmark/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ function createReport(pointer) {

const pointers = rawPointers.map(createReport);

const stats = pointers.map(pointer => `${pointer.name}: ${pointer.avg.toFixed(2)} ms`).join('\n')
const stats = pointers.map(pointer => `${pointer.name}: ${pointer.avg.toFixed(2)} ms`).join('\n');

console.log(stats);
Loading

1 comment on commit ca8dc52

@vercel
Copy link

@vercel vercel bot commented on ca8dc52 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.