Skip to content

Commit

Permalink
feat: Convert JS to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
microshine committed Feb 22, 2022
1 parent 6977b0c commit 32f52f4
Show file tree
Hide file tree
Showing 19 changed files with 3,453 additions and 888 deletions.
20 changes: 0 additions & 20 deletions .babelrc

This file was deleted.

43 changes: 0 additions & 43 deletions .eslintrc.js

This file was deleted.

45 changes: 45 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"ignorePatterns": [
"build/**/*",
"rollup.config.js"
],
"rules": {
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/explicit-function-return-type": 1,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"newline-before-return": 1,
"semi": "off",
"@typescript-eslint/semi": [
"error"
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal"
],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
build
.nyc_output
coverage
*.log
.DS_Store
5 changes: 5 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require: "ts-node/register"
extension:
- "ts"
spec:
- "test/**/*.ts"
9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

16 changes: 11 additions & 5 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"reporter": [
"lcovonly"
],
"sourceMap": false,
"instrument": false
"reporter": [
"lcov",
"text-summary"
],
"include": [
"src/**/*.ts"
],
"extension": [
".ts",
".tsx"
]
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker"
]
}
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Tests",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--no-timeouts",
"--colors"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"files.trimTrailingWhitespace": true,
"typescript.format.semicolons": "insert",
"typescript.preferences.quoteStyle": "double",
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true,
"**/build": true,
},
"typescript.tsdk": "node_modules/typescript/lib",
}
20 changes: 0 additions & 20 deletions circle.yml

This file was deleted.

45 changes: 31 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"email": "rmh@unmitigatedrisk.com",
"name": "Ryan Hurst"
},
{
"email": "microshine@mail.ru",
"name": "Miroshin Stepan"
}
],
"repository": {
Expand All @@ -18,23 +22,36 @@
"node": ">=6.0.0"
},
"scripts": {
"prepublishOnly": "npm run build",
"build": "babel src --compact=false --out-dir build --source-maps",
"watch": "babel src --compact=false --out-dir build --source-maps --watch",
"test": "cross-env NODE_ENV=test nyc mocha --require babel-register --require babel-polyfill"
"prepare": "npm run build",
"test": "mocha",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint --fix . --ext .ts",
"build": "rollup -c",
"coverage": "nyc npm test",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"jsnext:main": "./src/utils.js",
"module": "./src/utils.js",
"files": [
"build",
"README.md",
"LICENSE"
],
"module": "./build/utils.es.js",
"main": "./build/utils.js",
"types": "./build/index.d.ts",
"devDependencies": {
"babel-cli": "latest",
"mocha": "^3.0.2",
"nyc": "^11.6.0",
"cross-env": "^5.1.4",
"babel-plugin-istanbul": "^4.1.5",
"babel-preset-env": "latest",
"babel-polyfill": "^6.26.0",
"eslint": "^4.19.1"
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.19",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"eslint": "^8.9.0",
"eslint-plugin-import": "^2.25.4",
"mocha": "^9.2.1",
"nyc": "^15.1.0",
"rollup": "2.68.0",
"rollup-plugin-dts": "^4.1.0",
"rollup-plugin-typescript2": "^0.31.2",
"ts-node": "^10.5.0",
"typescript": "^4.5.5"
},
"name": "pvutils",
"version": "1.0.17",
Expand Down
59 changes: 59 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import path from "path";
import typescript from "rollup-plugin-typescript2";
import dts from "rollup-plugin-dts";
import pkg from "./package.json";

const banner = [
"/*!",
" Copyright (c) Peculiar Ventures, LLC",
"*/",
"",
].join("\n");
const input = "src/index.ts";
const external = Object.keys(pkg.dependencies || {});

export default [
{
input,
plugins: [
typescript({
check: true,
clean: true,
tsconfigOverride: {
compilerOptions: {
module: "ES2015",
removeComments: true,
}
}
}),
],
external: [...external],
output: [
{
banner,
file: pkg.main,
format: "cjs",
},
{
banner,
file: pkg.module,
format: "es",
},
],
},
{
input,
external: [...external],
plugins: [
dts({
tsconfig: path.resolve(__dirname, "./tsconfig.json")
})
],
output: [
{
banner,
file: pkg.types,
}
]
},
];
Loading

0 comments on commit 32f52f4

Please sign in to comment.