Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config sdk #4

Merged
merged 10 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"ignorePatterns": [
"hardhat.config.js",
"**/types/*.ts",
"*.graphql.ts",
"scripts/*",
"dist/*",
"*.d.ts"
],
"plugins": [
"import",
"@typescript-eslint"
],
"rules": {

// Common

"no-trailing-spaces": 1,
"semi": [ "error", "never" ],
"max-len": [ "warn", { "code": 140 } ],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description"
}
],
"@typescript-eslint/no-explicit-any": "off",
"object-curly-spacing": [ "error", "always" ],
"array-bracket-spacing": [ "error", "always" ],
"no-multiple-empty-lines": [ "error", { "max": 2 } ],
"jsx-a11y/alt-text": 0,
"comma-dangle": [
"warn", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
],

// Special

"no-restricted-globals": [ "error", {
"name": "localStorage",
"message": "Use localStorage module from @stakewise/frontwise-modules!"
} ],

// Import plugin

"import/first": 0,
"import/extensions": 0,
"import/no-unresolved": 0,
"import/no-dynamic-require": 0,
"import/prefer-default-export": 0,
"import/no-webpack-loader-syntax": 0,
"import/no-named-as-default-member": 1,
"import/no-extraneous-dependencies": 0,
"import/no-anonymous-default-export": 0,
"import/newline-after-import": [ "error", { "count": 2 } ]
}
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@dfkadyr @mike-diamond @Cast0001
32 changes: 32 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit tests

on:
pull_request:
branches: [ main, prod ]

jobs:
audit:
name: Checking
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Setup node and npm
uses: actions/setup-node@v3
with:
cache: npm
scope: '@stakewise'
node-version: '18.16.1'
registry-url: "https://npm.pkg.github.com"
cache-dependency-path: "**/package-lock.json"
- name: Install npm dependencies
run: "npm ci --ignore-scripts"
shell: bash
env:
NODE_AUTH_TOKEN: ${{ github.token }}
- name: Checking
run: npm run prepare && npm run test
shell: bash
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
.idea
.vscode
.rollup.cache
tsconfig.tsbuildinfo

dist
types
cache
coverage

# dependencies
node_modules

# Types
schema.graphql
*.graphql.ts
File renamed without changes.
File renamed without changes.
11 changes: 8 additions & 3 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename "$0")"
readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
Expand All @@ -19,13 +19,18 @@ if [ -z "$husky_skip_init" ]; then
. ~/.huskyrc
fi

export readonly husky_skip_init=1
readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode == 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
6 changes: 3 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
npm run test && npx eslint ./src
File renamed without changes.
24 changes: 0 additions & 24 deletions babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/v3-sdk/codegen.ts → codegen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CodegenConfig } from '@graphql-codegen/cli'
import constants from '../v3-sdk/src/constants'
import constants from '../v3-sdk/src/helpers/constants'


// https://the-guild.dev/graphql/codegen/plugins/typescript/typescript
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions jest.config.base.js

This file was deleted.

27 changes: 27 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Config } from 'jest'


const config: Config = {
rootDir: '.',
verbose: true,
preset: 'ts-jest',
resetMocks: true,
testEnvironment: 'node',
testMatch: [ '**/*.spec.ts' ],
collectCoverageFrom: [ 'src/**/*.ts' ],
moduleFileExtensions: [ 'json', 'js', 'ts' ],
modulePathIgnorePatterns: [ '<rootDir>/src/helpers' ],
transform: {
'\\.[jt]sx?$': 'ts-jest',
},
globals: {
isolatedModules: true,
},
moduleNameMapper: {
'^helpers$': require.resolve('./src/helpers/index.ts'),
'^graphql$': require.resolve('./src/graphql/index.ts'),
},
}


export default config
Loading
Loading