Skip to content

Commit 1fc88b8

Browse files
author
roman.vasilev
committed
feat: First release
1 parent bbf8f49 commit 1fc88b8

16 files changed

+433
-1
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[*.json]
16+
indent_size = 2

.eslintrc.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module.exports = {
2+
"root": true,
3+
"env": {
4+
"node": true,
5+
"jest": true,
6+
"jest/globals": true,
7+
},
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": 2019,
11+
"sourceType": "module",
12+
"ecmaFeatures": {
13+
"jsx": false,
14+
},
15+
"project": "tsconfig.json",
16+
},
17+
"plugins": [
18+
"wix-editor",
19+
"unicorn",
20+
"import",
21+
"jest",
22+
"@typescript-eslint/tslint",
23+
"only-warn",
24+
],
25+
"extends": [
26+
"eslint:recommended",
27+
"plugin:unicorn/recommended",
28+
"plugin:import/errors",
29+
"plugin:import/warnings",
30+
"plugin:import/typescript",
31+
"plugin:jest/recommended",
32+
],
33+
"rules": {
34+
"quotes": [1, "single", { "allowTemplateLiterals": true }],
35+
"semi": [1, "always"],
36+
// wix-editor
37+
"wix-editor/augmented-assignment": 1,
38+
"wix-editor/no-instanceof-array": 1,
39+
"wix-editor/no-not-not": 1,
40+
"wix-editor/no-unneeded-match": 1,
41+
"wix-editor/prefer-filter": 1,
42+
"wix-editor/prefer-ternary": 1,
43+
"wix-editor/return-boolean": 1,
44+
"wix-editor/simplify-boolean-expression": 1,
45+
// unicorn
46+
"unicorn/import-index": 0,
47+
"unicorn/catch-error-name": 0,
48+
// import
49+
"import/newline-after-import": 0,
50+
"import/no-duplicates": 1,
51+
"import/max-dependencies": [1, { "max": 10 }],
52+
// tslint
53+
"@typescript-eslint/tslint/config": [1, {
54+
lintFile: "./tslint.json",
55+
}],
56+
}
57+
};

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
dist/
2+
### https://raw.github.com/github/gitignore/5d896f6791c4257b74696714c66b2530b8d95a51/Node.gitignore
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
# Runtime data
10+
pids
11+
*.pid
12+
*.seed
13+
*.pid.lock
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
# nyc test coverage
19+
.nyc_output
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
# Bower dependency directory (https://bower.io/)
23+
bower_components
24+
# node-waf configuration
25+
.lock-wscript
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
# Dependency directories
29+
node_modules/
30+
jspm_packages/
31+
# Typescript v1 declaration files
32+
typings/
33+
# Optional npm cache directory
34+
.npm
35+
# Optional eslint cache
36+
.eslintcache
37+
# Optional REPL history
38+
.node_repl_history
39+
# Output of 'npm pack'
40+
*.tgz
41+
# Yarn Integrity file
42+
.yarn-integrity
43+
# dotenv environment variables file
44+
.env
45+
# Custom
46+
~*
47+
.idea
48+
.awcache
49+
.vscode
50+
.rts2_cache_*

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock = false

.releaserc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/changelog",
6+
[
7+
"@semantic-release/npm",
8+
{
9+
"pkgRoot": "dist"
10+
}
11+
],
12+
"@semantic-release/github",
13+
"@semantic-release/git",
14+
]
15+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# typescript-transform-x
1+
# typescript-transform-unspec
22
Typescript transform plugin
33

44
## Resources

Taskfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
PATH="$PWD/node_modules/.bin":$PATH
3+
4+
build() {
5+
rm -rf dist
6+
cp -rf src dist && /usr/bin/find dist -name '*.spec.ts' | xargs rm -f
7+
cat tsconfig.json | jq 'del(.include, .compilerOptions.outDir)' > dist/tsconfig.json
8+
pushd dist
9+
tsc -p .
10+
rm tsconfig.json
11+
popd
12+
cp README.md LICENSE package.json dist
13+
}
14+
15+
"$@"

