@0no-co/graphql.web 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +7 -0
- package/.gitattributes +1 -0
- package/.github/workflows/ci.yml +57 -0
- package/.github/workflows/release.yml +63 -0
- package/benchmark/kitchen_sink.graphql +69 -0
- package/benchmark/package.json +14 -0
- package/benchmark/suite.js +26 -0
- package/package.json +91 -0
- package/pnpm-workspace.yaml +2 -0
- package/scripts/changelog.js +125 -0
- package/scripts/eslint-preset.js +54 -0
- package/scripts/prepare.js +18 -0
- package/scripts/rollup.config.mjs +160 -0
- package/src/__tests__/__snapshots__/parser.test.ts.snap +779 -0
- package/src/__tests__/parser.test.ts +11 -0
- package/src/ast.ts +251 -0
- package/src/error.ts +51 -0
- package/src/index.ts +6 -0
- package/src/kind.ts +32 -0
- package/src/parser.ts +480 -0
- package/src/printer.ts +132 -0
- package/src/types.ts +5 -0
- package/src/visitor.ts +136 -0
- package/tsconfig.json +24 -0
|
@@ -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)
|
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
pull_request_review:
|
|
6
|
+
types: [submitted, edited]
|
|
7
|
+
branches: changeset-release/main
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
name: Checks
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
timeout-minutes: 10
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout Repo
|
|
16
|
+
uses: actions/checkout@v2
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
|
|
20
|
+
- name: Setup Node
|
|
21
|
+
uses: actions/setup-node@v1
|
|
22
|
+
with:
|
|
23
|
+
node-version: 18
|
|
24
|
+
|
|
25
|
+
- name: Setup pnpm
|
|
26
|
+
uses: pnpm/action-setup@v2.2.2
|
|
27
|
+
with:
|
|
28
|
+
version: 7
|
|
29
|
+
run_install: false
|
|
30
|
+
|
|
31
|
+
- name: Get pnpm store directory
|
|
32
|
+
id: pnpm-store
|
|
33
|
+
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
34
|
+
|
|
35
|
+
- name: Use pnpm store
|
|
36
|
+
uses: actions/cache@v3
|
|
37
|
+
id: pnpm-cache
|
|
38
|
+
with:
|
|
39
|
+
path: ${{ steps.pnpm-store.outputs.pnpm_cache_dir }}
|
|
40
|
+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
41
|
+
restore-keys: |
|
|
42
|
+
${{ runner.os }}-pnpm-
|
|
43
|
+
|
|
44
|
+
- name: Install Dependencies
|
|
45
|
+
run: pnpm install --frozen-lockfile --prefer-offline
|
|
46
|
+
|
|
47
|
+
- name: TypeScript
|
|
48
|
+
run: pnpm run check
|
|
49
|
+
|
|
50
|
+
- name: Linting
|
|
51
|
+
run: pnpm run lint
|
|
52
|
+
|
|
53
|
+
- name: Unit Tests
|
|
54
|
+
run: pnpm run test
|
|
55
|
+
|
|
56
|
+
- name: Build
|
|
57
|
+
run: pnpm run build
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: Release
|
|
9
|
+
runs-on: ubuntu-20.04
|
|
10
|
+
timeout-minutes: 20
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout Repo
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- name: Setup Node
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: 18
|
|
21
|
+
|
|
22
|
+
- name: Setup pnpm
|
|
23
|
+
uses: pnpm/action-setup@v2.2.2
|
|
24
|
+
with:
|
|
25
|
+
version: 7
|
|
26
|
+
run_install: false
|
|
27
|
+
|
|
28
|
+
- name: Get pnpm store directory
|
|
29
|
+
id: pnpm-store
|
|
30
|
+
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
31
|
+
|
|
32
|
+
- name: Use pnpm store
|
|
33
|
+
uses: actions/cache@v3
|
|
34
|
+
id: pnpm-cache
|
|
35
|
+
with:
|
|
36
|
+
path: ${{ steps.pnpm-store.outputs.pnpm_cache_dir }}
|
|
37
|
+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
38
|
+
restore-keys: |
|
|
39
|
+
${{ runner.os }}-pnpm-
|
|
40
|
+
|
|
41
|
+
- name: Install Dependencies
|
|
42
|
+
run: pnpm install --frozen-lockfile --prefer-offline
|
|
43
|
+
|
|
44
|
+
- name: PR or Publish
|
|
45
|
+
id: changesets
|
|
46
|
+
uses: changesets/action@v1.4.1
|
|
47
|
+
with:
|
|
48
|
+
version: pnpm changeset:version
|
|
49
|
+
publish: pnpm changeset:publish
|
|
50
|
+
env:
|
|
51
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
52
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
+
|
|
54
|
+
- name: Publish Prerelease
|
|
55
|
+
if: steps.changesets.outputs.published != 'true'
|
|
56
|
+
env:
|
|
57
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
58
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
59
|
+
run: |
|
|
60
|
+
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
|
|
61
|
+
git reset --hard origin/main
|
|
62
|
+
pnpm changeset version --no-git-tag --snapshot canary
|
|
63
|
+
pnpm changeset publish --no-git-tag --snapshot canary --tag canary
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright (c) 2015-present, Facebook, Inc.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
|
|
7
|
+
whoever123is: node(id: [123, 456]) {
|
|
8
|
+
id
|
|
9
|
+
... on User @onInlineFragment {
|
|
10
|
+
field2 {
|
|
11
|
+
id
|
|
12
|
+
alias: field1(first: 10, after: $foo) @include(if: $foo) {
|
|
13
|
+
id
|
|
14
|
+
...frag @onFragmentSpread
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
... @skip(unless: $foo) {
|
|
19
|
+
id
|
|
20
|
+
}
|
|
21
|
+
... {
|
|
22
|
+
id
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
mutation likeStory @onMutation {
|
|
28
|
+
like(story: 123) @onField {
|
|
29
|
+
story {
|
|
30
|
+
id @onField
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
subscription StoryLikeSubscription($input: StoryLikeSubscribeInput)
|
|
36
|
+
@onSubscription {
|
|
37
|
+
storyLikeSubscribe(input: $input) {
|
|
38
|
+
story {
|
|
39
|
+
likers {
|
|
40
|
+
count
|
|
41
|
+
}
|
|
42
|
+
likeSentence {
|
|
43
|
+
text
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fragment frag on Friend @onFragmentDefinition {
|
|
50
|
+
foo(
|
|
51
|
+
size: $site
|
|
52
|
+
bar: 12
|
|
53
|
+
obj: {
|
|
54
|
+
key: "value"
|
|
55
|
+
block: """
|
|
56
|
+
block string uses \"""
|
|
57
|
+
"""
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
query teeny {
|
|
63
|
+
unnamed(truthy: true, falsey: false, nullish: null)
|
|
64
|
+
query
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
query tiny {
|
|
68
|
+
__typename
|
|
69
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "benchmark",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "suite.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "NODE_ENV=production benchr suite.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"benchr": "4.3.0",
|
|
12
|
+
"graphql": "^16.6.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const graphqlWeb = require('..');
|
|
3
|
+
const graphql = require('graphql');
|
|
4
|
+
|
|
5
|
+
const kitchenSink = fs.readFileSync('./kitchen_sink.graphql', { encoding: 'utf8' });
|
|
6
|
+
const document = graphql.parse(kitchenSink, { noLocation: true });
|
|
7
|
+
|
|
8
|
+
suite('parse kitchen sink query', () => {
|
|
9
|
+
benchmark('0no-co/graphql.web', () => {
|
|
10
|
+
graphqlWeb.parse(kitchenSink);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
benchmark('graphql', () => {
|
|
14
|
+
graphql.parse(kitchenSink, { noLocation: true });
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
suite('print kitchen sink query', () => {
|
|
19
|
+
benchmark('0no-co/graphql.web', () => {
|
|
20
|
+
graphqlWeb.print(document);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
benchmark('graphql', () => {
|
|
24
|
+
graphql.print(document);
|
|
25
|
+
});
|
|
26
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0no-co/graphql.web",
|
|
3
|
+
"description": "A spec-compliant client-side GraphQL implementation",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"author": "0no.co <hi@0no.co>",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"main": "./dist/graphql.web",
|
|
8
|
+
"module": "./dist/graphql.web.mjs",
|
|
9
|
+
"types": "./dist/graphql.web.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/graphql.web.mjs",
|
|
13
|
+
"require": "./dist/graphql.web.js",
|
|
14
|
+
"types": "./dist/graphql.web.d.ts",
|
|
15
|
+
"source": "./src/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"public": true,
|
|
21
|
+
"keywords": [
|
|
22
|
+
"graphql",
|
|
23
|
+
"graphql-js",
|
|
24
|
+
"client-side graphql"
|
|
25
|
+
],
|
|
26
|
+
"repository": "https://github.com/0no-co/graphql.web",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/0no-co/graphql.web/issues"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"prettier": {
|
|
32
|
+
"singleQuote": true,
|
|
33
|
+
"tabWidth": 2,
|
|
34
|
+
"printWidth": 100
|
|
35
|
+
},
|
|
36
|
+
"lint-staged": {
|
|
37
|
+
"*.{ts,js}": "eslint -c scripts/eslint-preset.js --fix",
|
|
38
|
+
"*.json": "prettier --write",
|
|
39
|
+
"*.md": "prettier --write"
|
|
40
|
+
},
|
|
41
|
+
"husky": {
|
|
42
|
+
"hooks": {
|
|
43
|
+
"pre-commit": "lint-staged --quiet --relative"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"root": true,
|
|
48
|
+
"extends": [
|
|
49
|
+
"./scripts/eslint-preset.js"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@changesets/cli": "^2.26.0",
|
|
54
|
+
"@changesets/get-github-info": "^0.5.2",
|
|
55
|
+
"@rollup/plugin-buble": "^1.0.2",
|
|
56
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
57
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
58
|
+
"@rollup/plugin-sucrase": "^5.0.1",
|
|
59
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
61
|
+
"@typescript-eslint/parser": "^5.55.0",
|
|
62
|
+
"eslint": "^8.36.0",
|
|
63
|
+
"eslint-config-prettier": "^8.7.0",
|
|
64
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
65
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
66
|
+
"graphql": "^16.6.0",
|
|
67
|
+
"husky-v4": "^4.3.8",
|
|
68
|
+
"lint-staged": "^13.2.0",
|
|
69
|
+
"npm-run-all": "^4.1.5",
|
|
70
|
+
"prettier": "^2.8.4",
|
|
71
|
+
"rimraf": "^4.4.0",
|
|
72
|
+
"rollup": "^3.19.1",
|
|
73
|
+
"rollup-plugin-cjs-check": "^1.0.2",
|
|
74
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
75
|
+
"terser": "^5.16.6",
|
|
76
|
+
"typescript": "^5.0.2",
|
|
77
|
+
"vitest": "^0.29.3"
|
|
78
|
+
},
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"test": "vitest run",
|
|
84
|
+
"check": "tsc",
|
|
85
|
+
"lint": "eslint --ext=js,ts .",
|
|
86
|
+
"build": "rollup -c scripts/rollup.config.mjs",
|
|
87
|
+
"clean": "rimraf dist node_modules/.cache",
|
|
88
|
+
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
|
89
|
+
"changeset:publish": "changeset publish"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const { config } = require('dotenv');
|
|
2
|
+
const { getInfo } = require('@changesets/get-github-info');
|
|
3
|
+
|
|
4
|
+
config();
|
|
5
|
+
|
|
6
|
+
const REPO = '0no-co/wonka';
|
|
7
|
+
const SEE_LINE = /^See:\s*(.*)/i;
|
|
8
|
+
const TRAILING_CHAR = /[.;:]$/g;
|
|
9
|
+
const listFormatter = new Intl.ListFormat('en-US');
|
|
10
|
+
|
|
11
|
+
const getSummaryLines = cs => {
|
|
12
|
+
let lines = cs.summary.trim().split(/\r?\n/);
|
|
13
|
+
if (!lines.some(line => /```/.test(line))) {
|
|
14
|
+
lines = lines.map(l => l.trim()).filter(Boolean);
|
|
15
|
+
const size = lines.length;
|
|
16
|
+
if (size > 0) {
|
|
17
|
+
lines[size - 1] = lines[size - 1].replace(TRAILING_CHAR, '');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return lines;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Creates a "(See X)" string from a template */
|
|
24
|
+
const templateSeeRef = links => {
|
|
25
|
+
const humanReadableLinks = links.filter(Boolean).map(link => {
|
|
26
|
+
if (typeof link === 'string') return link;
|
|
27
|
+
return link.pull || link.commit;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const size = humanReadableLinks.length;
|
|
31
|
+
if (size === 0) return '';
|
|
32
|
+
|
|
33
|
+
const str = listFormatter.format(humanReadableLinks);
|
|
34
|
+
return `(See ${str})`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const changelogFunctions = {
|
|
38
|
+
getDependencyReleaseLine: async (changesets, dependenciesUpdated) => {
|
|
39
|
+
if (dependenciesUpdated.length === 0) return '';
|
|
40
|
+
|
|
41
|
+
const dependenciesLinks = await Promise.all(
|
|
42
|
+
changesets.map(async cs => {
|
|
43
|
+
if (!cs.commit) return undefined;
|
|
44
|
+
|
|
45
|
+
const lines = getSummaryLines(cs);
|
|
46
|
+
const prLine = lines.find(line => SEE_LINE.test(line));
|
|
47
|
+
if (prLine) {
|
|
48
|
+
const match = prLine.match(SEE_LINE);
|
|
49
|
+
return (match && match[1].trim()) || undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { links } = await getInfo({
|
|
53
|
+
repo: REPO,
|
|
54
|
+
commit: cs.commit,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return links;
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
let changesetLink = '- Updated dependencies';
|
|
62
|
+
|
|
63
|
+
const seeRef = templateSeeRef(dependenciesLinks);
|
|
64
|
+
if (seeRef) changesetLink += ` ${seeRef}`;
|
|
65
|
+
|
|
66
|
+
const detailsLinks = dependenciesUpdated.map(dep => {
|
|
67
|
+
return ` - ${dep.name}@${dep.newVersion}`;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return [changesetLink, ...detailsLinks].join('\n');
|
|
71
|
+
},
|
|
72
|
+
getReleaseLine: async (changeset, type) => {
|
|
73
|
+
let pull, commit, user;
|
|
74
|
+
|
|
75
|
+
const lines = getSummaryLines(changeset);
|
|
76
|
+
const prLineIndex = lines.findIndex(line => SEE_LINE.test(line));
|
|
77
|
+
if (prLineIndex > -1) {
|
|
78
|
+
const match = lines[prLineIndex].match(SEE_LINE);
|
|
79
|
+
pull = (match && match[1].trim()) || undefined;
|
|
80
|
+
lines.splice(prLineIndex, 1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const [firstLine, ...futureLines] = lines;
|
|
84
|
+
|
|
85
|
+
if (changeset.commit && !pull) {
|
|
86
|
+
const { links } = await getInfo({
|
|
87
|
+
repo: REPO,
|
|
88
|
+
commit: changeset.commit,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
pull = links.pull || undefined;
|
|
92
|
+
commit = links.commit || undefined;
|
|
93
|
+
user = links.user || undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let annotation = '';
|
|
97
|
+
if (type === 'patch' && /^\s*fix/i.test(firstLine)) {
|
|
98
|
+
annotation = '⚠️ ';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let str = `- ${annotation}${firstLine}`;
|
|
102
|
+
if (futureLines.length > 0) {
|
|
103
|
+
str += `\n${futureLines.map(l => ` ${l}`).join('\n')}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const endsWithParagraph = /(?<=(?:[!;?.]|```) *)$/g;
|
|
107
|
+
if (user && !endsWithParagraph) {
|
|
108
|
+
str += `, by ${user}`;
|
|
109
|
+
} else {
|
|
110
|
+
str += `\nSubmitted by ${user}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (pull || commit) {
|
|
114
|
+
const seeRef = templateSeeRef([pull || commit]);
|
|
115
|
+
if (seeRef) str += ` ${seeRef}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return str;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
...changelogFunctions,
|
|
124
|
+
default: changelogFunctions,
|
|
125
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parserOptions: {
|
|
3
|
+
ecmaVersion: 9,
|
|
4
|
+
sourceType: 'module',
|
|
5
|
+
ecmaFeatures: {
|
|
6
|
+
modules: true,
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
extends: ['prettier'],
|
|
10
|
+
plugins: ['prettier', 'tsdoc'],
|
|
11
|
+
ignorePatterns: ['node_modules/', 'dist/', 'coverage/', 'perf/'],
|
|
12
|
+
rules: {
|
|
13
|
+
'sort-keys': 'off',
|
|
14
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
15
|
+
'prefer-arrow/prefer-arrow-functions': 'off',
|
|
16
|
+
'prefer-rest-params': 'off',
|
|
17
|
+
|
|
18
|
+
'prettier/prettier': [
|
|
19
|
+
'error',
|
|
20
|
+
{
|
|
21
|
+
singleQuote: true,
|
|
22
|
+
arrowParens: 'avoid',
|
|
23
|
+
trailingComma: 'es5',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
overrides: [
|
|
29
|
+
{
|
|
30
|
+
files: ['*.ts'],
|
|
31
|
+
parser: '@typescript-eslint/parser',
|
|
32
|
+
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
|
|
33
|
+
rules: {
|
|
34
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
35
|
+
'@typescript-eslint/no-use-before-define': 'off',
|
|
36
|
+
'@typescript-eslint/ban-types': 'off',
|
|
37
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
38
|
+
'@typescript-eslint/member-ordering': 'off',
|
|
39
|
+
'@typescript-eslint/explicit-member-accessibility': 'off',
|
|
40
|
+
'@typescript-eslint/no-object-literal-type-assertion': 'off',
|
|
41
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
42
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
43
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
44
|
+
'@typescript-eslint/no-misused-new': 'off',
|
|
45
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
46
|
+
'@typescript-eslint/array-type': 'off',
|
|
47
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
48
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
49
|
+
'prefer-rest-params': 'off',
|
|
50
|
+
'tsdoc/syntax': 'error',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const hookSource = path.resolve(__dirname, '../node_modules/husky-v4/sh/husky.sh');
|
|
5
|
+
const hook = path.resolve(__dirname, '../.git/hooks/husky.sh');
|
|
6
|
+
const localHook = path.resolve(__dirname, '../.git/hooks/husky.local.sh');
|
|
7
|
+
const gitConfig = path.resolve(__dirname, '../.git/config');
|
|
8
|
+
|
|
9
|
+
let script = fs.readFileSync(hookSource, { encoding: 'utf-8' });
|
|
10
|
+
script = script.replace(`$(basename "$0")`, `$(basename "$0" .sh)`);
|
|
11
|
+
|
|
12
|
+
let config = fs.readFileSync(gitConfig, { encoding: 'utf-8' });
|
|
13
|
+
config = config.replace(/\s*hooksPath\s*=\s*\.husky\n?/g, '\n');
|
|
14
|
+
|
|
15
|
+
fs.writeFileSync(hook, script);
|
|
16
|
+
fs.writeFileSync(gitConfig, config);
|
|
17
|
+
|
|
18
|
+
fs.writeFileSync(localHook, 'packageManager=yarn\n' + 'cd "."\n');
|