Skip to content

Commit ea93f60

Browse files
committed
test(lang-ts): add initial tests & fixtures
1 parent 6aa8585 commit ea93f60

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test/fixtures/lang-ts.vue

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<div>
3+
</div>
4+
</template>
5+
6+
<script setup lang="ts">
7+
let test = 'hello-world'
8+
</script>
9+
10+
<style lang="ts">
11+
const testStyle = {
12+
backgroundColor: 'red',
13+
color: 'blue'
14+
}
15+
</style>
16+
17+
<custom lang="ts">
18+
const testi18n = {
19+
en: 'hello World',
20+
de: 'Hallo Welt'
21+
}
22+
</custom>

test/index.js

+30
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,36 @@ describe("Basic tests", () => {
539539
})
540540
})
541541

542+
describe("About fixtures/lang-ts", () => {
543+
it.only('Should parse lang="ts" blocks as script blocks', () => {
544+
const ast = parse(
545+
[
546+
"<template><div></div></template>",
547+
'<script lang="ts">const test = "test"</script>',
548+
'<style lang="ts">const testStyle = {}</style>',
549+
'<custom lang="ts">const testCustom = {}</custom>',
550+
].join("\n"),
551+
)
552+
const body = ast
553+
})
554+
it.only('Should treat lang="ts" blocks as script tags', async () => {
555+
const cli = new ESLint({
556+
cwd: FIXTURE_DIR,
557+
overrideConfig: {
558+
env: { browser: true, node: true },
559+
parser: PARSER_PATH,
560+
parserOptions: {
561+
...BABEL_PARSER_OPTIONS,
562+
sourceType: "module",
563+
ecmaVersion: 2017,
564+
},
565+
},
566+
useEslintrc: false,
567+
})
568+
const report = await cli.lintFiles(["lang-ts.vue"])
569+
})
570+
})
571+
542572
describe("About unexpected-null-character errors", () => {
543573
it("should keep NULL in DATA state.", () => {
544574
const ast = parse("<template>\u0000</template>")

0 commit comments

Comments
 (0)