diff --git a/docs/cli.adoc b/docs/cli.adoc index 4d90897d58..7d77dffcd9 100644 --- a/docs/cli.adoc +++ b/docs/cli.adoc @@ -172,25 +172,15 @@ Added in quick-lint-js version 0.3.0. * *default* (default): infer the _languageid_ from the file's extension: ** *.js*: *javascript-jsx* ** *.jsx*: *javascript-jsx* -** (anything else): *javascript-jsx* -* *experimental-default*: infer the _languageid_ from the file's extension (EXPERIMENTAL; subject to change in future versions of quick-lint-js): -** *.js*: *javascript-jsx* -** *.jsx*: *javascript-jsx* -** *.d.ts*: *experimental-typescript-definition* -** *.ts*: *experimental-typescript* -** *.tsx*: *experimental-typescript-jsx* +** *.d.ts*: *typescript-definition* +** *.ts*: *typescript* +** *.tsx*: *typescript-jsx* ** (anything else): *javascript-jsx* * *javascript*: the latest ECMAScript standard with proposed features. * *javascript-jsx*: like *javascript* but with JSX (React) extensions. -* *experimental-typescript*: the latest TypeScript version. -(EXPERIMENTAL. -Subject to change in future versions of quick-lint-js.) -* *experimental-typescript-definition*: the latest TypeScript version (.d.ts file). -(EXPERIMENTAL. -Subject to change in future versions of quick-lint-js.) -* *experimental-typescript-jsx*: like *experimental-typescript* but with JSX (React) extensions. -(EXPERIMENTAL. -Subject to change in future versions of quick-lint-js.) +* *typescript*: the latest TypeScript version. +* *typescript-definition*: the latest TypeScript version (.d.ts file). +* *typescript-jsx*: like *typescript* but with JSX (React) extensions. If *--language* is given twice, then the _languageid_ for the first *--language* option applies only to the input files between the two *--language* options, and the _languageid_ for the second *--language* option apples only to the input files after the second *--language* option. See the <> section for an example. diff --git a/docs/lsp.adoc b/docs/lsp.adoc index 27ece7efcb..1309274080 100644 --- a/docs/lsp.adoc +++ b/docs/lsp.adoc @@ -88,19 +88,19 @@ command-line option |`javascript-jsx` |`tsx` -|`experimental-typescript-jsx` +|`typescript-jsx` |`typescript` |See below |`typescriptsource` -|`experimental-typescript` +|`typescript` |`typescriptdefinition` -|`experimental-typescript-definition` +|`typescript-definition` |`typescriptreact` -|`experimental-typescript-jsx` +|`typescript-jsx` |(any) |See below diff --git a/plugin/vim/quick-lint-js.vim/ale_linters/typescript/quick_lint_js.vim b/plugin/vim/quick-lint-js.vim/ale_linters/typescript/quick_lint_js.vim index 229cc06f53..a6540c0f4c 100644 --- a/plugin/vim/quick-lint-js.vim/ale_linters/typescript/quick_lint_js.vim +++ b/plugin/vim/quick-lint-js.vim/ale_linters/typescript/quick_lint_js.vim @@ -5,10 +5,7 @@ " https://github.com/dense-analysis/ale call quick_lint_js_ale#init_variables() - -if g:ale_javascript_quick_lint_js_experimental_typescript - call quick_lint_js_ale#define_linter('typescript') -endif +call quick_lint_js_ale#define_linter('typescript') " quick-lint-js finds bugs in JavaScript programs. " Copyright (C) 2020 Matthew "strager" Glazar diff --git a/plugin/vim/quick-lint-js.vim/autoload/quick_lint_js_ale.vim b/plugin/vim/quick-lint-js.vim/autoload/quick_lint_js_ale.vim index d7e7fb09a1..a242ff76e2 100644 --- a/plugin/vim/quick-lint-js.vim/autoload/quick_lint_js_ale.vim +++ b/plugin/vim/quick-lint-js.vim/autoload/quick_lint_js_ale.vim @@ -9,8 +9,6 @@ function! quick_lint_js_ale#init_variables() abort call ale#Set('javascript_quick_lint_js_use_global', get(g:, 'ale_use_global_executables', v:true)) call ale#Set('javascript_quick_lint_js_tracing_directory', '') - - call ale#Set('javascript_quick_lint_js_experimental_typescript', v:false) endfunction function! quick_lint_js_ale#define_linter(filetype) abort diff --git a/plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt b/plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt index 2936159149..435732a76b 100644 --- a/plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt +++ b/plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt @@ -81,9 +81,8 @@ If you enable |g:ale_linters_explicit|, add the following code to let b:ale_linters = ['quick-lint-js'] -To lint TypeScript as well, enable -|g:ale_javascript_quick_lint_js_experimental_typescript| and also add the -following code to `~/.vim/ftplugin/typescript.vim` (UNIX) or +To lint TypeScript as well, also add the following code to +`~/.vim/ftplugin/typescript.vim` (UNIX) or `~/vimfiles/ftplugin/typescript.vim` (Windows): let b:ale_linters = ['quick-lint-js'] @@ -138,12 +137,9 @@ files. g:ale_javascript_quick_lint_js_experimental_typescript *g:ale_javascript_quick_lint_js_experimental_typescript* *b:ale_javascript_quick_lint_js_experimental_typescript* - Type: |Boolean| - Default: `v:false` -Set this variable to `v:true` to lint TypeScript and TypeScript JSX files, not -just JavaScript and JSX files. (EXPERIMENTAL. Subject to change in future -versions of quick-lint-js.) (Introduced in quick-lint-js version 2.11.0.) +This variable is unused. It was removed in quick-lint-js version +3.0.0. ============================================================================== 3.2. Configuring for coc.nvim *quick-lint-js-configure-coc-nvim* @@ -182,13 +178,9 @@ snippet into your |coc-configuration| then tweaking it according to g:coc_quick_lint_js_experimental_typescript *g:coc_quick_lint_js_experimental_typescript* *b:coc_quick_lint_js_experimental_typescript* - Type: |Boolean| - Default: `v:false` -Set this variable to `v:true` to lint TypeScript and TypeScript JSX files, not -just JavaScript and JSX files. Must be set before loading the quick-lint-js -Vim plugin. (EXPERIMENTAL. Subject to change in future versions of -quick-lint-js.) (Introduced in quick-lint-js version 2.11.0.) +This variable is unused. It was removed in quick-lint-js version +3.0.0. ============================================================================== 3.3. Configuring for nvim-lspconfig *quick-lint-js-configure-nvim-lspconfig* @@ -235,23 +227,11 @@ Set this option to a table of strings containing the operating system command for quick-lint-js. You must include the `"--lsp-server"` option. filetypes *quick-lint-js-configure-nvim-lspconfig-filetypes* - Default: `{"javascript", "javascriptreact"}` + Default: `{"javascript", "javascriptreact", "typescript", "typescriptreact"}` Set this option to a table of strings to enable quick-lint-js for different |filetype|s. -To lint TypeScript and TypeScript JSX files, not just JavaScript and JSX -files, add `"typescript"` and `"typescriptreact"` to `filetypes` -(EXPERIMENTAL. Subject to change in future versions of quick-lint-js.) -(Introduced in quick-lint-js version 2.11.0.): > - - require('lspconfig/quick_lint_js').setup { - filetypes = { - "javascript", "javascriptreact", - "typescript", "typescriptreact", - }, - } - settings.quick-lint-js.tracing-directory *quick-lint-js-configure-nvim-lspconfig-tracing-directory* Type: |String| diff --git a/plugin/vim/quick-lint-js.vim/lua/lspconfig/quick_lint_js.lua b/plugin/vim/quick-lint-js.vim/lua/lspconfig/quick_lint_js.lua index 808296a117..4ff4b2a069 100644 --- a/plugin/vim/quick-lint-js.vim/lua/lspconfig/quick_lint_js.lua +++ b/plugin/vim/quick-lint-js.vim/lua/lspconfig/quick_lint_js.lua @@ -13,7 +13,7 @@ local quick_lint_js_config = { -- Keep these in sync with -- plugin/vim/quick-lint-js.vim/doc/quick-lint-js.txt. cmd = {"quick-lint-js", "--lsp-server"}, - filetypes = {"javascript", "javascriptreact"}, + filetypes = {"javascript", "javascriptreact", "typescript", "typescriptreact"}, root_dir = function(fname) local root = lspconfig_util.path.dirname(fname) lspconfig_util.path.traverse_parents(fname, function(dir, _path) diff --git a/plugin/vim/quick-lint-js.vim/plugin/quick-lint-js.vim b/plugin/vim/quick-lint-js.vim/plugin/quick-lint-js.vim index 99d3d4fbc5..299ba6e13c 100644 --- a/plugin/vim/quick-lint-js.vim/plugin/quick-lint-js.vim +++ b/plugin/vim/quick-lint-js.vim/plugin/quick-lint-js.vim @@ -4,13 +4,7 @@ " Register quick-lint-js with coc.nvim (Conquer of Completion). " https://github.com/neoclide/coc.nvim -let s:enable_typescript = get(g:, 'coc_quick_lint_js_experimental_typescript', v:false) - -let s:filetypes = ['javascript', 'javascriptreact', 'json'] -if s:enable_typescript - call add(s:filetypes, 'typescript') - call add(s:filetypes, 'typescriptreact') -endif +let s:filetypes = ['javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'json'] try call coc#config('languageserver', { diff --git a/plugin/vscode/package.json b/plugin/vscode/package.json index 29cd7108be..d215eb24fb 100644 --- a/plugin/vscode/package.json +++ b/plugin/vscode/package.json @@ -28,12 +28,6 @@ "type": "object", "title": "quick-lint-js", "properties": { - "quick-lint-js.experimental-typescript": { - "scope": "window", - "type": "boolean", - "default": false, - "description": "Lint TypeScript and TypeScript JSX files, not just JavaScript and JSX files. (Requires restart.) (EXPERIMENTAL. Subject to change in future versions of quick-lint-js.)" - }, "quick-lint-js.logging": { "scope": "window", "type": "string", diff --git a/plugin/vscode/quick-lint-js/vscode/qljs-workspace.cpp b/plugin/vscode/quick-lint-js/vscode/qljs-workspace.cpp index 432045936c..7f4ccc4b4a 100644 --- a/plugin/vscode/quick-lint-js/vscode/qljs-workspace.cpp +++ b/plugin/vscode/quick-lint-js/vscode/qljs-workspace.cpp @@ -60,14 +60,6 @@ class Extension_Configuration { : config_ref_(::Napi::Persistent( vscode.get_configuration(env, "quick-lint-js"))) {} - bool get_experimental_typescript(::Napi::Env env) { - ::Napi::Value value = this->get(env, "experimental-typescript"); - if (!value.IsBoolean()) { - return false; - } - return value.As<::Napi::Boolean>().Value(); - } - Logging_Value get_logging(::Napi::Env env) { ::Napi::Value value = this->get(env, "logging"); if (!value.IsString()) { @@ -308,13 +300,11 @@ QLJS_Document_Base* QLJS_Workspace::maybe_create_document( if (to_string(vscode_document_uri.Get("scheme")) == "file") { file_path = to_string(vscode_document_uri.Get("fsPath")); } - bool allow_typescript = Extension_Configuration(env, this->vscode_) - .get_experimental_typescript(env); QLJS_Document_Base* doc; if (const VSCode_Language* lang = VSCode_Language::find( vscode_doc.language_id(), to_string8_view(vscode_doc.uri_string()), - /*allow_typescript=*/allow_typescript)) { + /*allow_typescript=*/true)) { doc = new QLJS_Lintable_Document(vscode_doc, file_path, lang->lint_options); } else if (file_path.has_value() && this->config_loader_.is_config_file_path(*file_path)) { diff --git a/plugin/vscode/test/vscode-tests.js b/plugin/vscode/test/vscode-tests.js index 76e166412d..e735a6b82d 100644 --- a/plugin/vscode/test/vscode-tests.js +++ b/plugin/vscode/test/vscode-tests.js @@ -213,25 +213,6 @@ tests = { }); }, - "parser does not check TypeScript files by default": async ({ - addCleanup, - }) => { - for (let extension of [".ts", ".tsx"]) { - let scratchDirectory = makeScratchDirectory({ addCleanup }); - let helloFilePath = path.join(scratchDirectory, `hello${extension}`); - fs.writeFileSync(helloFilePath, "this is a bug"); - let helloURI = vscode.Uri.file(helloFilePath); - - await loadExtensionAsync({ addCleanup }); - let helloDocument = await vscode.workspace.openTextDocument(helloURI); - let helloEditor = await vscode.window.showTextDocument(helloDocument); - - // Wait for possible linting to take effect. - await sleepAsync(100); - await waitUntilNoDiagnosticsAsync(helloURI); - } - }, - "parser checks TypeScript files if opted in": async ({ addCleanup }) => { let scratchDirectory = makeScratchDirectory({ addCleanup }); let helloFilePath = path.join(scratchDirectory, "hello.ts"); @@ -242,13 +223,6 @@ tests = { let helloURI = vscode.Uri.file(helloFilePath); await loadExtensionAsync({ addCleanup }); - await vscode.workspace - .getConfiguration("quick-lint-js") - .update( - "experimental-typescript", - true, - vscode.ConfigurationTarget.Workspace - ); let helloDocument = await vscode.workspace.openTextDocument(helloURI); let helloEditor = await vscode.window.showTextDocument(helloDocument); @@ -263,7 +237,7 @@ tests = { }); }, - "parser checks TypeScript JSX files if opted in": async ({ addCleanup }) => { + "parser checks TypeScript JSX files": async ({ addCleanup }) => { let scratchDirectory = makeScratchDirectory({ addCleanup }); let helloFilePath = path.join(scratchDirectory, "hello.tsx"); fs.writeFileSync( @@ -273,13 +247,6 @@ tests = { let helloURI = vscode.Uri.file(helloFilePath); await loadExtensionAsync({ addCleanup }); - await vscode.workspace - .getConfiguration("quick-lint-js") - .update( - "experimental-typescript", - true, - vscode.ConfigurationTarget.Workspace - ); let helloDocument = await vscode.workspace.openTextDocument(helloURI); let helloEditor = await vscode.window.showTextDocument(helloDocument); @@ -1568,7 +1535,7 @@ async function pollAsync(callback) { } async function resetConfigurationAsync() { - for (let setting of ["experimental-typescript", "logging"]) { + for (let setting of ["logging"]) { await vscode.workspace .getConfiguration("quick-lint-js") .update(setting, undefined, vscode.ConfigurationTarget.Workspace); diff --git a/src/quick-lint-js/cli/options.cpp b/src/quick-lint-js/cli/options.cpp index eedb366649..8e1cb0e537 100644 --- a/src/quick-lint-js/cli/options.cpp +++ b/src/quick-lint-js/cli/options.cpp @@ -132,17 +132,15 @@ Options parse_options(int argc, char** argv, Monotonic_Allocator* allocator) { unused_language_option = arg_value; if (arg_value == "default"sv) { language = Raw_Input_File_Language::default_; - } else if (arg_value == "experimental-default"sv) { - language = Raw_Input_File_Language::experimental_default; } else if (arg_value == "javascript"sv) { language = Raw_Input_File_Language::javascript; } else if (arg_value == "javascript-jsx"sv) { language = Raw_Input_File_Language::javascript_jsx; - } else if (arg_value == "experimental-typescript"sv) { + } else if (arg_value == "typescript"sv) { language = Raw_Input_File_Language::typescript; - } else if (arg_value == "experimental-typescript-definition"sv) { + } else if (arg_value == "typescript-definition"sv) { language = Raw_Input_File_Language::typescript_definition; - } else if (arg_value == "experimental-typescript-jsx"sv) { + } else if (arg_value == "typescript-jsx"sv) { language = Raw_Input_File_Language::typescript_jsx; } else { error_unrecognized_options.emplace_back(arg_value); @@ -324,8 +322,6 @@ Resolved_Input_File_Language get_language(const File_To_Lint& file, Resolved_Input_File_Language get_language(const char* file, Raw_Input_File_Language language) { if (language == Raw_Input_File_Language::default_) { - return Resolved_Input_File_Language::javascript_jsx; - } else if (language == Raw_Input_File_Language::experimental_default) { Path_Classification classification = classify_path(file); if (classification.typescript_jsx) { return Resolved_Input_File_Language::typescript_jsx; diff --git a/src/quick-lint-js/cli/options.h b/src/quick-lint-js/cli/options.h index 199df777b4..6aa3f2c2c9 100644 --- a/src/quick-lint-js/cli/options.h +++ b/src/quick-lint-js/cli/options.h @@ -22,9 +22,6 @@ enum class Output_Format { enum class Raw_Input_File_Language : unsigned char { // Explicit (--language=default) or implicit (no --language). default_, - // Explicit --language=experimental-default. - // TODO(#690): Make experimental_default the default and delete default_. - experimental_default, javascript, javascript_jsx, diff --git a/test/test-options.cpp b/test/test-options.cpp index 68d7f9c4fc..19cdc918ab 100644 --- a/test/test-options.cpp +++ b/test/test-options.cpp @@ -379,14 +379,6 @@ TEST_F(Test_Options, language) { EXPECT_EQ(o.files_to_lint[0].language, Raw_Input_File_Language::default_); } - { - Options o = - parse_options_no_errors({"--language=experimental-default", "file.js"}); - ASSERT_EQ(o.files_to_lint.size(), 1); - EXPECT_EQ(o.files_to_lint[0].language, - Raw_Input_File_Language::experimental_default); - } - { Options o = parse_options_no_errors( {"--language=javascript", "one.js", "two.ts", "three.txt"}); @@ -417,14 +409,14 @@ TEST_F(Test_Options, language) { { Options o = parse_options_no_errors( - {"--language=experimental-typescript", "one.txt"}); + {"--language=typescript", "one.txt"}); ASSERT_EQ(o.files_to_lint.size(), 1); EXPECT_EQ(o.files_to_lint[0].language, Raw_Input_File_Language::typescript); } { Options o = parse_options_no_errors( - {"--language=experimental-typescript-definition", "one.txt"}); + {"--language=typescript-definition", "one.txt"}); ASSERT_EQ(o.files_to_lint.size(), 1); EXPECT_EQ(o.files_to_lint[0].language, Raw_Input_File_Language::typescript_definition); @@ -432,7 +424,7 @@ TEST_F(Test_Options, language) { { Options o = parse_options_no_errors( - {"--language=experimental-typescript-jsx", "one.txt"}); + {"--language=typescript-jsx", "one.txt"}); ASSERT_EQ(o.files_to_lint.size(), 1); EXPECT_EQ(o.files_to_lint[0].language, Raw_Input_File_Language::typescript_jsx); @@ -489,23 +481,9 @@ TEST_F(Test_Options, invalid_language) { } TEST_F(Test_Options, - default_language_is_javascript_jsx_regardless_of_extension) { - constexpr auto default_language = Raw_Input_File_Language::default_; - constexpr auto javascript_jsx = Resolved_Input_File_Language::javascript_jsx; - EXPECT_EQ(get_language("", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.js", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.jsx", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.ts", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.d.ts", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.d.js", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.tsx", default_language), javascript_jsx); - EXPECT_EQ(get_language("hi.txt", default_language), javascript_jsx); -} - -TEST_F(Test_Options, - experimental_default_language_guesses_language_from_extension) { + default_language_guesses_language_from_extension) { constexpr auto default_language = - Raw_Input_File_Language::experimental_default; + Raw_Input_File_Language::default_; constexpr auto javascript_jsx = Resolved_Input_File_Language::javascript_jsx; EXPECT_EQ(get_language("", default_language), javascript_jsx); EXPECT_EQ(get_language("hi.js", default_language), javascript_jsx);