Skip to content

Commit

Permalink
ESM import fix (#6362)
Browse files Browse the repository at this point in the history
* import path fix ESM

* changelog updates

* removed invalid symlink

* esm import helper script

* fixed types

* changelog update

* import fixes

* using eslint rule to enforce esm js exts

* removed script

* fixed plugin example imports

* yarn lock update
  • Loading branch information
jdevcs authored Aug 18, 2023
1 parent ec6e117 commit 86f0cdb
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"declaration-bundler-webpack-plugin": "^1.0.3",
"eslint": "^8.20.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-require-extensions": "^0.1.3",
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
"husky": "^8.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/.prettierignore

This file was deleted.

4 changes: 4 additions & 0 deletions packages/web3-errors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,7 @@ Documentation:
- Fixed: "'disconnect' in Eip1193 provider must emit ProviderRpcError #6003".(#6230)

## [Unreleased]

### Fixed

- ESM import bug (#6359)
2 changes: 1 addition & 1 deletion packages/web3-errors/src/errors/rpc_error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
JSONRPC_ERR_REJECTED_REQUEST,
JSONRPC_ERR_UNAUTHORIZED,
JSONRPC_ERR_UNSUPPORTED_METHOD,
} from '../error_codes';
} from '../error_codes.js';

/**
* A template string for a generic Rpc Error. The `*code*` will be replaced with the code number.
Expand Down
1 change: 1 addition & 0 deletions packages/web3-eth-accounts/src/tx/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
import type { HexString, Numbers } from 'web3-types';

import type { Common } from '../common/common.js';
// eslint-disable-next-line require-extensions/require-extensions
import type { Uint8ArrayLike, PrefixedHexString } from '../common/types';
import { Address } from './address.js';

Expand Down
4 changes: 4 additions & 0 deletions packages/web3-types/src/web3_base_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Socket } from 'net';

import { Web3Error } from './error_types.js';
import { EthExecutionAPI } from './apis/eth_execution_api.js';
// eslint-disable-next-line require-extensions/require-extensions
import {
JsonRpcNotification,
JsonRpcPayload,
Expand All @@ -27,6 +28,7 @@ import {
JsonRpcResult,
JsonRpcSubscriptionResult,
} from './json_rpc_types';
// eslint-disable-next-line require-extensions/require-extensions
import {
Web3APISpec,
Web3APIMethod,
Expand All @@ -36,7 +38,9 @@ import {
ProviderRpcError,
ProviderMessage,
} from './web3_api_types';
// eslint-disable-next-line require-extensions/require-extensions
import { Web3EthExecutionAPI } from './apis/web3_eth_execution_api';
// eslint-disable-next-line require-extensions/require-extensions
import { Web3DeferredPromiseInterface } from './web3_deferred_promise_type';

const symbol = Symbol.for('web3/base-provider');
Expand Down
4 changes: 4 additions & 0 deletions packages/web3-validator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ Documentation:
- Added `json-schema` as a main json schema type (#6264)

## [Unreleased]

### Fixed

- ESM import bug (#6359)
1 change: 1 addition & 0 deletions packages/web3-validator/src/validation/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

import { AbiParameter } from 'web3-types';
// eslint-disable-next-line require-extensions/require-extensions
import { ShortValidationSchema } from '../types';

export const isAbiParameterSchema = (
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { z, ZodType, ZodIssue, ZodIssueCode, ZodTypeAny } from 'zod';
import { RawCreateParams } from 'zod/lib/types';
import { Web3ValidatorError } from './errors.js';
import { Json, JsonSchema } from './types.js';
import formats from './formats';
import formats from './formats.js';

const convertToZod = (schema: JsonSchema): ZodType => {
if ((!schema?.type || schema?.type === 'object') && schema?.properties) {
Expand Down
1 change: 1 addition & 0 deletions tools/eslint-config-web3-base/ts-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
'jest/globals': true,
},
rules: {
'require-extensions/require-extensions': 'off',
'jest/valid-title': ['error'],
'jest/no-conditional-expect': ['error'],
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
Expand Down
10 changes: 9 additions & 1 deletion tools/eslint-config-web3-base/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ const license = [

module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'header', 'deprecation', 'eslint-plugin-tsdoc', 'no-null'],
plugins: [
'@typescript-eslint',
'header',
'deprecation',
'eslint-plugin-tsdoc',
'no-null',
'require-extensions',
],
extends: [
'airbnb-base',
'eslint:recommended',
Expand All @@ -48,6 +55,7 @@ module.exports = {
'plugin:import/typescript',
],
rules: {
'require-extensions/require-extensions': 'error',
'deprecation/deprecation': 'error',
'header/header': [2, 'block', license, 1],
'class-methods-use-this': ['error'],
Expand Down
3 changes: 2 additions & 1 deletion tools/web3-plugin-example/src/contract_method_wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { Web3PluginBase } from 'web3-core';
import Contract from 'web3-eth-contract';
import { Address, ContractAbi, DataFormat, DEFAULT_RETURN_FORMAT, Numbers } from 'web3-types';
import { format, numberToHex } from 'web3-utils';

// eslint-disable-next-line require-extensions/require-extensions
import { ERC20TokenAbi } from './ERC20Token';
// eslint-disable-next-line require-extensions/require-extensions
import { Web3Context } from './reexported_web3_context';

export class ContractMethodWrappersPlugin extends Web3PluginBase {
Expand Down
2 changes: 1 addition & 1 deletion tools/web3-plugin-example/src/custom_rpc_methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
import { Web3PluginBase } from 'web3-core';

// eslint-disable-next-line require-extensions/require-extensions
import { Web3Context } from './reexported_web3_context';

type CustomRpcApi = {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4666,6 +4666,11 @@ eslint-plugin-no-null@^1.0.2:
resolved "https://registry.yarnpkg.com/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz#1236a812391390a1877ad4007c26e745341c951f"
integrity sha512-uRDiz88zCO/2rzGfgG15DBjNsgwWtWiSo4Ezy7zzajUgpnFIqd1TjepKeRmJZHEfBGu58o2a8S0D7vglvvhkVA==

eslint-plugin-require-extensions@^0.1.3:
version "0.1.3"
resolved "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz#394aeab433f996797a6ceba0a3f75640d4846bc8"
integrity sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==

eslint-plugin-tsdoc@^0.2.16:
version "0.2.16"
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.16.tgz#a3d31fb9c7955faa3c66a43dd43da7635f1c5e0d"
Expand Down

0 comments on commit 86f0cdb

Please sign in to comment.