Skip to content

Commit eca5d21

Browse files
authored
refactor!: switch to esm-only and update ml-gsd (#25)
* extend `@zakodium/tsconfig` * add `allowImportingTsExtensions` and `noUncheckedIndexedAccess` flags * ci: update typedoc workflow Closes: #24 Refs: https://github.com/cheminfo/generator-cheminfo/blob/main/ts-migration.md#configure-eslint
1 parent ef3797e commit eca5d21

File tree

81 files changed

+204
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+204
-279
lines changed

.github/workflows/typedoc.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
1-
name: Deploy TypeDoc on GitHub pages
1+
name: TypeDoc
22

33
on:
44
workflow_dispatch:
55
release:
66
types: [published]
77

8-
env:
9-
NODE_VERSION: 16.x
10-
ENTRY_FILE: 'src/index.ts'
11-
128
jobs:
13-
deploy:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions/setup-node@v3
18-
with:
19-
node-version: ${{ env.NODE_VERSION }}
20-
- name: Install dependencies
21-
run: npm install
22-
- name: Build documentation
23-
uses: zakodium/typedoc-action@v2
24-
with:
25-
entry: ${{ env.ENTRY_FILE }}
26-
- name: Deploy to GitHub pages
27-
uses: JamesIves/github-pages-deploy-action@releases/v4
28-
with:
29-
token: ${{ secrets.BOT_TOKEN }}
30-
branch: gh-pages
31-
folder: docs
32-
clean: true
9+
typedoc:
10+
# Documentation: https://github.com/zakodium/workflows#typedoc
11+
uses: zakodium/workflows/.github/workflows/typedoc.yml@typedoc-v1
12+
with:
13+
entry: 'src/index.ts'
14+
secrets:
15+
github-token: ${{ secrets.BOT_TOKEN }}

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CHANGELOG.md
2+
lib
3+
coverage
4+
FilterXYSchema.json
5+
FilterXYSchema.js

FilterXYSchema.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
declare const schema: typeof import('./FilterXYSchema.json')
1+
declare const schema: typeof import('./FilterXYSchema.json');
22
export = schema;

eslint.config.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
12
import cheminfo from 'eslint-config-cheminfo-typescript';
23

3-
export default [
4-
...cheminfo,
5-
{
6-
languageOptions: {},
7-
rules: {},
8-
},
9-
];
4+
export default defineConfig(
5+
globalIgnores(['coverage', 'lib', 'FilterXYSchema.*']),
6+
cheminfo,
7+
);

package.json

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,32 @@
22
"name": "ml-signal-processing",
33
"version": "1.2.0",
44
"description": "Process data in the form of {x:[], y:[]}",
5-
"main": "./lib/index.js",
6-
"module": "./lib-esm/index.js",
7-
"types": "./lib/index.d.ts",
5+
"type": "module",
6+
"exports": "./lib/index.js",
87
"keywords": [],
98
"author": "Luc Patiny",
109
"license": "MIT",
1110
"files": [
1211
"src",
1312
"lib",
14-
"lib-esm",
1513
"FilterXYSchema.d.ts",
1614
"FilterXYSchema.js",
1715
"FilterXYSchema.json"
1816
],
1917
"scripts": {
2018
"check-types": "tsc --noEmit",
21-
"clean": "rimraf lib lib-esm",
19+
"clean": "rimraf lib",
2220
"createSchema": "typescript-json-schema --refs false ./tsconfig.json FilterXYType > FilterXYSchema.json",
2321
"postcreateSchema": "node scripts/create_js_schema.mjs",
24-
"eslint": "eslint src --cache",
25-
"eslint-fix": "npm run eslint -- --fix",
22+
"eslint": "eslint . --cache",
23+
"eslint-fix": "node --run eslint -- --fix",
2624
"prepack": "npm run createSchema && npm run tsc",
27-
"prettier": "prettier --check src",
28-
"prettier-write": "prettier --write src",
25+
"prettier": "prettier --check .",
26+
"prettier-write": "prettier --write .",
2927
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
3028
"test-only": "vitest run --coverage",
31-
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
32-
"tsc-cjs": "tsc --project tsconfig.cjs.json",
33-
"tsc-esm": "tsc --project tsconfig.esm.json"
29+
"tsc": "npm run clean && npm run tsc-build",
30+
"tsc-build": "tsc --project tsconfig.build.json"
3431
},
3532
"repository": {
3633
"type": "git",
@@ -41,22 +38,22 @@
4138
},
4239
"homepage": "https://github.com/mljs/signal-processing#readme",
4340
"devDependencies": {
44-
"@vitest/coverage-v8": "^2.1.4",
45-
"eslint": "^9.14.0",
46-
"eslint-config-cheminfo-typescript": "^16.0.0",
41+
"@vitest/coverage-v8": "^3.2.3",
42+
"@zakodium/tsconfig": "^1.0.1",
43+
"eslint": "^9.29.0",
44+
"eslint-config-cheminfo-typescript": "^18.0.1",
4745
"jest-matcher-deep-close-to": "^3.0.2",
48-
"prettier": "^3.3.3",
46+
"prettier": "^3.5.3",
4947
"rimraf": "^6.0.1",
50-
"ts-jest": "^29.2.5",
51-
"typescript": "^5.6.3",
48+
"typescript": "^5.8.3",
5249
"typescript-json-schema": "^0.65.1",
53-
"vitest": "^2.1.4"
50+
"vitest": "^3.2.3"
5451
},
5552
"dependencies": {
5653
"baselines": "^1.1.9",
5754
"cheminfo-types": "^1.8.1",
58-
"ml-gsd": "^12.1.8",
55+
"ml-gsd": "^13.0.1",
5956
"ml-savitzky-golay-generalized": "^4.2.0",
60-
"ml-spectra-processing": "^14.6.2"
57+
"ml-spectra-processing": "^14.12.0"
6158
}
6259
}

