Skip to content

Commit

Permalink
chore: eslint x graphql support
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Aug 25, 2022
1 parent d73bba2 commit eb52b2e
Show file tree
Hide file tree
Showing 8 changed files with 739 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ahmadnassri
anson
ardatan
autocrlf
autosetuprebase
bdel
Expand All @@ -23,9 +24,11 @@ esbenp
fbca
fpnv
gpgsign
graphqlrc
hmarr
iife
keyid
larsgw
lcov
lintstagedrc
micnncim
Expand Down
8 changes: 8 additions & 0 deletions .eslintrc.base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,14 @@ const config = {
'unicorn/no-keyword-prefix': 0
}
},
{
files: ['*.gql'],
extends: ['plugin:@graphql-eslint/operations-all'],
rules: {
'@graphql-eslint/no-anonymous-operations': 0,
'@graphql-eslint/require-id-when-available': 0
}
},
{
files: ['*.json'],
extends: ['plugin:jsonc/prettier'],
Expand Down
4 changes: 2 additions & 2 deletions .github/graphql/queries/linked-issues.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query ($owner: String!, $repo: String!, $pr: Int!, $limit: Int = 20) {
repository(owner: $owner, name: $repo) {
query ($limit: Int = 20, $owner: String!, $pr: Int!, $repo: String!) {
repository(name: $repo, owner: $owner) {
pullRequest(number: $pr) {
closingIssuesReferences(
first: $limit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/label-linked-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
uses: octokit/[email protected]
with:
query: |
query ($owner: String!, $repo: String!, $pr: Int!, $limit: Int = 20) {
repository(owner: $owner, name: $repo) {
query ($limit: Int = 20, $owner: String!, $pr: Int!, $repo: String!) {
repository(name: $repo, owner: $owner) {
pullRequest(number: $pr) {
closingIssuesReferences(
first: $limit
Expand Down
42 changes: 42 additions & 0 deletions .graphqlrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @file GraphQL Config
* @module config/graphql
* @see https://graphql-config.com/docs/user/usage
*/

import { config as dotenv } from 'dotenv'
import { expand } from 'dotenv-expand'
import type { IGraphQLConfig } from 'graphql-config'

/**
* GitHub personal access token.
*
* @const {string} GITHUB_TOKEN
*/
const GITHUB_TOKEN: string = ((): string => {
if (process.env.GITHUB_TOKEN) return process.env.GITHUB_TOKEN

const { parsed: zshenv } = expand({
parsed: dotenv({ path: '~/.config/zsh/.zshenv' }).parsed
})

return zshenv?.GITHUB_TOKEN!
})()

/**
* GraphQL configuration options.
*
* @const {IGraphQLConfig} config
*/
const config: IGraphQLConfig = {
documents: ['./.github/graphql/**/*.gql'],
schema: [
{
'https://api.github.com/graphql': {
headers: { Authorization: `token ${GITHUB_TOKEN}` }
}
}
]
}

export default config
15 changes: 13 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@
"eslint.enable": true,
"eslint.nodePath": "./node_modules/eslint",
"eslint.options": {
"extensions": ["cjs", "cts", "json", "md", "mjs", "ts", "yml"],
"extensions": ["cjs", "cts", "gql", "json", "md", "mjs", "ts", "yml"],
"overrideConfigFile": "./.eslintrc.cjs"
},
"eslint.packageManager": "yarn",
"eslint.validate": ["javascript", "json", "markdown", "typescript"],
"eslint.validate": [
"graphql",
"javascript",
"json",
"markdown",
"typescript"
],
"files.associations": {
"*.snap": "jest-snapshot",
".env.zsh": "shellscript",
Expand Down Expand Up @@ -87,6 +93,11 @@
"format": "svg",
"icon": "eslint"
},
{
"extensions": [".graphqlrc.ts"],
"format": "svg",
"icon": "graphql"
},
{
"extensions": [".lintstagedrc.cjs"],
"format": "svg",
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"build": "unbuild",
"check:ci": "yarn fix:cg && yarn check:spelling && yarn check:types && yarn test && NODE_ENV=production yarn pack -o %s-%v.tgz && yarn clean:pack",
"check:format": "prettier --check .",
"check:lint": "eslint --cache --exit-on-fatal-error --ext cjs,cts,json,md,mjs,ts,yml --max-warnings 0 .",
"check:lint": "eslint --cache --exit-on-fatal-error --ext cjs,cts,gql,json,md,mjs,ts,yml --max-warnings 0 .",
"check:spelling": "cspell lint --color --no-progress --relative $@ \"**\"",
"check:types": "NODE_OPTIONS='--es-module-specifier-resolution=node --loader=./loader' tsc -p tsconfig.json",
"check:upgrades": "yarn upgrade-interactive",
Expand Down Expand Up @@ -105,6 +105,7 @@
"@commitlint/config-conventional": "17.0.3",
"@commitlint/types": "17.0.0",
"@faker-js/faker": "7.4.0",
"@graphql-eslint/eslint-plugin": "3.10.7",
"@types/chai": "4.3.3",
"@types/conventional-changelog": "3.1.1",
"@types/conventional-changelog-config-spec": "2.1.1",
Expand All @@ -125,6 +126,8 @@
"conventional-changelog-cli": "2.2.2",
"conventional-recommended-bump": "6.1.0",
"cspell": "6.8.0",
"dotenv": "16.0.1",
"dotenv-expand": "8.0.3",
"eslint": "8.22.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-chai-expect": "3.0.0",
Expand All @@ -139,6 +142,8 @@
"eslint-plugin-react": "7.31.0",
"eslint-plugin-unicorn": "43.0.2",
"eslint-plugin-yml": "1.1.0",
"graphql": "16.6.0",
"graphql-config": "4.3.3",
"growl": "1.10.5",
"husky": "8.0.1",
"is-ci": "3.0.1",
Expand All @@ -162,6 +167,7 @@
"yaml-eslint-parser": "1.1.0"
},
"resolutions": {
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",
"mkdist": "patch:mkdist@npm:0.3.13#.yarn/patches/mkdist-npm-0.3.13-c41cf41c68.patch",
"typescript": "4.8.0-beta",
"vite": "3.0.4"
Expand Down
Loading

0 comments on commit eb52b2e

Please sign in to comment.