diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..0a2b03c3 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,35 @@ +{ + "root": true, + "env": { + "node": true, + "browser": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier", + "prettier/@typescript-eslint" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2020, + "parser": "babel-eslint", + "project": "./tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint", + "prettier" + ], + "rules": { + "no-console": 0, + "semi": 0, + "template-curly-spacing": [ + 2, + "always" + ], + "@typescript-eslint/no-explicit-any": 0 + } +} diff --git a/.travis.yml b/.travis.yml index c2e8e101..3f243cfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,19 +2,16 @@ language: node_js cache: directories: - ~/.npm -notifications: - email: false node_js: + - '12' - '10' - - '11' - '8' - - '6' script: - npm run test:prod && npm run build after_success: - - npm run travis-deploy-once "npm run report-coverage" - - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi - - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi + - npm run report-coverage + - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run deploy-docs; fi + - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run semantic-release; fi branches: except: - /^v\d+\.\d+\.\d+$/ diff --git a/package.json b/package.json index 48e6778e..a2cc7ba4 100644 --- a/package.json +++ b/package.json @@ -1,44 +1,8 @@ { - "name": "--libraryname--", - "version": "0.0.0", - "description": "", - "keywords": [], - "main": "dist/--libraryname--.umd.js", - "module": "dist/--libraryname--.es5.js", - "typings": "dist/types/--libraryname--.d.ts", - "files": [ - "dist" - ], "author": "--username-- <--usermail-->", - "repository": { - "type": "git", - "url": "" - }, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'", - "prebuild": "rimraf dist", - "build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", - "start": "rollup -c rollup.config.ts -w", - "test": "jest --coverage", - "test:watch": "jest --coverage --watch", - "test:prod": "npm run lint && npm run test -- --no-cache", - "deploy-docs": "ts-node tools/gh-pages-publish", - "report-coverage": "cat ./coverage/lcov.info | coveralls", - "commit": "git-cz", - "semantic-release": "semantic-release", - "semantic-release-prepare": "ts-node tools/semantic-release-prepare", - "precommit": "lint-staged", - "postinstall": "ts-node tools/init", - "travis-deploy-once": "travis-deploy-once" - }, - "lint-staged": { - "{src,test}/**/*.ts": [ - "prettier --write", - "git add" + "commitlint": { + "extends": [ + "@commitlint/config-conventional" ] }, "config": { @@ -46,16 +10,67 @@ "path": "node_modules/cz-conventional-changelog" } }, + "description": "", + "devDependencies": { + "@babel/core": "^7.8.4", + "@babel/plugin-proposal-class-properties": "^7.8.3", + "@babel/plugin-proposal-object-rest-spread": "^7.8.3", + "@babel/preset-env": "^7.8.4", + "@commitlint/cli": "^8.3.5", + "@commitlint/config-conventional": "^8.3.4", + "@rollup/plugin-commonjs": "^11.0.2", + "@types/babel__core": "^7.1.3", + "@types/eslint": "^6.1.8", + "@types/eslint-plugin-prettier": "^2.2.0", + "@types/jest": "^25.1.2", + "@types/lodash.camelcase": "^4.3.6", + "@types/node": "^13.7.1", + "@types/prettier": "^1.19.0", + "@types/rimraf": "^2.0.3", + "@types/rollup-plugin-json": "^3.0.2", + "@types/semantic-release": "^15.13.1", + "@types/shelljs": "^0.8.6", + "@typescript-eslint/eslint-plugin": "^2.19.2", + "@typescript-eslint/parser": "^2.19.2", + "colors": "^1.4.0", + "commitizen": "^4.0.3", + "coveralls": "^3.0.9", + "cross-env": "^7.0.0", + "cz-conventional-changelog": "^3.1.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.10.0", + "eslint-plugin-jest": "^23.7.0", + "eslint-plugin-prettier": "^3.1.2", + "husky": "^4.2.3", + "jest": "^25.1.0", + "jest-config": "^25.1.0", + "lint-staged": "^10.0.7", + "lodash.camelcase": "^4.3.0", + "prettier": "^1.19.1", + "prompt": "^1.0.0", + "replace-in-file": "^5.0.2", + "rimraf": "^3.0.2", + "rollup": "^1.31.1", + "rollup-plugin-json": "^4.0.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-sourcemaps": "^0.5.0", + "rollup-plugin-typescript2": "^0.26.0", + "semantic-release": "^17.0.3", + "shelljs": "^0.8.3", + "ts-jest": "^25.2.0", + "ts-node": "^8.6.2", + "typedoc": "^0.16.9", + "typescript": "^3.7.5" + }, + "engines": { + "node": ">=6.0.0" + }, + "files": [ + "dist" + ], "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testEnvironment": "node", - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js" + "collectCoverageFrom": [ + "src/**/*.{js,ts}" ], "coveragePathIgnorePatterns": [ "/node_modules/", @@ -69,53 +84,51 @@ "statements": 95 } }, - "collectCoverageFrom": [ - "src/*.{js,ts}" + "moduleFileExtensions": [ + "ts", + "tsx", + "js" + ], + "testEnvironment": "node", + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", + "transform": { + ".(ts|tsx)": "ts-jest" + } + }, + "keywords": [], + "license": "MIT", + "lint-staged": { + "{src,test}/**/*.ts": [ + "prettier --write", + "git add" ] }, + "main": "dist/--libraryname--.umd.js", + "module": "dist/--libraryname--.es5.js", + "name": "--libraryname--", "prettier": { "semi": false, "singleQuote": true }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ] + "repository": { + "type": "git", + "url": "" }, - "devDependencies": { - "@commitlint/cli": "^7.1.2", - "@commitlint/config-conventional": "^7.1.2", - "@types/jest": "^23.3.2", - "@types/node": "^10.11.0", - "colors": "^1.3.2", - "commitizen": "^3.0.0", - "coveralls": "^3.0.2", - "cross-env": "^5.2.0", - "cz-conventional-changelog": "^2.1.0", - "husky": "^1.0.1", - "jest": "^23.6.0", - "jest-config": "^23.6.0", - "lint-staged": "^8.0.0", - "lodash.camelcase": "^4.3.0", - "prettier": "^1.14.3", - "prompt": "^1.0.0", - "replace-in-file": "^3.4.2", - "rimraf": "^2.6.2", - "rollup": "^0.67.0", - "rollup-plugin-commonjs": "^9.1.8", - "rollup-plugin-json": "^3.1.0", - "rollup-plugin-node-resolve": "^3.4.0", - "rollup-plugin-sourcemaps": "^0.4.2", - "rollup-plugin-typescript2": "^0.18.0", - "semantic-release": "^15.9.16", - "shelljs": "^0.8.3", - "travis-deploy-once": "^5.0.9", - "ts-jest": "^23.10.2", - "ts-node": "^7.0.1", - "tslint": "^5.11.0", - "tslint-config-prettier": "^1.15.0", - "tslint-config-standard": "^8.0.1", - "typedoc": "^0.12.0", - "typescript": "^3.0.3" - } + "scripts": { + "build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", + "commit": "git-cz", + "deploy-docs": "ts-node tools/gh-pages-publish", + "lint": "eslint --ext .js,.ts {src,test}/* --fix && prettier --write \"{src,test}/**/*.{js,ts}\"", + "prebuild": "rimraf dist", + "precommit": "lint-staged", + "report-coverage": "cat ./coverage/lcov.info | coveralls", + "semantic-release": "semantic-release", + "semantic-release-prepare": "ts-node tools/semantic-release-prepare", + "start": "rollup -c rollup.config.ts -w", + "test": "jest --coverage", + "test:prod": "npm run lint && npm run test -- --no-cache", + "test:watch": "jest --coverage --watch" + }, + "typings": "dist/types/--libraryname--.d.ts", + "version": "0.0.0" } diff --git a/rollup.config.ts b/rollup.config.ts index 5b25262a..549ac0fa 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,9 +1,9 @@ +import commonjs from '@rollup/plugin-commonjs' +import camelCase from 'lodash.camelcase' +import json from 'rollup-plugin-json' import resolve from 'rollup-plugin-node-resolve' -import commonjs from 'rollup-plugin-commonjs' import sourceMaps from 'rollup-plugin-sourcemaps' -import camelCase from 'lodash.camelcase' import typescript from 'rollup-plugin-typescript2' -import json from 'rollup-plugin-json' const pkg = require('./package.json') @@ -13,12 +13,12 @@ export default { input: `src/${libraryName}.ts`, output: [ { file: pkg.main, name: camelCase(libraryName), format: 'umd', sourcemap: true }, - { file: pkg.module, format: 'es', sourcemap: true }, + { file: pkg.module, format: 'es', sourcemap: true } ], // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash') external: [], watch: { - include: 'src/**', + include: 'src/**' }, plugins: [ // Allow json resolution @@ -33,6 +33,6 @@ export default { resolve(), // Resolve source maps to the original source - sourceMaps(), - ], + sourceMaps() + ] } diff --git a/tsconfig.json b/tsconfig.json index 215a7f1a..debb3168 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,28 @@ { "compilerOptions": { - "moduleResolution": "node", - "target": "es5", - "module":"es2015", - "lib": ["es2015", "es2016", "es2017", "dom"], - "strict": true, - "sourceMap": true, - "declaration": true, "allowSyntheticDefaultImports": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true, + "declaration": true, "declarationDir": "dist/types", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "lib": [ + "es2015", + "es2016", + "es2017", + "dom" + ], + "module": "es2015", + "moduleResolution": "node", "outDir": "dist/lib", + "sourceMap": true, + "strict": true, + "target": "es5", "typeRoots": [ "node_modules/@types" ] }, "include": [ - "src" + "src", + "test" ] } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 398a4167..00000000 --- a/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": [ - "tslint-config-standard", - "tslint-config-prettier" - ] -} \ No newline at end of file