No-op template
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
mochawesome-report
|
7
.mocharc.json
Normal file
7
.mocharc.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/mocharc",
|
||||||
|
"reporter": "mochawesome",
|
||||||
|
"extension": [".ts"],
|
||||||
|
"require": ["ts-node/register"],
|
||||||
|
"timeout": 10000
|
||||||
|
}
|
24
package.json
Normal file
24
package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "babel-decorators",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha test/**/*.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.14.8",
|
||||||
|
"@babel/types": "^7.14.8",
|
||||||
|
"@types/babel__core": "^7.1.15",
|
||||||
|
"@types/chai": "^4.2.21",
|
||||||
|
"@types/mocha": "github:whitecolor/mocha-types#da22474cf43f48a56c86f8c23a5a0ea36e295768",
|
||||||
|
"@types/node": "^16.4.0",
|
||||||
|
"@types/prettier": "^2.3.2",
|
||||||
|
"chai": "^4.3.4",
|
||||||
|
"mocha": "^9.0.2",
|
||||||
|
"mochawesome": "^6.2.2",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
|
"ts-node": "^10.1.0",
|
||||||
|
"typescript": "^4.3.5"
|
||||||
|
}
|
||||||
|
}
|
1383
pnpm-lock.yaml
generated
Normal file
1383
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
src/index.ts
Normal file
6
src/index.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import type * as babel from "@babel/core";
|
||||||
|
|
||||||
|
export default ({ types: t }: typeof babel): babel.PluginObj => ({
|
||||||
|
name: "tsc-dedent",
|
||||||
|
visitor: {},
|
||||||
|
});
|
34
test/index.ts
Normal file
34
test/index.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { describe, it } from "mocha";
|
||||||
|
import { expect } from "chai";
|
||||||
|
import { transform } from "@babel/core";
|
||||||
|
import { format } from "prettier";
|
||||||
|
import plugin from "../src/index";
|
||||||
|
|
||||||
|
const javascript = (code: TemplateStringsArray) =>
|
||||||
|
transform(code[0], {
|
||||||
|
parserOpts: {
|
||||||
|
plugins: ["decorators-legacy", "typescript"],
|
||||||
|
},
|
||||||
|
plugins: [plugin],
|
||||||
|
})!.code!;
|
||||||
|
|
||||||
|
const canonize = (code: string) => format(code, { parser: "babel" }).trim();
|
||||||
|
|
||||||
|
const equal = (actual: string, expected: string) => {
|
||||||
|
actual = canonize(actual);
|
||||||
|
expected = canonize(expected);
|
||||||
|
expect(actual).to.deep.equal(expected);
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("", () => {
|
||||||
|
it("should do nothing", () => {
|
||||||
|
equal(
|
||||||
|
javascript`
|
||||||
|
class A {}
|
||||||
|
`,
|
||||||
|
/* javascript */ `
|
||||||
|
class A {}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
6
tsconfig.json
Normal file
6
tsconfig.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user