No-op template

This commit is contained in:
aet
2021-07-21 21:26:22 -04:00
commit 2c504997af
7 changed files with 1462 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
mochawesome-report

7
.mocharc.json Normal file
View 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
View 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

File diff suppressed because it is too large Load Diff

6
src/index.ts Normal file
View 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
View 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
View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"strict": true,
"noEmit": true
}
}