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

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'v22.22.2'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we migrate to node 24?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open another PR

node-version: '22.23.1'
- name: Cache node_modules
uses: actions/cache@v3
env:
Expand All @@ -42,7 +42,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: ['v22.22.2']
node: ['22.23.1']

steps:
- uses: actions/checkout@v4
Expand All @@ -66,7 +66,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'v22.22.2'
node-version: '22.23.1'
- name: Cache node_modules
uses: actions/cache@v3
env:
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'v22.22.2'
node-version: '22.23.1'
- name: Cache node_modules
uses: actions/cache@v3
env:
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'v22.22.2'
node-version: '22.23.1'

- name: Cache node_modules
uses: actions/cache@v3
Expand Down Expand Up @@ -241,13 +241,13 @@ jobs:
with:
repository: 'oceanprotocol/ocean-cli'
path: 'ocean-cli'
ref: feature/next-node-4
ref: deps/remove_web3_and_bump_deps
- name: Checkout Ocean-js
uses: actions/checkout@v4
with:
repository: 'oceanprotocol/ocean.js'
path: 'ocean.js'
ref: next-release-v9
ref: feature/update_web3_deps
- name: Build ocean-js
working-directory: ${{ github.workspace }}/ocean.js
run: |
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
22.22.2
22.23.1

40 changes: 30 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,32 @@ of which dispatch to the same set of command handlers.

## 1. Environment & tooling prerequisites

- **Node.js ≥ 22.13 is required** (`.nvmrc` pins `22.22.2`, matching the Dockerfile and CI;
`package.json` `engines` requires `>=22.13.0`). Always run `nvm use` (or `source ~/.nvm/nvm.sh && nvm use`) before
- **Node.js ≥ 22.13 is required** (`.nvmrc` pins `22.23.1`, matching the Dockerfile and CI;
`package.json` `engines` requires `>=22.13.0`). The Dockerfile additionally pins each base
image by digest, so bumping the version means updating the `sha256:` alongside the tag —
resolve it with `docker buildx imagetools inspect node:<version>-trixie`, not from the tag
alone. Always run `nvm use` (or `source ~/.nvm/nvm.sh && nvm use`) before
any `npm`, build, or test command. The wrong Node version fails with errors like
`Unexpected token 'with'`, missing `GLIBC_2.38`, or — since the SQLite layer uses the
built-in `node:sqlite` module — `ERR_UNKNOWN_BUILTIN_MODULE: node:sqlite` on Node < 22.13.
This is enforced by `.cursor/rules/tests-nvm.mdc` and the in-repo `CLAUDE.md`.
- **`postinstall` runs `scripts/fix-libp2p-http-utils.js`** — a patch applied to a libp2p
dependency. Expect it to run on every `npm install`; don't remove it.
- **There is no `postinstall` step.** `npm install` is plain. (Historically a `postinstall`
ran `scripts/fix-libp2p-http-utils.js` to default a missing URL port to 443/80 in
`@libp2p/http-utils`; upstream shipped that fix in `2.0.3`, so both the hook and the
script were removed.)
- **Docker + docker-compose** are needed for the metadata database (Typesense or
Elasticsearch) and for C2D (Compute-to-Data) via the local Docker socket.
- TypeScript config: ESM (`module: esnext`, `target: ES2022`, `moduleResolution: node`),
`experimentalDecorators` + `emitDecoratorMetadata` enabled, `rootDir: ./src`,
`outDir: ./dist`. All local imports use the `.js` extension (compiled ESM convention).
- TypeScript config: **TypeScript 6**, ESM (`module: esnext`, `target: ES2022`,
`moduleResolution: node`), `experimentalDecorators` + `emitDecoratorMetadata` enabled,
`rootDir: ./src`, `outDir: ./dist`. Most local imports use the `.js` extension
(compiled ESM convention), though ~31 relative imports still omit it.
- `strict` is **on**, with two documented exceptions: `strictNullChecks: false` and
`useUnknownInCatchVariables: false`. Turning either on is a real project (~1324 and
~389 errors); do it subsystem by subsystem, not in passing.
- Two things must be done before TypeScript 7: `moduleResolution` has to move off
`node10` (`ignoreDeprecations: "6.0"` only defers it, and `nodenext` currently costs
~123 errors), and `typescript-eslint` has to support TS 7 — its peer range is
`>=4.8.4 <6.1.0`, so it pins us below 7 today.

### Only-mandatory config: `PRIVATE_KEY`

