Skip to content
Draft
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
16 changes: 16 additions & 0 deletions .babel-register
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
See
https://github.com/babel/babel/issues/8652
https://github.com/babel/babel/pull/6027
Babel isn't currently configured by default to read .ts files and
can only be configured to do so via cli or configuration below.

This file is used by mocha to interpret test files using a properly
configured babel.

This can (probably) be removed in babel 8.x.
*/
require('@babel/register')({
extensions: ['.ts'],
ignore: ['node_modules'],
})
22 changes: 22 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": "10.4",
"browsers": ">1%, not ie 11"
},
"exclude": [
"transform-regenerator"
]
}
],
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"@babel/plugin-syntax-bigint"
]
}
134 changes: 134 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
const path = require('path');

module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
mocha: true
},
globals: {
BigInt: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 10,
project: "./tsconfig.json"
},
plugins: [
"@typescript-eslint",
"eslint-plugin-import",
"eslint-plugin-node",
"no-only-tests",
"prettier"
],
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended"
],
// settings: {
// "import/resolver": {
// "@mpetrunic/eslint-import-resolver-lerna": {
// packages: path.resolve(__dirname, "packages")
// }
// }
// },
rules: {
"prettier/prettier": "error",
//doesnt work, it reports false errors
"constructor-super": "off",
"@typescript-eslint/naming-convention": ["error",
{selector: "default", format: ['camelCase']},
{selector: ["classProperty", "objectLiteralProperty", "classMethod", "parameter"], format: ['camelCase'], leadingUnderscore: "allow"},
//variable must be in camel or upper case
{selector: "variable", format: ["camelCase", "UPPER_CASE"], leadingUnderscore: "allow"},
//classes and types must be in PascalCase
{selector: ["typeLike", "enum"], format: ['PascalCase']},
{selector: "enumMember", format: null},
//interface must start with I
{selector: "interface", format: ['PascalCase'], prefix: ["I"]},
//ignore rule for quoted stuff
{
selector: [
"classProperty",
"objectLiteralProperty",
"typeProperty",
"classMethod",
"objectLiteralMethod",
"typeMethod",
"accessor",
"enumMember"
],
format: null,
modifiers: ["requiresQuotes"]
},
//ignore rules on destructured params
{
selector: "variable",
modifiers: ["destructured"],
format: null
}
],
"@typescript-eslint/explicit-function-return-type": ["error", {
"allowExpressions": true
}],
"@typescript-eslint/func-call-spacing": "error",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^_"
}],
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-floating-promises": "error",
"import/no-extraneous-dependencies": ["error", {
"devDependencies": false,
"optionalDependencies": false,
"peerDependencies": false
}],
"func-call-spacing": "off",
//if --fix is run it messes imports like /lib/presets/minimal & /lib/presets/mainnet
"import/no-duplicates": "off",
"node/no-deprecated-api": "error",
"new-parens": "error",
"no-caller": "error",
"no-bitwise": "off",
"no-cond-assign": "error",
"no-consecutive-blank-lines": 0,
"no-console": "warn",
"no-var": "error",
"object-curly-spacing": ["error", "never"],
"object-literal-sort-keys": 0,
"no-prototype-builtins": 0,
"prefer-const": "error",
"quotes": ["error", "double"],
"semi": "off",

// Prevents accidentally pushing a commit with .only in Mocha tests
"no-only-tests/no-only-tests": "error"
},
"overrides": [
{
"files": ["**/test/**/*.ts"],
"rules": {
"import/no-extraneous-dependencies": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["**/lodestar-types/**/*.ts"],
"rules": {
"@typescript-eslint/naming-convention": ["off", {
selector: "interface", prefix: ["I"]
}],
}
}
]
};
16 changes: 0 additions & 16 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://gitcoin.co/grants/79/lodestar-eth20-client
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI Tests

on: [pull_request, push]

jobs:
lint:
name: Quick tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Bootstrap
run: yarn
- name: Check types
run: yarn check-types
- name: Lint
run: yarn lint
- name: Tests
run: yarn test
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
dist
.nyc_output/
coverage/
dist/
lib/
node_modules/
.idea/
11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: false,
quoteProps: "as-needed",
trailingComma: "es5",
bracketSpacing: false,
arrowParens: "always",
};
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"runtimeVersion": "12.10.0",
"name": "Mocha Current File",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-r",
"ts-node/register",
"--require",
"source-map-support/register",
"--timeout",
"999999",
"--colors",
"${file}"
],
"env": {
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
},
"sourceMaps": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
46 changes: 35 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
"description": "Persistent data structures for TypeScript.",
"main": "index.ts",
"scripts": {
"lint": "eslint src/**",
"test": "jest",
"prettier:check": "prettier --parser typescript --list-different \"src/**/*.{ts,tsx}\""
"build": "yarn build-lib && yarn build-types",
"build-lib": "babel src -x .ts -d lib --source-maps",
"build-types": "tsc --incremental --declaration --outDir lib --emitDeclarationOnly",
"check-types": "tsc --noEmit",
"clean": "rm -rf lib && rm -rf dist && rm -f tsconfig.tsbuildinfo",
"lint": "eslint --color --ext .ts src/ test/",
"lint:fix": "yarn run lint --fix",
"prepublishOnly": "yarn build",
"pretest": "yarn check-types",
"test": "yarn test:unit",
"test:unit": "nyc -e .ts mocha --colors -r ts-node/register \"test/unit/**/*.test.ts\"",
"test:perf": "mocha --colors -r ts-node/register 'test/perf/**/*.test.ts'"
},
"repository": {
"type": "git",
Expand All @@ -24,15 +33,30 @@
},
"homepage": "https://github.com/cronokirby/persistent-ts#readme",
"devDependencies": {
"@types/jest": "^24.0.13",
"@typescript-eslint/eslint-plugin": "^1.10.2",
"@typescript-eslint/parser": "^1.10.2",
"eslint": "^5.16.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-typescript": "^7.8.3",
"@babel/register": "^7.8.3",
"@typescript-eslint/eslint-plugin": "4.9.0",
"@typescript-eslint/parser": "4.9.0",
"ts-node": "^9.0.0",
"eslint": "^7.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"fast-check": "^1.15.1",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"typescript": "^3.5.1"
"prettier": "^2.0.5",
"mocha": "^8.1.1",
"@types/mocha": "^8.0.3",
"chai": "^4.2.0",
"@types/node": "^12.12.21",
"typescript": "^3.8.3",
"nyc": "^15.0.0"
},
"jest": {
"transform": {
Expand Down
Loading