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

Initial setup #4

Merged
merged 1 commit into from
Oct 3, 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
1 change: 1 addition & 0 deletions .eslintignore
72 changes: 72 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = {
root: true, // https://github.com/eslint/eslint/issues/13385#issuecomment-641252879
env: {
es6: true,
jest: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 11,
sourceType: 'module',
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:jest/recommended',
],
plugins: ['@typescript-eslint', 'import', 'jest'],
rules: {
// TypeScript
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// Turning off, because it conflicts with prettier
'@typescript-eslint/indent': ['off'],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
// Leave vars as 'all' to force everything to be handled when pattern matching
// Variables can be ignored by prefixing with an '_'
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', vars: 'all' }],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',

// eslint-plugin-import
'import/namespace': ['error', { allowComputed: true }],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'sibling', 'parent', 'index', 'object', 'type'],
pathGroups: [
{
pattern: 'mock-utils',
group: 'builtin',
patternOptions: { matchBase: true, nocomment: true },
},
],
},
],

// ESLint
'comma-dangle': ['error', 'only-multiline'],
indent: 'off',
'no-console': 'error',
'no-useless-escape': 'off',
semi: 'error',
eqeqeq: ['error', 'smart'],

// Jest
'jest/valid-title': 'off', // Prevents using "<function-name>.name" as a test name
},
};
51 changes: 51 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Continuous Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
documentation:
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Check hyperlinks
uses: gaurav-nelson/github-action-markdown-link-check@v1

lint-build-test:
runs-on: ubuntu-latest
name: Build, lint and test
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.8.0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Lint Typescript
run: pnpm run tsc
- name: Lint
run: pnpm run prettier:check && pnpm run eslint:check
- name: Test
run: pnpm run test

required-checks-passed:
name: All required checks passed
runs-on: ubuntu-latest
needs: [documentation, lint-build-test]
steps:
- run: exit 0
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.build
.env
.idea
.log
.tsbuildinfo
.vscode
build
dist
node_modules
coverage
.DS_Store
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm run prettier:check && pnpm run eslint:check
1 change: 1 addition & 0 deletions .prettierignore
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"bracketSpacing": true,
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"overrides": [
{
"files": "*.md",
"options": {
"parser": "markdown",
"proseWrap": "always"
}
}
]
}
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# airseekerV2
# airseeker-v2

> A service powering data feeds using the [signed API](https://github.com/api3dao/signed-api).

The Airseeker is a rework of the [original Airseeker](https://github.com/api3dao/airseeker). The Airseeker v2 is
simplified and only works with signed APIs.

## Getting started

To install the dependencies:

```sh
pnpm install
```
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { join } = require('path');

/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
collectCoverage: true,
coverageDirectory: 'coverage',
coverageProvider: 'v8',
modulePathIgnorePatterns: ['<rootDir>/.build', '<rootDir>/dist/', '<rootDir>/build/'],
preset: 'ts-jest',
restoreMocks: true,
setupFiles: [join(__dirname, './jest.setup.js')],
testEnvironment: 'jest-environment-node',
};
20 changes: 20 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Sometimes Jest can have issues when trying to spy on an internal module. Import
// and use this function as a workaround at the top of your test.
//
// Credit: https://github.com/facebook/jest/issues/6914#issuecomment-654710111
const { defineProperty } = Object;

Object.defineProperty = function (object, name, meta) {
if (meta.get && !meta.configurable) {
// it might be an ES6 exports object
return defineProperty(object, name, {
...meta,
configurable: true, // prevent freezing
});
}

return defineProperty(object, name, meta);
};

// Disable logger if it is not explicitly set to true.
process.env.LOGGER_ENABLED = process.env.LOGGER_ENABLED || 'false';
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "airseeker-v2",
"version": "1.0.0",
"keywords": [],
"license": "MIT",
"engines": {
"node": "^18.14.0",
"pnpm": "^8.8.0"
},
"scripts": {
"build": "tsc --project tsconfig.build.json",
"clean": "rm -rf coverage dist",
"dev": "nodemon --ext ts,js,json,env --exec \"pnpm ts-node src/index.ts\"",
"eslint:check": "eslint . --ext .js,.ts --max-warnings 0",
"eslint:fix": "eslint . --ext .js,.ts --fix",
"prepare": "husky install",
"prettier:check": "prettier --check \"./**/*.{js,ts,md,json}\"",
"prettier:fix": "prettier --write \"./**/*.{js,ts,md,json}\"",
"test": "jest --passWithNoTests",
"tsc": "tsc --project ."
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@types/node": "^20.8.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.2",
"husky": "^8.0.3",
"jest": "^29.7.0",
"nodemon": "^3.0.1",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
Loading