Skip to content

Commit

Permalink
migrate to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaplus1 committed Aug 21, 2020
1 parent 55fd72e commit bdd758a
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 2,397 deletions.
130 changes: 0 additions & 130 deletions .babelrc.js

This file was deleted.

40 changes: 37 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,54 @@ module.exports = {
es6: true,
node: true
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:prettier/recommended'
],
globals: {
globalThis: true
},
overrides: [
{
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier/@typescript-eslint'
],
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'node/no-unsupported-features/es-syntax': 'off'
},
settings: {
node: {
tryExtensions: ['.ts', '.js', '.json', '.json']
}
}
},
{
env: {
mocha: true
},
files: ['test/**/*.mjs']
files: ['test/**/*.ts'],
rules: {
'node/no-unsupported-features/es-builtins': 'off'
}
},
{
files: ['rollup.config.js'],
rules: {
'node/no-unsupported-features/es-syntax': 'off'
}
}
],
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: 'module'
},
root: true
Expand Down
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'*.+(js|mjs)': 'npx eslint --cache --ext .js,.mjs',
'*.+(js|ts)': 'npx eslint --cache --ext .js,.ts',
'*.yml': [
'npx prettier --parser yaml --write',
'git diff --exit-code --quiet'
Expand Down
3 changes: 2 additions & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
require: '@babel/register'
extension: 'ts',
require: 'espower-typescript/guess'
};
1 change: 0 additions & 1 deletion .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
":preserveSemverRanges",
":assignee(sasaplus1)",
":timezone(Asia/Tokyo)",
"group:babelMonorepo",
"group:definitelyTyped",
"group:jsUnitTest",
"group:linters",
Expand Down
49 changes: 16 additions & 33 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');

const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const { default: nodeResolve } = require('@rollup/plugin-node-resolve');
const typescript = require('rollup-plugin-typescript');

const meta = require('./package.json');

Expand Down Expand Up @@ -34,49 +34,32 @@ module.exports = function (config) {
},
files: [
{
pattern: 'test/**/*.mjs',
pattern: 'test/**/*.ts',
type: 'js',
watched: true
}
],
frameworks: ['mocha', 'power-assert'],
mime: {
'text/x-typescript': ['ts', 'tsx']
},
preprocessors: {
'test/**/*.mjs': ['rollup', 'espower']
'+(src|test)/**/*.ts': ['rollup', 'espower']
},
reporters: ['dots'],
rollupPreprocessor: {
plugins: [
nodeResolve({
browser: true,
extensions: ['.mjs', '.js'],
main: true,
module: true
nodeResolve(),
typescript({
inlineSourceMap: true,
newLine: 'lf',
strict: true,
target: 'ES5'
}),
commonjs(),
babel({
babelrc: false,
compact: false,
// NOTE: fix circular dependencies in core-js
// https://github.com/rollup/rollup-plugin-commonjs/issues/284#issuecomment-361085666
ignore: ['node_modules/core-js/**/*.js'],
minified: false,
presets: [
[
'@babel/preset-env',
{
debug: true,
modules: false,
targets: {
browsers: ['IE >= 11', 'Android >= 4.4.4']
},
useBuiltIns: 'usage'
}
]
]
})
commonjs()
],
output: {
format: 'umd',
format: 'iife',
name: meta.name,
sourcemap: 'inline'
}
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
"type-detect": "^4.0.8"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/preset-env": "^7.11.0",
"@babel/register": "^7.10.5",
"babel-plugin-transform-rename-import": "^2.3.0",
"babel-preset-power-assert": "^3.0.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@types/mocha": "^8.0.1",
"@types/node": "^13.13.2",
"@types/type-detect": "^4.0.1",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"benchmark": "^2.1.4",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"espower-typescript": "^9.0.2",
"husky": "^4.2.5",
"karma": "^5.1.1",
"karma-chrome-launcher": "^3.1.0",
Expand All @@ -36,10 +38,9 @@
"power-assert": "^1.6.1",
"prettier": "^2.0.5",
"rollup": "^2.26.2",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.0"
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript": "^1.0.1",
"typescript": "^3.8.3"
},
"engines": {
"node": ">=12"
Expand All @@ -61,15 +62,14 @@
"scripts": {
"benchmark": "./benchmark/benchmark.js",
"build": "run-p -l build:*",
"build:cjs": "BABEL_ENV=cjs babel ./src -d ./cjs -s",
"build:umd": "BABEL_ENV=umd rollup -c",
"fix": "eslint --ext .js,.mjs --fix .",
"build:cjs": "tsc",
"build:esm": "rollup -c --environment build:esm",
"build:umd": "rollup -c --environment build:umd",
"check-types": "tsc --noEmit",
"fix": "eslint --fix --ext .js,.ts .",
"fixpack": "npx fixpack",
"lint": "eslint --cache --ext .js,.mjs .",
"mocha": "run-s mocha:*",
"mocha:cjs": "BABEL_ENV=mocha:cjs mocha --experimental-modules './test/**/*.mjs'",
"mocha:mjs": "BABEL_ENV=mocha:mjs mocha --experimental-modules './test/**/*.mjs'",
"premocha:cjs": "run-s build:cjs",
"lint": "eslint --cache --ext .js,.ts .",
"mocha": "mocha",
"test": "run-s mocha"
},
"sideEffects": false,
Expand Down
Loading

0 comments on commit bdd758a

Please sign in to comment.