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

📝 Added eslint-plugin-jsdoc and fixed errors #133

Merged
merged 17 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 15 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
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,29 @@ module.exports = {
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
},
overrides: [
{
files: 'src/**/*.ts',
excludedFiles: '*.test.ts',
plugins: ['jsdoc'],
extends: ['plugin:jsdoc/recommended'],
rules: {
'jsdoc/check-tag-names': ['warn', { definedTags: ['alpha', 'beta'] }], // Should check that tag names are valid; include 'alpha' and 'beta' as acceptable tag names
'jsdoc/require-param-type': 'off', // TypeDoc automatically reads types from TypeScript types, hence param types should rarely be defined explictly -- https://typedoc.org/guides/doccomments/#%40param-%3Cparam-name%3E
'jsdoc/require-returns-type': 'off', // Read above note for `jsdoc/require-param-type`
// 'jsdoc/check-examples': 'warn', // Ensures examples match a certain format -- currently not supported for ESLint, waiting for this issue -- https://github.com/eslint/eslint/issues/14745
'jsdoc/check-indentation': 'warn', // Ensures proper indentation of items inside TypeDoc comments
'jsdoc/check-line-alignment': 'warn', // Ensures TypeDoc comments are aligned to match what it's documenting
'jsdoc/check-syntax': 'warn', // Ensures that documentation syntax is appropriate for Google Closure Compiler
'jsdoc/require-asterisk-prefix': 'warn', // Require that all documentation is prefixed with an asterisk, makes it easier to differentiate what's documentation and what isn't
'jsdoc/require-example': 'warn', // Ensures that all documentated functions have examples
'jsdoc/require-hyphen-before-param-description': ['warn', 'never'], // Prevent hyphens before description of a parameter
'jsdoc/require-returns': [
'warn',
{ checkGetters: true, forceReturnsWithAsync: true },
],
'jsdoc/no-multi-asterisks': ['warn', { allowWhitespace: true }],
},
},
],
};
131 changes: 130 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"dotenv": "^16.0.0",
"eslint": "^8.16.0",
"eslint-plugin-jest": "^26.2.2",
"ethers": "^5.6.8",
"eslint-plugin-jsdoc": "=38.0.2",
"ethers": "^5.6.7",
"express": "^4.17.1",
"husky": "^7.0.4",
"jest": "^27.5.1",
Expand Down
19 changes: 15 additions & 4 deletions src/classes/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {
encodeData,
} from './utils/encode-decode-transaction';
import { buildRPCPostBody, post } from './utils/fetchers';
/**
*
* @param txnData
* @example
*/
function estimateGas(txnData: string) {
// https://ethereum.stackexchange.com/questions/1570/what-does-intrinsic-gas-too-low-mean/1694
txnData.split('').reduce((previousValue, currentValue) => {
Expand All @@ -24,9 +29,10 @@ export class BaseContract {
private readonly _provider: JsonRpcProvider;

/**
* @param addressOrName - The ethereum address of the smart-contract
* @param contractInterface - The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
* @param signerOrProvider - An instantiated essential-eth provider
* @param addressOrName The ethereum address of the smart-contract
* @param contractInterface The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
* @param signerOrProvider An instantiated essential-eth provider
* @example
*/
constructor(
addressOrName: string,
Expand Down Expand Up @@ -91,6 +97,11 @@ export class BaseContract {

/**
* Applies the unique contract's methods to the instantiated Contract in the constructor based-upon the provided ABI
*
* @param object
* @param name
* @param value
* @example
*/
export function defineReadOnly<T>(object: T, name: string, value: any): void {
Object.defineProperty(object, name, {
Expand All @@ -103,7 +114,7 @@ export function defineReadOnly<T>(object: T, name: string, value: any): void {
/**
* @alpha
* Only accepts ABIS in JSON format. This allows for stronger typing and assurances of data-types
* * Only read-only function calls currently supported.
* Only read-only function calls currently supported.
* @example
* ```typescript
* import { Contract, JsonRpcProvider } from 'essential-eth';
Expand Down
16 changes: 16 additions & 0 deletions src/classes/utils/clean-block.ts

Large diffs are not rendered by default.

Loading