From ea93f60beb06064a9ad41f7896de2816e5de8028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ya=C3=ABl=20Guilloux?= Date: Wed, 13 Sep 2023 17:11:22 +0200 Subject: [PATCH 1/3] test(lang-ts): add initial tests & fixtures --- test/fixtures/lang-ts.vue | 22 ++++++++++++++++++++++ test/index.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/fixtures/lang-ts.vue diff --git a/test/fixtures/lang-ts.vue b/test/fixtures/lang-ts.vue new file mode 100644 index 00000000..bfc16bc1 --- /dev/null +++ b/test/fixtures/lang-ts.vue @@ -0,0 +1,22 @@ + + + + + + + + const testi18n = { + en: 'hello World', + de: 'Hallo Welt' +} + diff --git a/test/index.js b/test/index.js index 8f8c9a19..64c97729 100644 --- a/test/index.js +++ b/test/index.js @@ -539,6 +539,36 @@ describe("Basic tests", () => { }) }) + describe("About fixtures/lang-ts", () => { + it.only('Should parse lang="ts" blocks as script blocks', () => { + const ast = parse( + [ + "", + '', + '', + 'const testCustom = {}', + ].join("\n"), + ) + const body = ast + }) + it.only('Should treat lang="ts" blocks as script tags', async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + env: { browser: true, node: true }, + parser: PARSER_PATH, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + sourceType: "module", + ecmaVersion: 2017, + }, + }, + useEslintrc: false, + }) + const report = await cli.lintFiles(["lang-ts.vue"]) + }) + }) + describe("About unexpected-null-character errors", () => { it("should keep NULL in DATA state.", () => { const ast = parse("") From 99a550de6a799624ac0d7800ea2161b23b54c47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ya=C3=ABl=20Guilloux?= Date: Wed, 13 Sep 2023 17:11:39 +0200 Subject: [PATCH 2/3] feat(lang-ts): try supporting all lang="ts" blocks as scripts elements --- src/common/ast-utils.ts | 11 +++++++++-- src/index.ts | 4 ++-- src/script-setup/index.ts | 36 +++++++++++++++++++++--------------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/common/ast-utils.ts b/src/common/ast-utils.ts index e87b8365..2ea8da72 100644 --- a/src/common/ast-utils.ts +++ b/src/common/ast-utils.ts @@ -14,7 +14,10 @@ import type { * @returns `true` if the node is a `