diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index aad0697ce3..8a99571bf0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -55,6 +55,9 @@ Semantic Versioning. [E0034][] ("redeclaration of variable"). * `(a?, ...b) => ReturnType` in a TypeScript type no longer falsely reports [E0379][] ("optional parameter cannot be followed by a required parameter"). + * LSP: A file named `a.tsxbanana.ts` is no longer recognized as a + TypeScript JSX file. It is now recognized as a non-JSX TypeScript + file. * Nested `module` declarations no longer falsely report [E0361][]. E0361's message has been changed: * Before: "module with string name is only allowed at the top level" diff --git a/src/quick-lint-js/util/classify-path.cpp b/src/quick-lint-js/util/classify-path.cpp index 44549757ce..1842620bce 100644 --- a/src/quick-lint-js/util/classify-path.cpp +++ b/src/quick-lint-js/util/classify-path.cpp @@ -2,6 +2,7 @@ // See end of file for extended copyright information. #include +#include #include #include #include @@ -12,7 +13,7 @@ Path_Classification classify_uri(String8_View uri) { String8_View base_name = uri_base_name(uri); return Path_Classification{ .typescript_definition = base_name.find(u8".d."_sv) != base_name.npos, - .typescript_jsx = base_name.find(u8".tsx"_sv) != base_name.npos, + .typescript_jsx = ends_with(base_name, u8".tsx"_sv), }; } } diff --git a/test/test-lsp-language.cpp b/test/test-lsp-language.cpp index d80fcf0429..ce02f0dbea 100644 --- a/test/test-lsp-language.cpp +++ b/test/test-lsp-language.cpp @@ -107,6 +107,14 @@ TEST(Test_LSP_Language, typescript_file_without_d_or_tsx_is_source) { << ".d. in containing directory should be ignored"; } + { + const LSP_Language* language = + LSP_Language::find("typescript"sv, u8"file:///folder/test.tsx.ts"_sv); + ASSERT_NE(language, nullptr); + EXPECT_FALSE(language->lint_options.jsx) + << ".tsx in file name but not in extension should be ignored"; + } + // TODO(strager): Query parameters should be ignored. // TODO(strager): Fragments should be ignored. }