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

[RFC] improve lerna monorepo setup #14

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
coverage/
/sandbox
**/*.d.ts
/docs/_preview
/docs/_loopback.io
262 changes: 262 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
// Copyright Abridged Inc. 2020. All Rights Reserved.
// Node module: eth-sdk-monorepo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

const fs = require('fs');

/**
* Default ESLint configuration for LoopBack
*
* See https://eslint.org/docs/user-guide/configuring
*/
module.exports = {
root: true,
// Use the typescript-eslint parser
parser: '@typescript-eslint/parser',
// Enable eslint and typescript-eslint
plugins: ['eslint-plugin', '@typescript-eslint', 'prettier'],
env: {
es6: true,
node: true,
mocha: true,
},
parserOptions: {
sourceType: 'module',
/*
* The `project` setting is required for `@typescript-eslint/await-thenable`
* but it causes significant performance overhead (1m13s vs 13s)
* See https://github.com/typescript-eslint/typescript-eslint/issues/389
*/
project: getProjectFile(),
ecmaFeatures: {
ecmaVersion: 2017,
jsx: false,
},
noWatch: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
/**
* Use `prettier` to override default formatting related rules
* See https://github.com/prettier/eslint-config-prettier
*/
'prettier',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
rules: {
'prefer-const': 'error',
'no-mixed-operators': 'off',
'no-console': 'off',
// 'no-undef': 'off',
'no-inner-declarations': 'off',
// TypeScript allows method overloading
'no-dupe-class-members': 'off',
'no-useless-escape': 'off',
// TypeScript allows the same name for namespace and function
'no-redeclare': 'off',

'no-array-constructor': 'error',

/**
* TypeScript specific rules
* See https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
*/
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-triple-slash-reference': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',

// Disable warning Missing return type on function for now
'@typescript-eslint/explicit-module-boundary-types': 'off',

/**
* The following rules are enforced to support legacy tslint configuration
*/
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md
// Rules mapped from `@loopback/tslint-config/tslint.common.json
'@typescript-eslint/adjacent-overload-signatures': 'error', // tslint:adjacent-overload-signatures
'@typescript-eslint/prefer-for-of': 'error', // tslint:prefer-for-of
'@typescript-eslint/unified-signatures': 'error', // tslint:unified-signatures
'@typescript-eslint/no-explicit-any': 'error', // tslint:no-any

'no-unused-labels': 'error', // tslint:label-position
'no-caller': 'error', // tslint:no-arg
'no-new-wrappers': 'error', // tslint:no-construct
// 'no-redeclare': 'error', // tslint:no-duplicate-variable

'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': ['error'],
'@typescript-eslint/no-misused-new': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md#how-to-use
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',

'no-throw-literal': 'error', // tslint:no-string-throw

'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'none', // none - do not check arguments
ignoreRestSiblings: false,
},
], // tslint:no-unused-variable
'no-unused-expressions': 'error', // tslint:no-unused-expression
'no-var': 'error', // tslint:no-var-keyword
eqeqeq: ['error', 'smart'], // tslint:triple-equals: [true, 'allow-null-check', 'allow-undefined-check'],

// Rules mapped from `@loopback/tslint-config/tslint.build.json
'@typescript-eslint/await-thenable': 'error', // tslint:await-promise: [true, 'PromiseLike', 'RequestPromise'],
'@typescript-eslint/no-floating-promises': 'error',

'no-void': 'error', // tslint:no-void-expression: [true, 'ignore-arrow-function-shorthand'],

'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-misused-promises': 'error',

'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md#how-to-use
'@typescript-eslint/return-await': 'error',
// note we must disable the base rule as it can report incorrect errors
'no-return-await': 'off',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
camelcase: 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
},

{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},

{
selector: 'variable',
format: null,
filter: {
regex: '^_$',
match: true,
},
},

// For mixin functions
{
selector: 'function',
format: ['PascalCase'],
filter: {
regex: 'Mixin$',
match: true,
},
},

{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For members such as `Content-Type`
{
selector: 'memberLike',
format: null,
filter: {
// you can expand this regex as you find more cases that require
// quoting that you want to allow
regex: '[- ]',
match: true,
},
},

// For enum members
{
selector: 'enumMember',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},

// For properties
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},

{
selector: 'method',
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For static members
{
selector: 'memberLike',
modifiers: ['static'],
format: ['camelCase', 'UPPER_CASE'],
},

// For private members
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},

// For protected members
{
selector: 'memberLike',
modifiers: ['protected'],
format: ['camelCase'],
leadingUnderscore: 'allow',
},

{
selector: 'typeLike',
format: ['PascalCase'],
},
],
},

overrides: [
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
},
},
],
};

/**
* Detect tsconfig file
*/
function getProjectFile() {
if (fs.existsSync('./tsconfig.build.json')) return './tsconfig.build.json';
if (fs.existsSync('./tsconfig.json')) return './tsconfig.json';
return undefined;
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
!.gitignore
!.npmignore

!.prettier*

!.eslintignore
!.eslintrc.js

*.log
npm-debug.log*
lerna-debug.log*

build
node_modules

*.tsbuildinfo

5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github/
*/*/build
*.json
CHANGELOG.md
*.yml
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"bracketSpacing": false,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "all",
"arrowParens": "avoid",
"overrides": [
{
"files": "**/*.md",
"options": {
"parser": "markdown",
"proseWrap": "always"
}
}
]
}
36 changes: 21 additions & 15 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
Copyright (c) Abridged Inc. 2019,2020.
Node module: eth-sdk-monorepo
This project is licensed under the MIT License, full text below.

--------

MIT License

Copyright (c) 2019 Abridged Inc.
MIT License Copyright (c) Abridged Inc. 2019,2020

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@

## Packages

* [eth-sdk](./packages/eth-sdk)
* [@eth-sdk/contract](./packages/eth-sdk-contract)
* [@eth-sdk/key](./packages/eth-sdk-key)
* [@eth-sdk/query](./packages/eth-sdk-query)
* [@eth-sdk/utils](./packages/eth-sdk-utils)
- [eth-sdk](./packages/eth-sdk)
- [@eth-sdk/contract](./packages/eth-sdk-contract)
- [@eth-sdk/key](./packages/eth-sdk-key)
- [@eth-sdk/query](./packages/eth-sdk-query)
- [@eth-sdk/utils](./packages/eth-sdk-utils)

## Examples

* [(node.js) key ganache provider](./examples/node-key-ganache-provider)
* [(node.js) key http provider](./examples/node-key-http-provider)
* [(node.js) query http provider](./examples/node-query-http-provider)
* [(node.js) query websocket provider](./examples/node-query-websocket-provider)
* [(react) app](./examples/react-app)
* [(node.js + typescript) contract](./examples/ts-node-contract)
- [(node.js) key ganache provider](./examples/node-key-ganache-provider)
- [(node.js) key http provider](./examples/node-key-http-provider)
- [(node.js) query http provider](./examples/node-query-http-provider)
- [(node.js) query websocket provider](./examples/node-query-websocket-provider)
- [(react) app](./examples/react-app)
- [(node.js + typescript) contract](./examples/ts-node-contract)

## License

[MIT][license-url]

[lerna-image]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
[lerna-url]: https://lerna.js.org/
[actions-image]: https://github.com/etherspot/eth-sdk/workflows/unit-tests/badge.svg
[actions-image]:
https://github.com/etherspot/eth-sdk/workflows/unit-tests/badge.svg
[actions-url]: https://github.com/etherspot/eth-sdk/actions
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: ./LICENSE
Loading