Expand Down Expand Up @@ -63,13 +76,20 @@ The Dockerfile uses the identical CMD. The compiled entry point is `dist/index.j
### Lint / format

```bash
npm run lint # eslint (.ts,.tsx) + type-check
npm run lint # eslint + type-check
npm run lint:fix # eslint --fix
npm run format # prettier --write '**/*.{js,jsx,ts,tsx}'
```

ESLint extends `oceanprotocol` + `prettier/recommended`. Notable rules: `require-await`
is an **error**, `no-unused-vars` is an **error**, empty catch blocks are allowed. Prettier:
ESLint 10 with flat config in `eslint.config.js` (there is no `.eslintrc`/`.eslintignore`).
`eslint-config-oceanprotocol` is **not** used — it is pinned to eslint ^8 and cannot follow
eslint to flat config, so the preset is composed in-repo from `@eslint/js`,
`typescript-eslint`, `eslint-plugin-security`, `eslint-plugin-promise` and
`eslint-plugin-prettier`. Only `**/*.ts` is linted; `.js` is ignored as build output.
Notable rules: `require-await` is an **error**, `no-unused-vars` is an **error** (with
`args: 'none'`, `caughtErrors: 'none'`), empty catch blocks are allowed. `@typescript-eslint`'s
`recommended` set is deliberately *not* extended, and a few rules that eslint 9/10 and the
newer plugins added are switched off — see the comments in `eslint.config.js`. Prettier:
no semicolons, single quotes, `printWidth: 90`, no trailing commas, 2-space tabs.

### Tests (important build quirk)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:22.22.2-trixie@sha256:17ccc50fade521c62e2acefd0c975bf5eb2a09632b8717fa7f8b1c2b4e967a07 AS builder
FROM node:22.23.1-trixie@sha256:3145536027ca5268e24654f7efebf1dbdd684cda3708324e6c53f4ad61af8710 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
build-essential \
Expand All @@ -14,7 +14,7 @@ COPY . .
RUN npm run build && npm prune --omit=dev


FROM node:22.22.2-trixie-slim@sha256:76043ed3132293c26b960ede4358d3c8ba424ee64662cd2d56318b76fcc51c4c AS runner
FROM node:22.23.1-trixie-slim@sha256:e6d9a389d34ff9678438af985c9913fbd1eb6ed36e80fea56644f4b4f6dd70ba AS runner
RUN apt-get update && apt-get install -y --no-install-recommends \
dumb-init \
gosu \
Expand Down
100 changes: 100 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import security from 'eslint-plugin-security'
import promise from 'eslint-plugin-promise'
// this pulls in eslint-config-prettier, which is why that package is a declared
// devDependency despite never being imported by name (it is an *optional* peer of
// eslint-plugin-prettier, so npm will not reliably install it on its own)
import prettierRecommended from 'eslint-plugin-prettier/recommended'

// Replaces the .eslintrc that extended eslint-config-oceanprotocol. That config is
// pinned to eslint ^8 and cannot follow eslint to flat config, so the preset is
// composed here instead.
//
// The rule set is held at the severity the old gate actually resolved to
// (0 errors, 40 warnings), taken from `eslint --print-config` on the previous
// setup. Rules that eslint 9/10 and the newer plugins add on top are switched off
// rather than fixed here, so this dependency bump does not double as a lint-debt PR.
export default tseslint.config(
{
// only TypeScript is linted - the .js in the tree is build output, k6
// performance scripts or plain node helpers
ignores: [
'**/*.js',
'**/*.mjs',
'**/*.cjs',
'dist/',
'coverage/',
'.nyc_output/',
'databases/',
'c2d_storage/',
'logs/'
]
},
{
files: ['**/*.ts'],
// a stale eslint-disable is a lie about the code, so these are errors rather
// than warnings: it keeps the directives honest as rules move around
linterOptions: { reportUnusedDisableDirectives: 'error' },
extends: [
js.configs.recommended,
// parser + plugin wiring only. The old config never pulled in
// @typescript-eslint's `recommended`, and adopting it here would add
// ~1350 no-explicit-any errors unrelated to the dependency bump.
tseslint.configs.base,
security.configs.recommended,
prettierRecommended
],
// eslint-plugin-promise is registered but not extended: the old config
// enabled promise/param-names only, not the plugin's recommended set
plugins: { promise },
languageOptions: {
sourceType: 'module',
globals: {
...globals.node,
...globals.browser,
...globals.mocha,
NodeJS: true,
RequestInit: true
}
},
rules: {
// from .eslintrc
'no-empty': ['error', { allowEmptyCatch: true }],
'prefer-destructuring': ['warn', { object: true, array: false }],
'no-dupe-class-members': ['warn'],
'no-useless-constructor': ['warn'],
'constructor-super': ['warn'],
'require-await': 'error',

// from eslint-config-standard, via eslint-config-oceanprotocol
'no-unused-vars': [
'error',
{ args: 'none', caughtErrors: 'none', ignoreRestSiblings: true, vars: 'all' }
],
'no-unused-expressions': [
'error',
{ allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }
],
'no-constant-condition': ['error', { checkLoops: false }],
'promise/param-names': 'error',
// these three cost nothing on the current tree and keep the existing
// eslint-disable comments for them meaningful. Three more that standard
// supplied are deliberately absent: no-await-in-loop (264 violations),
// camelcase (111) and no-use-before-define (54) - the old gate did not
// enforce them either, so turning them on is its own piece of work.
'no-new': 'error',
'no-self-compare': 'error',
'no-unmodified-loop-condition': 'error',

// added to eslint's recommended set after v8 - not part of the old gate
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',

// eslint-config-oceanprotocol explicitly disabled this; it fires on every
// bracket access and would add ~128 warnings
'security/detect-object-injection': 'off'
}
}
)
Loading
Loading