jest.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
transform: {
4+
'^.+\\.tsx?$': 'ts-jest'
5+
},
6+
collectCoverage: false,
7+
coverageDirectory: 'coverage',
8+
coverageReporters: [
9+
// 'lcov',
10+
'text',
11+
],
12+
collectCoverageFrom: [
13+
'src/**/*.ts',
14+
'!src/**/*.spec.ts',
15+
],
16+
testMatch: [
17+
'<rootDir>/src/**/*.spec.ts'
18+
],
19+
moduleFileExtensions: [
20+
'ts',
21+
'tsx',
22+
'js',
23+
'jsx',
24+
'json',
25+
],
26+
globals: {
27+
'ts-jest': {
28+
diagnostics: false,
29+
isolatedModules: true,
30+
tsConfig: {
31+
target: 'esnext',
32+
}
33+
},
34+
},
35+
};

package.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"name": "typescript-transform-unspec",
3+
"version": "0.0.0-dev",
4+
"license": "MIT",
5+
"description": "Typescript transform plugin",
6+
"main": "index.js",
7+
"typings": "index.d.ts",
8+
"author": "2019",
9+
"keywords": [],
10+
"engines": {
11+
"node": ">=8"
12+
},
13+
"repository": {
14+
"type": "git"
15+
},
16+
"scripts": {
17+
"test": "npm run eslint && npm run tscheck && npm run test:cov && npm run typecov",
18+
"test:r": "jest --runInBand --verbose",
19+
"test:w": "jest --runInBand --watch",
20+
"test:cov": "npm run test:r -- --collectCoverage",
21+
"test:d": "node --inspect-brk node_modules/jest/bin/jest.js --runInBand --testMatch \"<rootDir>/src/**/*.spec.ts\"",
22+
"typecov": "type-coverage --detail",
23+
"tscheck": "echo tscheck... && tsc --noEmit",
24+
"tscheck:w": "npm run tscheck -- --watch",
25+
"tsclint": "tsc --noEmit --strict --forceConsistentCasingInFileNames --noImplicitReturns --noImplicitThis --noUnusedLocals --noUnusedParameters",
26+
"tsclint:w": "npm run tsclint -- --watch",
27+
"eslint:w": "watchexec -w src \"npm run eslint\"",
28+
"eslint": "eslint src --ext ts",
29+
"eslint:fix": "eslint src --ext ts --fix",
30+
"tslint:fix": "tslint -p tsconfig.json --fix",
31+
"lint:w": "run-p tsclint:w eslint:w",
32+
"semantic-release": "semantic-release",
33+
"prepublishOnly": "sed -i -e 's/devDependencies/_devDependencies/g' package.json",
34+
"copySource": "cp -rv src dist && find dist/src -name '*.spec.ts' | xargs rm -f",
35+
"build": "sh Taskfile build",
36+
"remark": "sh Taskfile remark_run",
37+
"remark:update": "sh Taskfile remark_run --output",
38+
"setupfrontend": "npm i -D ng-packagr @angular/core @angular/compiler-cli @angular/compiler tsickle",
39+
"setupwebpack": "npm i -D webpack webpack-cli webpack-dev-server html-webpack-plugin source-map-loader ts-loader html-loader swc-loader @swc/core",
40+
"commit": "git-cz"
41+
},
42+
"devDependencies": {
43+
"@semantic-release/changelog": "^3.0.2",
44+
"@semantic-release/commit-analyzer": "^7.0.0-beta.2",
45+
"@semantic-release/git": "^7.1.0-beta.3",
46+
"@semantic-release/github": "^5.4.0-beta.1",
47+
"@semantic-release/npm": "^5.2.0-beta.6",
48+
"@semantic-release/release-notes-generator": "^7.1.7",
49+
"@types/node": "^12.0.2",
50+
"@types/jest": "^24.0.13",
51+
"@typescript-eslint/eslint-plugin-tslint": "^1.9.0",
52+
"@typescript-eslint/parser": "^1.9.0",
53+
"eslint": "^5.16.0",
54+
"eslint-import-resolver-node": "^0.3.2",
55+
"eslint-plugin-import": "^2.17.3",
56+
"eslint-plugin-jest": "^22.6.4",
57+
"eslint-plugin-only-warn": "^1.0.1",
58+
"eslint-plugin-unicorn": "^8.0.2",
59+
"eslint-plugin-wix-editor": "^2.0.0",
60+
"jest": "^24.8.0",
61+
"npm-run-all": "^4.1.5",
62+
"remark": "^10.0.1",
63+
"remark-cli": "^6.0.1",
64+
"remark-license": "^5.0.1",
65+
"remark-toc": "^5.1.1",
66+
"semantic-release": "^16.0.0-beta.19",
67+
"simplytyped": "^3.1.0",
68+
"ts-jest": "^24.0.2",
69+
"tslint": "^5.16.0",
70+
"tslint-clean-code": "^0.2.9",
71+
"tslint-microsoft-contrib": "^6.2.0",
72+
"tslint-sonarts": "^1.9.0",
73+
"type-coverage": "^2.0.2",
74+
"typescript": "~3.4.5",
75+
"watchexec-bin": "^1.0.0"
76+
},
77+
"config": {
78+
"commitizen": {
79+
"path": "cz-conventional-changelog"
80+
}
81+
}
82+
}

