Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
33 changes: 0 additions & 33 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion CodeExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Next, we define the metadata that will describe our data asset. This is what we
publisherAccount = (await provider.getSigner(0)) as Signer
consumerAccount = (await provider.getSigner(1)) as Signer
stakerAccount = (await provider.getSigner(2)) as Signer
const config = new ConfigHelper().getConfig(
config = new ConfigHelper().getConfig(
parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
)
Object.assign(config, getNodeEndpointConfig())
Expand Down
2 changes: 1 addition & 1 deletion ComputeExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ We need to load the configuration. Add the following code into your `run(){ }` f
)
publisherAccount = (await provider.getSigner(0)) as Signer
consumerAccount = (await provider.getSigner(1)) as Signer
const config = new ConfigHelper().getConfig(
config = new ConfigHelper().getConfig(
parseInt(String((await publisherAccount.provider.getNetwork()).chainId))
)
Object.assign(config, getNodeEndpointConfig())
Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,34 @@ npm install @oceanprotocol/lib
- Developers using this library should ensure their tsconfig.json includes the necessary options:
```
{
"moduleResolution": "node",
"moduleResolution": "bundler",
"module": "esnext",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
```
- If using Next.js, they may need "moduleResolution": "bundler" for better compatibility.
- `"moduleResolution": "nodenext"` works too. The older `"node"` (node10) mode was removed in
TypeScript 7, so don't use it — and it cannot resolve this package's `exports` map anyway.

### ESM only

`@oceanprotocol/lib` ships as ES modules only — there is no CommonJS build, because most of
its runtime dependencies (the libp2p stack, `multiformats`, `uint8arrays`) are themselves
ESM-only. Import it:

```js
import { ProviderInstance, ConfigHelper } from '@oceanprotocol/lib'
```

From CommonJS code, use Node's built-in `require(esm)` support, available from **Node
22.12**:

```js
const { ConfigHelper } = require('@oceanprotocol/lib')
```

On Node 22.0–22.11 this throws `ERR_REQUIRE_ESM`; use a dynamic `await import(...)`
instead, or move the calling module to ESM.

## 📖 Documentation

Expand Down
62 changes: 62 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import prettierRecommended from 'eslint-plugin-prettier/recommended'
import globals from 'globals'
import security from 'eslint-plugin-security'

// Flat config, replacing .eslintrc + eslint-config-oceanprotocol. ESLint 10 dropped
// eslintrc entirely, and eslint-config-oceanprotocol (2022) is eslintrc-only and built on
// eslint-config-standard@17, which peers on eslint ^8 — so it could not come along.
// The rule set below is deliberately behaviour-neutral: the gate still fails only on the
// things it failed on before (prettier formatting, real errors), with the same rules
// downgraded to warnings as the old .eslintrc had.
export default tseslint.config(
{ ignores: ['dist/**', 'docs/**', 'coverage/**', '.nyc_output/**'] },
js.configs.recommended,
tseslint.configs.recommended,
prettierRecommended,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.mocha,
NodeJS: 'readonly'
}
},
plugins: { security },
rules: {
// eslint-config-oceanprotocol bundled eslint-plugin-security; only this rule was
// actually load-bearing (src/ and test/ carry disable directives acknowledging
// deliberate non-literal fs reads), so it is enabled explicitly rather than
// pulling in the plugin's whole noisy recommended set.
'security/detect-non-literal-fs-filename': 'error',

// Rules new to ESLint 10 / typescript-eslint that the old standardjs-based config
// never applied. Left off so this migration does not change what the gate rejects;
// enable them as separate, deliberate cleanups:
// no-explicit-any (173 hits) preserve-caught-error (25 hits)
'@typescript-eslint/no-explicit-any': 'off',
'preserve-caught-error': 'off',

// New in ESLint 10. It found 6 real defects on introduction: two shadowed `config`
// declarations in the guide-generating tests, and four declarations belonging to the
// fully-disabled onchain/graphql flows in PublishEditConsume. All six are fixed, so
// this stays at 'error' to stop the pattern coming back.

// carried over verbatim from the old .eslintrc
'no-empty': ['error', { allowEmptyCatch: true }],
'prefer-destructuring': ['warn', { object: true, array: false }],
'constructor-super': ['warn'],
// core versions are superseded by the typescript-eslint ones
'no-unused-vars': 'off',
'no-dupe-class-members': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-dupe-class-members': ['warn'],
'@typescript-eslint/no-useless-constructor': ['warn']
}
}
)
Loading
Loading