Skip to content

Commit 34047f4

Browse files
committed
refactor: setup project for TypeScript
1 parent d96fee1 commit 34047f4

10 files changed

+58
-25
lines changed

.eslintcache

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"/home/javierosorio/github/josoriom/CPCA/src/__tests__/cpca.test.js":"1","/home/javierosorio/github/josoriom/CPCA/src/index.js":"2"},{"size":1675,"mtime":1663732397792,"results":"3","hashOfConfig":"4"},{"size":7199,"mtime":1663736601252,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","suppressedMessages":"8","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"173h6nn",{"filePath":"9","messages":"10","suppressedMessages":"11","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/javierosorio/github/josoriom/CPCA/src/__tests__/cpca.test.js",[],[],"/home/javierosorio/github/josoriom/CPCA/src/index.js",[],[]]

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
extends: cheminfo
1+
extends: cheminfo-typescript
22
parserOptions:
33
sourceType: module

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ tags
7979
!.vscode/tasks.json
8080
!.vscode/launch.json
8181
!.vscode/extensions.json
82-
*.code-workspace
82+
*.code-workspace
83+
lib-esm

babel.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
2-
"plugins": ["@babel/plugin-transform-modules-commonjs"]
2+
presets: ['@babel/preset-typescript'],
3+
plugins: ['@babel/plugin-transform-modules-commonjs'],
34
};

package.json

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,29 @@
22
"name": "cpca",
33
"version": "0.0.1",
44
"description": "statistical",
5-
"main": "src/index.js",
5+
"main": "./lib/index.js",
6+
"module": "./lib-esm/index.js",
7+
"types": "./lib/index.d.ts",
68
"files": [
9+
"src",
710
"lib",
8-
"src"
11+
"lib-esm"
912
],
1013
"scripts": {
11-
"compile": "rollup -c",
12-
"build": "cheminfo build --root dist",
13-
"prepublishOnly": "npm run compile",
14-
"eslint": "eslint src",
14+
"build": "npm run tsc && cheminfo-build",
15+
"check-types": "tsc --noEmit",
16+
"clean": "rimraf lib lib-esm",
17+
"eslint": "eslint src --cache",
1518
"eslint-fix": "npm run eslint -- --fix",
16-
"test": "npm run test-only && npm run eslint",
17-
"test-coverage": "jest --coverage",
18-
"test-travis": "npm run test-coverage && npm run eslint",
19-
"test-only": "jest"
19+
"prepack": "npm run tsc",
20+
"prettier": "prettier --check src",
21+
"prettier-write": "prettier --write src",
22+
"test": "npm run test-coverage && npm run eslint && npm run prettier && npm run check-types",
23+
"test-coverage": "npm run test-only -- --coverage",
24+
"test-only": "jest",
25+
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
26+
"tsc-cjs": "tsc --project tsconfig.cjs.json",
27+
"tsc-esm": "tsc --project tsconfig.esm.json"
2028
},
2129
"repository": {
2230
"type": "git",
@@ -40,17 +48,18 @@
4048
"trailingComma": "all"
4149
},
4250
"devDependencies": {
43-
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
51+
"@babel/preset-typescript": "^7.18.6",
4452
"@types/jest": "^29.0.3",
4553
"cheminfo-build": "^1.1.11",
4654
"eslint": "^8.23.1",
47-
"eslint-config-cheminfo": "^8.0.2",
55+
"eslint-config-cheminfo-typescript": "^11.1.0",
4856
"eslint-plugin-import": "^2.26.0",
4957
"eslint-plugin-jest": "^26.4.6",
5058
"eslint-plugin-prettier": "^4.2.1",
5159
"jest": "^29.0.3",
5260
"prettier": "^2.7.1",
53-
"rollup": "^2.79.0"
61+
"rimraf": "^3.0.2",
62+
"typescript": "^4.8.3"
5463
},
5564
"dependencies": {
5665
"jest-matcher-deep-close-to": "^3.0.2",

rollup.config.js

-8
This file was deleted.

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export default class CPCA {
160160
if (i === 0) {
161161
Psup.setSubMatrix(loadingBlocks[i], counter, 0);
162162
} else if (this.blocksSlicing[i] === 1) {
163-
Psup.setSubMatrix(loadingBlocks[i], counter, 0);
163+
Psup.setSubMatrix(loadingBlocks[i], counter, 0);
164164
}
165165
counter += loadingBlocks[i].rows;
166166
}

tsconfig.cjs.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"declaration": true,
6+
"declarationMap": true
7+
},
8+
"exclude": ["./src/**/__tests__"]
9+
}

tsconfig.esm.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.cjs.json",
3+
"compilerOptions": {
4+
"module": "es2020",
5+
"outDir": "lib-esm"
6+
}
7+
}

tsconfig.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"esModuleInterop": true,
5+
"moduleResolution": "node",
6+
"outDir": "lib",
7+
"sourceMap": true,
8+
"strict": true,
9+
"target": "es2020"
10+
},
11+
"include": ["./src/**/*"]
12+
}
13+

0 commit comments

Comments
 (0)