Skip to content

Commit f9d59d2

Browse files
committed
chore: update config files for TS
1 parent 072f0c5 commit f9d59d2

10 files changed

+953
-1245
lines changed

.eslintrc.js

-43
This file was deleted.

.eslintrc.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": [
4+
"@typescript-eslint"
5+
],
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/eslint-recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"ignorePatterns": [
12+
"build/**/*.ts",
13+
"**/*.js"
14+
],
15+
"rules": {
16+
"no-prototype-builtins": 0,
17+
"no-unused-vars": 0,
18+
"newline-before-return": 1,
19+
"@typescript-eslint/no-unused-vars": [
20+
"warn",
21+
{
22+
"args": "none"
23+
}
24+
],
25+
"@typescript-eslint/ban-ts-ignore": 0,
26+
"@typescript-eslint/camelcase": 0,
27+
"@typescript-eslint/explicit-function-return-type": 1,
28+
"@typescript-eslint/explicit-member-accessibility": [
29+
"warn",
30+
{
31+
"overrides": {
32+
"constructors": "no-public"
33+
}
34+
}
35+
],
36+
"@typescript-eslint/interface-name-prefix": 0,
37+
"@typescript-eslint/no-explicit-any": 0,
38+
"semi": 0,
39+
"@typescript-eslint/semi": 2,
40+
"quotes": 0,
41+
"@typescript-eslint/quotes": 2,
42+
"no-duplicate-imports": 2,
43+
"@typescript-eslint/explicit-module-boundary-types": 0,
44+
"@typescript-eslint/triple-slash-reference": 0,
45+
"no-trailing-spaces": 2
46+
}
47+
}

.gitattributes

-63
This file was deleted.

.mocharc.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require:
2+
- "ts-node/register"
3+
extension:
4+
- ts
5+
spec:
6+
- "test/**/*.spec.ts"

.nycrc

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
2-
"reporter": [
3-
"lcovonly"
4-
],
5-
"sourceMap": false,
6-
"instrument": false
2+
"reporter": [
3+
"lcov",
4+
"text-summary"
5+
],
6+
"include": [
7+
"src/**/*.ts"
8+
],
9+
"extension": [
10+
".ts",
11+
".tsx"
12+
]
713
}

babel.config.js

-22
This file was deleted.

package.json

+25-26
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,32 @@
1010
}
1111
],
1212
"engines": {
13-
"node": ">=6.0.0"
13+
"node": ">=12.0.0"
1414
},
1515
"devDependencies": {
16-
"@babel/cli": "^7.17.6",
17-
"@babel/core": "^7.17.9",
18-
"@babel/preset-env": "^7.16.11",
19-
"@babel/register": "^7.17.7",
2016
"@types/mocha": "^9.1.1",
21-
"@types/node": "^17.0.27",
17+
"@types/node": "^17.0.29",
18+
"@typescript-eslint/eslint-plugin": "^5.21.0",
19+
"@typescript-eslint/parser": "^5.21.0",
2220
"asn1-test-suite": "^1.0.2",
23-
"babel-plugin-istanbul": "^6.1.1",
24-
"cross-env": "^7.0.3",
21+
"eslint": "^8.14.0",
2522
"mocha": "^9.2.2",
2623
"nyc": "^15.1.0",
2724
"rollup": "^2.70.2",
28-
"rollup-plugin-node-resolve": "^5.2.0"
25+
"rollup-plugin-dts": "^4.2.1",
26+
"rollup-plugin-node-resolve": "^5.2.0",
27+
"rollup-plugin-typescript2": "^0.31.2",
28+
"ts-node": "^10.7.0",
29+
"typescript": "^4.6.3"
2930
},
3031
"repository": {
3132
"type": "git",
3233
"url": "git://github.com/PeculiarVentures/asn1.js.git"
3334
},
3435
"dependencies": {
35-
"pvutils": "^1.1.3"
36+
"pvtsutils": "^1.2.2",
37+
"pvutils": "^1.1.3",
38+
"tslib": "^2.4.0"
3639
},
3740
"description": "asn1js is a pure JavaScript library implementing this standard. ASN.1 is the basis of all X.509 related data structures and numerous other protocols used on the web",
3841
"keywords": [
@@ -51,27 +54,23 @@
5154
"universalstring",
5255
"generalizedtime"
5356
],
54-
"main": "./build/asn1.js",
55-
"jsnext:main": "./src/asn1.js",
56-
"module": "./src/asn1.js",
57-
"types": "index.d.ts",
57+
"main": "build/index.js",
58+
"module": "build/index.es.js",
59+
"types": "build/index.d.ts",
5860
"name": "asn1js",
5961
"files": [
6062
"build",
61-
"src",
6263
"LICENSE",
63-
"README.md",
64-
"index.d.ts"
64+
"README.md"
6565
],
6666
"scripts": {
67-
"build": "babel src --compact=false --out-dir build --source-maps",
68-
"watch": "babel src --compact=false --out-dir build --source-maps --watch",
69-
"ex1": "cd examples/ASN1Usage && npm run build && cd ../..",
70-
"build:examples": "npm run ex1",
71-
"build:tests": "npm run build:examples",
72-
"test": "cross-env NODE_ENV=test nyc mocha --require @babel/register",
73-
"prepublishOnly": "npm run build"
67+
"build": "rollup -c",
68+
"test": "mocha",
69+
"prepublishOnly": "npm run build",
70+
"lint": "eslint . --ext .ts",
71+
"lint:fix": "eslint --fix . --ext .ts",
72+
"coverage": "nyc npm test"
7473
},
75-
"version": "2.4.0",
74+
"version": "3.0.0",
7675
"license": "BSD-3-Clause"
77-
}
76+
}

rollup.config.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import path from "path";
2+
import fs from "fs";
3+
import typescript from "rollup-plugin-typescript2";
4+
import dts from "rollup-plugin-dts";
5+
import pkg from "./package.json";
6+
7+
const LICENSE = fs.readFileSync("LICENSE", { encoding: "utf-8" });
8+
const banner = [
9+
"/*!",
10+
...LICENSE.split("\n").map(o => ` * ${o}`),
11+
" */",
12+
"",
13+
].join("\n");
14+
const input = "src/index.ts";
15+
const external = Object.keys(pkg.dependencies || {});
16+
17+
export default [
18+
{
19+
input,
20+
plugins: [
21+
typescript({
22+
check: true,
23+
clean: true,
24+
tsconfigOverride: {
25+
compilerOptions: {
26+
module: "ES2015",
27+
removeComments: true,
28+
}
29+
}
30+
}),
31+
],
32+
external: [...external],
33+
output: [
34+
{
35+
banner,
36+
file: pkg.main,
37+
format: "cjs",
38+
},
39+
{
40+
banner,
41+
file: pkg.module,
42+
format: "es",
43+
},
44+
],
45+
},
46+
{
47+
input,
48+
external: [...external],
49+
plugins: [
50+
dts({
51+
tsconfig: path.resolve(__dirname, "./tsconfig.json")
52+
})
53+
],
54+
output: [
55+
{
56+
banner,
57+
file: pkg.types,
58+
}
59+
]
60+
},
61+
];

tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2019",
4+
"module": "CommonJS",
5+
"strict": true,
6+
"importHelpers": true,
7+
"noImplicitOverride": true,
8+
"skipLibCheck": true,
9+
"noErrorTruncation": true,
10+
"experimentalDecorators": true
11+
},
12+
"exclude": [
13+
"build/**/*.ts"
14+
]
15+
}

0 commit comments

Comments
 (0)