Skip to content

Commit 7159691

Browse files
author
Fabrice Bascoulergue
committed
Add configuration and scripts to lint, format and build
1 parent 6e9c770 commit 7159691

File tree

13 files changed

+5995
-15
lines changed

13 files changed

+5995
-15
lines changed

.babelrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-typescript"],
3+
"plugins": ["@babel/plugin-transform-async-to-generator", "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime"]
4+
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

.eslintrc.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"extends": ["eslint:recommended", "plugin:node/recommended", "prettier"],
3+
"plugins": ["node", "prettier"],
4+
"rules": {
5+
"prettier/prettier": "error",
6+
"block-scoped-var": "error",
7+
"eqeqeq": "error",
8+
"no-var": "error",
9+
"prefer-const": "error",
10+
"eol-last": "error",
11+
"prefer-arrow-callback": "error",
12+
"no-trailing-spaces": "error",
13+
"quotes": ["warn", "single", { "avoidEscape": true }],
14+
"no-restricted-properties": [
15+
"error",
16+
{
17+
"object": "describe",
18+
"property": "only"
19+
},
20+
{
21+
"object": "it",
22+
"property": "only"
23+
}
24+
]
25+
},
26+
"overrides": [
27+
{
28+
"files": ["**/*.ts", "**/*.tsx"],
29+
"parser": "@typescript-eslint/parser",
30+
"extends": ["plugin:@typescript-eslint/recommended"],
31+
"rules": {
32+
"@typescript-eslint/no-non-null-assertion": "off",
33+
"@typescript-eslint/no-use-before-define": "off",
34+
"@typescript-eslint/no-warning-comments": "off",
35+
"@typescript-eslint/no-empty-function": "off",
36+
"@typescript-eslint/no-var-requires": "off",
37+
"@typescript-eslint/explicit-function-return-type": "off",
38+
"@typescript-eslint/explicit-module-boundary-types": "off",
39+
"@typescript-eslint/ban-types": "off",
40+
"@typescript-eslint/camelcase": "off",
41+
"node/no-missing-import": "off",
42+
"node/no-empty-function": "off",
43+
"node/no-unsupported-features/es-syntax": "off",
44+
"node/no-missing-require": "off",
45+
"node/shebang": "off",
46+
"no-dupe-class-members": "off",
47+
"require-atomic-updates": "off"
48+
},
49+
"parserOptions": {
50+
"ecmaVersion": 2018,
51+
"sourceType": "module"
52+
}
53+
}
54+
]
55+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
# Build output
107+
/lib
108+
/typings

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"printWidth": 200,
6+
"tabWidth": 4,
7+
"quoteProps": "preserve"
8+
}

DOCUMENTATION.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Javascript SDK Documentation
2+
3+
## Node version
4+
5+
The SDK is developped and maintained using **NodeJS v12 Erbium**.

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@ This SDK basically provides an easy access to all the available Sandblock Chain
88

99
**Most commonly used features:**
1010

11-
- Core cryptographic tools and functions
12-
- Client service:
13-
- Connection to a blockchain node (http and socket mode)
14-
- Transaction broadcast
15-
- Blockchain RPCs
16-
- Accounts and wallets:
17-
- Accounts seed and encrypted mnemonic generation
18-
- Unlock accounts from private keys, keystore and mnemonic
19-
- Wallet balance
20-
- Transactions
21-
- Payload generation
22-
- Signature
11+
- Core cryptographic tools and functions
12+
- Client service:
13+
- Connection to a blockchain node (http and socket mode)
14+
- Transaction broadcast
15+
- Blockchain RPCs
16+
- Accounts and wallets:
17+
- Accounts seed and encrypted mnemonic generation
18+
- Unlock accounts from private keys, keystore and mnemonic
19+
- Wallet balance
20+
- Transactions
21+
- Payload generation
22+
- Signature
2323

2424
## Documentation
2525

2626
The SDK code should be documented enough for developers to explore and use it easily. Therefore the documentation might not cover all the capabilities of the SDK. Feel free to contribute if you wish to improve the code documentation and/or the provided samples.
2727

2828
The [Documentation](./DOCUMENTATION.md) contains:
29-
- Installation instructions
30-
- Basic usage
31-
- Code samples
29+
30+
- Installation instructions
31+
- Basic usage
32+
- Code samples
3233

3334
## Contributing
3435

jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
testMatch: ['**/*test.(ts|js)'],
3+
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/lib/', '<rootDir>/typings'],
4+
transform: {
5+
'^.+\\.(ts|js)?$': 'ts-jest',
6+
},
7+
rootDir: '',
8+
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
9+
testEnvironment: 'node',
10+
globals: {
11+
'ts-jest': {
12+
diagnostics: false,
13+
},
14+
},
15+
};

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@sandblock-chain/sdk-javascript",
3+
"version": "1.0.0",
4+
"license": "Apache-2.0",
5+
"main": "lib/index.js",
6+
"typings": "lib/index.d.ts",
7+
"files": [
8+
"lib/*"
9+
],
10+
"scripts": {
11+
"test": "cross-env NODE_ENV=test jest",
12+
"build": "yarn clean && yarn build:types && yarn build:js",
13+
"build:types": "tsc --emitDeclarationOnly",
14+
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
15+
"clean": "rimraf lib",
16+
"lint": "eslint '**/*.{ts,js}'",
17+
"format": "prettier --write '**/*.{js,jsx,ts,tsx,css,json,md,html,yml}'"
18+
},
19+
"dependencies": {},
20+
"optionalDependencies": {},
21+
"devDependencies": {
22+
"@babel/cli": "^7.8.3",
23+
"@babel/core": "^7.8.3",
24+
"@babel/plugin-proposal-class-properties": "^7.8.3",
25+
"@babel/plugin-transform-runtime": "^7.12.10",
26+
"@babel/preset-env": "^7.8.3",
27+
"@babel/preset-typescript": "^7.8.3",
28+
"@types/jest": "^26.0.20",
29+
"cross-env": "^7.0.3",
30+
"eslint": "^7.19.0",
31+
"gts": "^3.1.0",
32+
"jest": "^26.6.3",
33+
"prettier": "^2.2.1",
34+
"rimraf": "^3.0.2",
35+
"ts-jest": "^26.5.0",
36+
"typescript": "^4.1.3"
37+
}
38+
}

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const foobar = (input: string): string => {
2+
if (input === 'foo') {
3+
return 'bar';
4+
} else if (input === 'bar') {
5+
return 'foo';
6+
}
7+
return 'foobar';
8+
};
9+
10+
export { foobar };

0 commit comments

Comments
 (0)