src/gen-transpiled.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const ts = require('ttypescript')
2+
const fs = require('fs')
3+
const path = require('path')
4+
5+
const res = ts.transpileModule(
6+
fs.readFileSync(path.join(__dirname, 'test.ts')).toString(),
7+
require('./tsconfig.json')
8+
)
9+
10+
console.log(res.outputText)

src/test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const a = { b: 1 };
2+
declare function safely(a: any): void;
3+
4+
function abc() {
5+
const c = safely(a.b);
6+
}
7+
console.log(abc.toString());

src/transformers/transformer.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as ts from 'typescript';
2+
3+
export interface MyPluginOptions {
4+
some?: string
5+
}
6+
7+
export default function myTransformerPlugin(program: ts.Program, opts: MyPluginOptions) {
8+
return {
9+
before(ctx: ts.TransformationContext) {
10+
return (sourceFile: ts.SourceFile) => {
11+
function visitor(node: ts.Node): ts.Node {
12+
if (ts.isCallExpression(node) && node.expression.getText() === 'safely') {
13+
const target = node.arguments[0]
14+
if (ts.isPropertyAccessExpression(target)) {
15+
return ts.createBinary(
16+
target.expression,
17+
ts.SyntaxKind.AmpersandAmpersandToken,
18+
target
19+
)
20+
}
21+
}
22+
return ts.visitEachChild(node, visitor, ctx)
23+
}
24+
return ts.visitEachChild(sourceFile, visitor, ctx)
25+
}
26+
}
27+
}
28+
}

src/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"declaration": true,
5+
"module": "commonjs",
6+
"strict": true,
7+
"outDir": "../dist",
8+
"plugins": [
9+
{
10+
"transform": "./transformers/transformer.ts"
11+
}
12+
]
13+
},
14+
"exclude": ["transformers/**/*"]
15+
}

tsconfig.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2017",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"importHelpers": true,
7+
"strict": true,
8+
"noImplicitAny": false,
9+
"experimentalDecorators": false,
10+
"emitDecoratorMetadata": false,
11+
"outDir": "dist",
12+
"pretty": true,
13+
"removeComments": false,
14+
"sourceMap": true,
15+
"declaration": true,
16+
"declarationMap": true,
17+
"skipLibCheck": true,
18+
"lib": [
19+
"esnext"
20+
]
21+
},
22+
"include": [
23+
"src/**/*.ts"
24+
],
25+
"exclude": [
26+
"src/**/*.spec.ts"
27+
]
28+
}

0 commit comments

Comments
 (0)