scripts/create_js_schema.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import fs from 'node:fs';
22

3-
const schema = fs.readFileSync(new URL('../FilterXYSchema.json', import.meta.url), 'utf8');
3+
const schema = fs.readFileSync(
4+
new URL('../FilterXYSchema.json', import.meta.url),
5+
'utf8',
6+
);
47

58
const schemaJs = `'use strict';
69

src/FilterMatrixType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { MatrixCenterZMeanFilter } from './matrixFilters/centerZMean';
2-
import { PQNFilter } from './matrixFilters/pqn';
3-
import { MatrixZRescaleFilter } from './matrixFilters/zRescale';
1+
import type { MatrixCenterZMeanFilter } from './matrixFilters/centerZMean.ts';
2+
import type { PQNFilter } from './matrixFilters/pqn.ts';
3+
import type { MatrixZRescaleFilter } from './matrixFilters/zRescale.ts';
44

55
export type FilterMatrixType =
66
| MatrixCenterZMeanFilter

src/FilterXYType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
AirPLSBaselineFilter,
33
CenterMeanFilter,
44
CenterMedianFilter,
@@ -21,8 +21,8 @@ import {
2121
YFunctionFilter,
2222
CalibrateFilter,
2323
ParetoNormalizationFilter,
24-
} from './filters/filters';
25-
import { ReverseIfNeededFilter } from './filters/x/reverseIfNeeded';
24+
} from './filters/filters.ts';
25+
import type { ReverseIfNeededFilter } from './filters/x/reverseIfNeeded.ts';
2626

2727
export type FilterXYType =
2828
| AirPLSBaselineFilter
File renamed without changes.

src/__tests__/filterMatrix.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from 'vitest';
22

3-
import { filterMatrix } from '..';
4-
import { FilterMatrixType } from '../FilterMatrixType';
3+
import type { FilterMatrixType } from '../FilterMatrixType.ts';
4+
import { filterMatrix } from '../index.ts';
55

66
test('filterMatrix', () => {
77
const filters: FilterMatrixType[] = [

0 commit comments

Comments
 (0)