Skip to content

Commit 1ff9aa3

Browse files
authored
refactor!: migrate to TypeScript and ESM-only (#21)
Refs: https://github.com/cheminfo/generator-cheminfo/blob/main/ts-migration.md fix: update `is-any-array` to v3
1 parent 03f0480 commit 1ff9aa3

File tree

134 files changed

+1001
-3147
lines changed

Some content is hidden

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

134 files changed

+1001
-3147
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ jobs:
1111
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
1212
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
1313
with:
14-
node-version-matrix: '[12, 14, 16]'
15-
npm-setup-command: 'npm install && npm run prepare && npm run build'
14+
lint-check-types: true
15+
disable-test-package: true # Monorepo, root not publishable
16+

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,8 @@ typings/
5858
.env
5959

6060
.idea
61+
62+
# Lib (ts) artifacts
63+
6164
/packages/*/lib/
62-
/packages/*/lib-es6/
65+
/packages/*/*.tsbuildinfo

.prettierignore

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Functional utilities to transform and compute stats on arrays
55
## Packages
66

77
| Name | Description |
8-
|--------------------------------------------------------------------|------------------------------------------------|
8+
| ------------------------------------------------------------------ | ---------------------------------------------- |
99
| [ml-array-sequential-fill](./packages/array-sequential-fill) | Fill / create an array with sequential numbers |
1010
| [ml-array-min](./packages/array-min) | Get the minimum value in an array |
1111
| [ml-array-max](./packages/array-max) | Get the maximum value in an array |

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

eslint.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
import { defineConfig, globalIgnores } from 'eslint/config';
6+
import ts from 'eslint-config-cheminfo-typescript/base';
7+
import unicorn from 'eslint-config-cheminfo-typescript/unicorn';
8+
import vitest from 'eslint-config-cheminfo-typescript/vitest';
9+
10+
export default defineConfig(
11+
globalIgnores([
12+
'**/coverage',
13+
'**/lib',
14+
'**/lib-internal',
15+
'**/docs',
16+
'**/CHANGELOG.md',
17+
'/src/',
18+
]),
19+
ts,
20+
unicorn,
21+
vitest,
22+
createNoExtraneousConfigs(),
23+
{
24+
// it uses an old `median-quickselect` package, which does not have types,
25+
// so triple-slash-reference is used to declare `median-quickselect` module.
26+
files: ['packages/array-median/src/index.ts'],
27+
rules: {
28+
'@typescript-eslint/triple-slash-reference': 'off',
29+
},
30+
},
31+
);
32+
33+
function createNoExtraneousConfigs() {
34+
const configs = [];
35+
for (const pkg of fs.readdirSync('packages')) {
36+
configs.push({
37+
files: [`packages/${pkg}/**`],
38+
rules: {
39+
'import/no-extraneous-dependencies': [
40+
'error',
41+
{
42+
packageDir: [
43+
fileURLToPath(new URL(`packages/${pkg}`, import.meta.url)),
44+
path.dirname(fileURLToPath(import.meta.url)),
45+
],
46+
},
47+
],
48+
},
49+
});
50+
}
51+
return configs;
52+
}

lerna.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
23
"conventionalCommits": true,
34
"packages": ["packages/*"],
45
"command": {

package.json

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
{
2-
"private": true,
32
"name": "ml-array-utils",
4-
"main": "lib/index.js",
5-
"module": "src/index.js",
3+
"private": true,
4+
"version": "1.0.0",
65
"description": "Functional utilities to transform and compute stats on arrays",
6+
"type": "module",
7+
"workspaces": [
8+
"packages/*"
9+
],
710
"scripts": {
8-
"bootstrap": "lerna bootstrap --no-ci",
9-
"build": "npm run build-clean && lerna exec -- rollup -c ../../rollup.config.js",
10-
"build-clean": "rimraf ./packages/*/lib/ && rimraf ./packages/*/lib-es6/",
11-
"eslint": "eslint packages/**/*.js --cache",
11+
"build": "npm run build-clean && npm run tsc",
12+
"build-clean": "rimraf packages/*/lib packages/*/*.tsbuildinfo",
13+
"check-types": "tsc --noEmit",
14+
"coverage-clean": "rimraf coverage",
15+
"eslint": "eslint . --cache",
1216
"eslint-fix": "npm run eslint -- --fix",
13-
"prepare": "npm run bootstrap",
14-
"prettier": "prettier --check src",
15-
"prettier-write": "prettier --write src",
16-
"publish": "git pull --rebase && npm run build && npm run test-publish && lerna publish",
17-
"test": "run-s build test-only eslint prettier",
18-
"test-watch": "jest --watch",
19-
"test-publish": "run-s test-only eslint",
20-
"test-only": "jest --coverage"
17+
"full-clean": "npm run build-clean && npm run coverage-clean && npm run install-clean",
18+
"install-clean": "rimraf node_modules packages/*/node_modules",
19+
"prettier": "prettier --check .",
20+
"prettier-write": "prettier --write .",
21+
"publish": "npm run test && npm run build && npm run test && lerna publish -y --no-verify-access",
22+
"test": "npm run test-only && tsc --noEmit && npm run eslint && npm run prettier",
23+
"test-only": "vitest --run --coverage",
24+
"tsc": "tsc --build",
25+
"tsc-watch": "tsc --build --watch"
2126
},
2227
"devDependencies": {
23-
"@babel/plugin-transform-modules-commonjs": "^7.16.8",
24-
"@babel/preset-env": "^7.16.11",
25-
"@rollup/plugin-babel": "^5.3.1",
26-
"eslint": "^8.10.0",
27-
"eslint-config-cheminfo": "^7.2.2",
28-
"jest": "^27.5.1",
29-
"lerna": "^4.0.0",
30-
"npm-run-all": "^4.1.5",
31-
"prettier": "^2.5.1",
32-
"rimraf": "^3.0.2",
33-
"rollup": "^2.68.0"
28+
"@types/node": "^25.6.0",
29+
"@vitest/coverage-v8": "^4.1.4",
30+
"@zakodium/tsconfig": "^1.0.5",
31+
"eslint": "^9.39.4",
32+
"eslint-config-cheminfo-typescript": "^21.2.0",
33+
"lerna": "^9.0.5",
34+
"prettier": "^3.8.2",
35+
"rimraf": "^6.1.3",
36+
"typescript": "^6.0.2",
37+
"vitest": "^4.1.4"
3438
}
3539
}

0 commit comments

Comments
 (0)