├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .github └── workflows │ ├── better_link_checker.ts │ ├── ci.yml │ ├── deploy.yml │ ├── update_versions.ts │ └── update_versions.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── _components ├── Base.tsx ├── Breadcrumbs.css ├── Breadcrumbs.tsx ├── ExternalLink.css ├── ExternalLink.tsx ├── Feedback.tsx ├── Footer.css ├── Footer.tsx ├── FourOhFour.css ├── FourOhFour.tsx ├── Hamburger.css ├── Hamburger.tsx ├── Header.css ├── Header.tsx ├── HeaderAnchor.tsx ├── LandingPage.tsx ├── Logo.tsx ├── MainNav.css ├── MainNav.tsx ├── Navigation.css ├── Navigation.tsx ├── NavigationButton.tsx ├── RefHeader.css ├── RefHeader.tsx ├── RefToc.tsx ├── SearchInput.css ├── SearchInput.tsx ├── SecondaryNav.css ├── SecondaryNav.tsx ├── Sidebar.tsx ├── TabItem.tsx ├── TableOfContents.css ├── TableOfContents.tsx ├── TableOfContentsItem.tsx ├── TableOfContentsMobile.tsx ├── Tabs.tsx ├── ThemeToggle.css ├── ThemeToggle.tsx ├── ToTop.tsx ├── VideoPlayer.css └── VideoPlayer.tsx ├── _config-styleguide.ts ├── _config.ts ├── _data.json ├── _includes ├── doc.tsx ├── layout.tsx ├── lintRule.tsx ├── raw.tsx ├── reference │ ├── allSymbols.tsx │ ├── index.tsx │ └── symbol.tsx ├── renderCommand.tsx └── video.tsx ├── copy.client.ts ├── data.json ├── deno.json ├── deno.lock ├── deploy ├── _data.ts ├── api │ ├── compression.md │ ├── dynamic-import.md │ ├── index.md │ ├── runtime-broadcast-channel.md │ ├── runtime-fetch.md │ ├── runtime-fs.md │ ├── runtime-headers.md │ ├── runtime-node.md │ ├── runtime-request.md │ ├── runtime-response.md │ └── runtime-sockets.md ├── docs-images │ ├── add_custom_domain.png │ ├── blank_project.png │ ├── change_dns_records.png │ ├── discord-slash-command.png │ ├── dns_records_modal.png │ ├── fauna1.png │ ├── fauna2.png │ ├── get_certificates.png │ ├── green_check.png │ ├── neon_postgres_env_variable.png │ ├── new_github_repo.png │ ├── organizations.png │ ├── postgres_env_variable.png │ ├── preview_deployment.png │ ├── project_name.png │ ├── promote_to_production.png │ ├── proxy_to_example.png │ ├── vite-branch.png │ ├── vite-deploy-yaml.png │ ├── vite-link.png │ ├── vite-ok.png │ └── vite-project.png ├── index.md ├── kv │ ├── manual │ │ ├── _admonition.tsx │ │ ├── backup.md │ │ ├── cron.md │ │ ├── data_modeling_typescript.md │ │ ├── images │ │ │ ├── backup-add-bucket-to-dash.png │ │ │ ├── backup-bucket-create.png │ │ │ ├── backup-gcs-bucket-create.png │ │ │ ├── backup-gcs-create-hmac.png │ │ │ ├── backup-gcs-grant.png │ │ │ ├── cron-tasks.png │ │ │ └── kv-connect.png │ │ ├── index.md │ │ ├── key_expiration.md │ │ ├── key_space.md │ │ ├── node.md │ │ ├── on_deploy.md │ │ ├── operations.md │ │ ├── queue_overview.md │ │ ├── secondary_indexes.md │ │ └── transactions.md │ └── tutorials │ │ ├── images │ │ └── github_webhook.png │ │ ├── index.md │ │ ├── schedule_notification.md │ │ └── webhook_processor.md ├── manual │ ├── acceptable-use-policy.md │ ├── ci_github.md │ ├── custom-domains.md │ ├── deployctl.md │ ├── deployments.md │ ├── dynamodb.md │ ├── edge-cache.md │ ├── environment-variables.md │ ├── faunadb.md │ ├── firebase.md │ ├── fulfillment-policy.md │ ├── how-to-deploy.md │ ├── images │ │ ├── deploy_onboarding.png │ │ ├── deployctl-deployments-list.png │ │ ├── deployctl-deployments-show.png │ │ └── project_deployments.png │ ├── index.md │ ├── logs.md │ ├── middleware.md │ ├── neon-postgres.md │ ├── organizations.md │ ├── playgrounds.md │ ├── postgres.md │ ├── pricing-and-limits.md │ ├── privacy-policy.md │ ├── regions.md │ ├── running-scripts-locally.md │ ├── security.md │ ├── terms-and-conditions.md │ └── use-cases.md └── tutorials │ ├── discord-slash.md │ ├── fresh.md │ ├── images │ ├── simple_api_dashboard.png │ ├── simple_api_deploy.png │ └── simple_api_deploy_settings.png │ ├── index.md │ ├── simple-api.md │ ├── static-site.md │ ├── tutorial-blog-fresh.md │ ├── tutorial-dynamodb.md │ ├── tutorial-faunadb.md │ ├── tutorial-firebase.md │ ├── tutorial-http-server.md │ ├── tutorial-hugo-blog.md │ ├── tutorial-postgres.md │ ├── tutorial-wordpress-frontend.md │ └── vite.md ├── examples ├── _components │ ├── CopyButton.tsx │ ├── EmbedVideo.tsx │ ├── ExampleIcon.tsx │ ├── ExamplePage.tsx │ ├── LearningList.tsx │ ├── SnippetComponent.tsx │ ├── TutorialIcon.tsx │ └── VideoIcon.tsx ├── _data.ts ├── _pages │ ├── VideoPage.tsx │ └── examples_test.ts ├── index.examples.tsx ├── index.tsx ├── scripts │ ├── aes_encryption.ts │ ├── benchmarking.ts │ ├── byte_manipulation.ts │ ├── checking_directory_existence.ts │ ├── checking_file_existence.ts │ ├── color_logging.ts │ ├── command_line_arguments.ts │ ├── create_remove_directories.ts │ ├── creating_and_verifying_jwt.ts │ ├── cron.ts │ ├── data_processing.ts │ ├── deleting_files.ts │ ├── deno_version.ts │ ├── dns_queries.ts │ ├── duckdb.ts │ ├── environment_variables.ts │ ├── exponential_backoff.ts │ ├── hashing.ts │ ├── hello_world.ts │ ├── hex_base64_encoding.ts │ ├── hmac_generate_verify.ts │ ├── hono.ts │ ├── http_requests.ts │ ├── http_server.ts │ ├── http_server_files.ts │ ├── http_server_oak_crud_middleware_with_sqlite3_db.ts │ ├── http_server_routing.ts │ ├── http_server_streaming.ts │ ├── http_server_websocket.ts │ ├── import_export.ts │ ├── importing_json.ts │ ├── kv.ts │ ├── kv_watch.ts │ ├── mongo.ts │ ├── moving_renaming_files.ts │ ├── node_built_in.ts │ ├── npm.ts │ ├── openai_chat_completion.ts │ ├── os_signals.ts │ ├── parsing_serializing_csv.ts │ ├── parsing_serializing_json.ts │ ├── parsing_serializing_toml.ts │ ├── parsing_serializing_yaml.ts │ ├── path_operations.ts │ ├── permissions.ts │ ├── pid.ts │ ├── piping_streams.ts │ ├── postgres.ts │ ├── prompts.ts │ ├── queues.ts │ ├── reading_files.ts │ ├── reading_system_metrics.ts │ ├── redis.ts │ ├── rsa_signature.ts │ ├── spy_functions.ts │ ├── sqlite.ts │ ├── sss.ts │ ├── streaming_files.ts │ ├── stubs.ts │ ├── subprocess_running_files.ts │ ├── subprocesses_output.ts │ ├── subprocesses_spawn.ts │ ├── supabase.ts │ ├── symlinks.ts │ ├── tcp_connector.ts │ ├── tcp_echo_server.ts │ ├── tcp_listener.ts │ ├── temporal.ts │ ├── temporary_files.ts │ ├── timers.ts │ ├── tls_connector.ts │ ├── tls_listener.ts │ ├── top_level_await.ts │ ├── typescript_support.ts │ ├── udp_connector.ts │ ├── udp_listener.ts │ ├── ulid.ts │ ├── unix_cat.ts │ ├── unzip_gzipped_file.ts │ ├── url_parsing.ts │ ├── uuids.ts │ ├── walking_directories.ts │ ├── watching_files.ts │ ├── web_workers.ts │ ├── webassembly.ts │ ├── websocket.ts │ ├── writing_files.ts │ └── writing_tests.ts ├── tutorials │ ├── apollo.md │ ├── astro.md │ ├── aws_lambda.md │ ├── aws_lightsail.md │ ├── chat_app.md │ ├── cjs_to_esm.md │ ├── cloudflare_workers.md │ ├── connecting_to_databases.md │ ├── create_react.md │ ├── debugging_with_console.md │ ├── digital_ocean.md │ ├── drizzle.md │ ├── express.md │ ├── fetch_data.md │ ├── file_based_routing.md │ ├── file_server.md │ ├── file_system_events.md │ ├── google_cloud_run.md │ ├── hashbang.md │ ├── images │ │ ├── deno-educator.png │ │ ├── how-to │ │ │ ├── astro │ │ │ │ ├── dynamic-page.webp │ │ │ │ ├── hello-astro.png │ │ │ │ └── index-page.webp │ │ │ ├── aws-lightsail │ │ │ │ ├── create-container-service-on-aws.png │ │ │ │ ├── hello-world-from-deno-and-aws-lightsail.png │ │ │ │ ├── hello-world-from-localhost.png │ │ │ │ └── new-image-on-docker-hub.png │ │ │ ├── cloudflare-workers │ │ │ │ └── main-on-cloudflare.png │ │ │ ├── digital-ocean │ │ │ │ ├── hello-from-deno-and-digital-ocean.png │ │ │ │ ├── hello-world-from-localhost.png │ │ │ │ └── new-deno-image-on-digital-ocean-container-registry.png │ │ │ ├── drizzle │ │ │ │ └── table-diagram.png │ │ │ ├── google-cloud-run │ │ │ │ ├── hello-from-google-cloud-run.png │ │ │ │ ├── hello-world-from-localhost.png │ │ │ │ ├── image-in-google-artifact-registry.png │ │ │ │ └── new-repository-in-google-artifact-repository.png │ │ │ ├── next │ │ │ │ └── dinoapp.gif │ │ │ ├── nuxt │ │ │ │ ├── nuxt-1.webp │ │ │ │ ├── nuxt-2.webp │ │ │ │ ├── nuxt-3.mp4 │ │ │ │ └── nuxt-4.mp4 │ │ │ ├── prisma │ │ │ │ ├── 1-dinosaurs-in-prisma.png │ │ │ │ ├── 2-dinosaurs-from-api.png │ │ │ │ └── 3-new-dinosaur-in-prisma.png │ │ │ ├── qwik │ │ │ │ └── demo.mp4 │ │ │ ├── react │ │ │ │ └── react-dinosaur-app-demo.gif │ │ │ ├── redis │ │ │ │ ├── cached-redis-body.png │ │ │ │ ├── cached-redis-header.png │ │ │ │ ├── uncached-redis-body.png │ │ │ │ └── uncached-redis-header.png │ │ │ ├── solidjs │ │ │ │ └── demo.mp4 │ │ │ ├── tanstack │ │ │ │ └── demo.mp4 │ │ │ └── vue │ │ │ │ └── vue.gif │ │ ├── quick-fix.png │ │ ├── websockets.gif │ │ └── word_finder.png │ ├── initialize_project.md │ ├── kinsta.md │ ├── module_metadata.md │ ├── mongoose.md │ ├── mysql2.md │ ├── next.md │ ├── nuxt.md │ ├── os_signals.md │ ├── planetscale.md │ ├── prisma.md │ ├── qwik.md │ ├── react.md │ ├── redis.md │ ├── run_script.md │ ├── solidjs.md │ ├── subprocess.md │ ├── tanstack.md │ ├── trpc.md │ ├── vue.md │ └── word_finder.md ├── types.ts ├── utils │ └── parseExample.ts └── videos │ ├── all-in-one_tooling.md │ ├── backward_compat_with_node_npm.md │ ├── browser_apis_in_deno.md │ ├── build_api_server_ts.md │ ├── command_line_utility.md │ ├── configuration_with_deno_json.md │ ├── deno_bench.md │ ├── deno_coverage.md │ ├── deno_dev_environment.md │ ├── deno_fmt.md │ ├── deno_test.md │ ├── deploy_deno_to_aws_lambda.md │ ├── deploying_deno_with_docker.md │ ├── esmodules.md │ ├── interoperability_with_nodejs.md │ ├── intro_to_deno_apis.md │ ├── mongoose.md │ ├── prisma.md │ ├── publishing_modules_with_jsr.md │ ├── react_app_video.md │ ├── realtime_websocket_app.md │ ├── ts_jsx.md │ ├── vue_app_video.md │ └── what_is_deno.md ├── feedback.client.ts ├── go.json ├── index.page.tsx ├── lint ├── _data.ts ├── index.tsx ├── lint_rule.page.tsx └── rules │ ├── adjacent-overload-signatures.md │ ├── ban-ts-comment.md │ ├── ban-types.md │ ├── ban-unknown-rule-code.md │ ├── ban-untagged-ignore.md │ ├── ban-untagged-todo.md │ ├── ban-unused-ignore.md │ ├── button-has-type.md │ ├── camelcase.md │ ├── constructor-super.md │ ├── default-param-last.md │ ├── eqeqeq.md │ ├── explicit-function-return-type.md │ ├── explicit-module-boundary-types.md │ ├── for-direction.md │ ├── fresh-handler-export.md │ ├── fresh-server-event-handlers.md │ ├── getter-return.md │ ├── guard-for-in.md │ ├── jsx-boolean-value.md │ ├── jsx-button-has-type.md │ ├── jsx-curly-braces.md │ ├── jsx-key.md │ ├── jsx-no-children-prop.md │ ├── jsx-no-comment-text-nodes.md │ ├── jsx-no-duplicate-props.md │ ├── jsx-no-unescaped-entities.md │ ├── jsx-no-useless-fragment.md │ ├── jsx-props-no-spread-multi.md │ ├── jsx-void-dom-elements-no-children.md │ ├── no-array-constructor.md │ ├── no-async-promise-executor.md │ ├── no-await-in-loop.md │ ├── no-await-in-sync-fn.md │ ├── no-boolean-literal-for-arguments.md │ ├── no-case-declarations.md │ ├── no-class-assign.md │ ├── no-compare-neg-zero.md │ ├── no-cond-assign.md │ ├── no-console.md │ ├── no-const-assign.md │ ├── no-constant-condition.md │ ├── no-control-regex.md │ ├── no-debugger.md │ ├── no-delete-var.md │ ├── no-deprecated-deno-api.md │ ├── no-dupe-args.md │ ├── no-dupe-class-members.md │ ├── no-dupe-else-if.md │ ├── no-dupe-keys.md │ ├── no-duplicate-case.md │ ├── no-empty-character-class.md │ ├── no-empty-enum.md │ ├── no-empty-interface.md │ ├── no-empty-pattern.md │ ├── no-empty.md │ ├── no-eval.md │ ├── no-ex-assign.md │ ├── no-explicit-any.md │ ├── no-external-import.md │ ├── no-extra-boolean-cast.md │ ├── no-extra-non-null-assertion.md │ ├── no-fallthrough.md │ ├── no-func-assign.md │ ├── no-global-assign.md │ ├── no-implicit-declare-namespace-export.md │ ├── no-import-assertions.md │ ├── no-import-assign.md │ ├── no-inferrable-types.md │ ├── no-inner-declarations.md │ ├── no-invalid-regexp.md │ ├── no-invalid-triple-slash-reference.md │ ├── no-irregular-whitespace.md │ ├── no-misused-new.md │ ├── no-namespace.md │ ├── no-new-symbol.md │ ├── no-node-globals.md │ ├── no-non-null-asserted-optional-chain.md │ ├── no-non-null-assertion.md │ ├── no-obj-calls.md │ ├── no-octal.md │ ├── no-process-global.md │ ├── no-prototype-builtins.md │ ├── no-redeclare.md │ ├── no-regex-spaces.md │ ├── no-self-assign.md │ ├── no-self-compare.md │ ├── no-setter-return.md │ ├── no-shadow-restricted-names.md │ ├── no-sloppy-imports.md │ ├── no-slow-types.md │ ├── no-sparse-arrays.md │ ├── no-sync-fn-in-async-fn.md │ ├── no-this-alias.md │ ├── no-this-before-super.md │ ├── no-throw-literal.md │ ├── no-top-level-await.md │ ├── no-undef.md │ ├── no-unreachable.md │ ├── no-unsafe-finally.md │ ├── no-unsafe-negation.md │ ├── no-unused-labels.md │ ├── no-unused-vars.md │ ├── no-useless-rename.md │ ├── no-var.md │ ├── no-window-prefix.md │ ├── no-window.md │ ├── no-with.md │ ├── prefer-as-const.md │ ├── prefer-ascii.md │ ├── prefer-const.md │ ├── prefer-namespace-keyword.md │ ├── prefer-primordials.md │ ├── react-no-danger-with-children.md │ ├── react-no-danger.md │ ├── react-rules-of-hooks.md │ ├── require-await.md │ ├── require-yield.md │ ├── single-var-declarator.md │ ├── triple-slash-reference.md │ ├── use-isnan.md │ ├── valid-typeof.md │ └── verbatim-module-syntax.md ├── lint_rules.client.ts ├── lume.ts ├── markdown-it ├── admonition.ts ├── codeblock-copy.ts ├── codeblock-title.ts ├── relative-path.ts └── replacer.ts ├── middleware ├── apiDocContentType.ts ├── functionRoutes.ts ├── functions │ ├── feedback.ts │ ├── feedback_test.ts │ ├── health.ts │ └── routes.ts ├── googleAnalytics.ts ├── null.ts └── redirects.ts ├── oldurls.json ├── overrides.css ├── prism.ts ├── reference ├── _components │ ├── Anchor.tsx │ ├── Arrow.tsx │ ├── Breadcrumbs.tsx │ ├── Check.tsx │ ├── Copy.tsx │ ├── Deprecated.tsx │ ├── DocBlockSubtitleClass.tsx │ ├── DocBlockSubtitleInterface.tsx │ ├── DocEntry.tsx │ ├── DocNodeKindIcon.tsx │ ├── Example.tsx │ ├── Function.tsx │ ├── HeaderItem.tsx │ ├── IndexSignature.tsx │ ├── Link.tsx │ ├── ModuleDoc.tsx │ ├── NamespaceSection.tsx │ ├── RefNav.tsx │ ├── Section.css │ ├── Section.tsx │ ├── See.tsx │ ├── SymbolContent.tsx │ ├── SymbolGroup.tsx │ ├── Tag.tsx │ └── UsageLarge.tsx └── reference.page.tsx ├── reference_gen ├── common.ts ├── deno-categories.json ├── deno-doc.ts ├── deno-types.ts ├── deno.jsonc ├── deno.lock ├── node-default-map.json ├── node-doc.ts ├── node-exclude-map.json ├── node-rewrite-map.json ├── node-symbol-map.json ├── node-types.ts ├── node_descriptions │ ├── assert.yaml │ ├── async_hooks.yaml │ ├── buffer.yaml │ ├── child_process.yaml │ ├── cluster.yaml │ ├── console.yaml │ ├── crypto.yaml │ ├── dgram.yaml │ ├── diagnostics_channel.yaml │ ├── dns.yaml │ ├── domain.yaml │ ├── events.yaml │ ├── fs--promises.yaml │ ├── fs.yaml │ ├── http.yaml │ ├── http2.yaml │ ├── https.yaml │ ├── inspector.yaml │ ├── module.yaml │ ├── net.yaml │ ├── os.yaml │ ├── path.yaml │ ├── perf_hooks.yaml │ ├── process.yaml │ ├── punycode.yaml │ ├── querystring.yaml │ ├── readline.yaml │ ├── repl.yaml │ ├── sea.yaml │ ├── sqlite.yaml │ ├── stream.yaml │ ├── string_decoder.yaml │ ├── test.yaml │ ├── timers.yaml │ ├── tls.yaml │ ├── trace_events.yaml │ ├── tty.yaml │ ├── url.yaml │ ├── util.yaml │ ├── v8.yaml │ ├── vm.yaml │ ├── wasi.yaml │ ├── worker_threads.yaml │ └── zlib.yaml ├── web-categories.json └── web-doc.ts ├── replacements.json ├── runtime ├── _data.ts ├── contributing │ ├── architecture.md │ ├── building_from_source.md │ ├── docs.md │ ├── examples.md │ ├── images │ │ └── stickers.jpg │ ├── index.md │ ├── profiling.md │ ├── release_schedule.md │ ├── style_guide.md │ └── web_platform_tests.md ├── fundamentals │ ├── _category_.json │ ├── configuration.md │ ├── debugging.md │ ├── http_server.md │ ├── images │ │ ├── debugger1.png │ │ ├── debugger2.jpg │ │ ├── debugger3.jpg │ │ ├── debugger4.jpg │ │ ├── debugger5.jpg │ │ ├── debugger7.jpg │ │ ├── deno-lts-support.png │ │ ├── jb-ide-debug.png │ │ ├── node_modules_dir.png │ │ ├── private-github-new-token.png │ │ ├── private-github-token-display.png │ │ └── private-pat.png │ ├── index.md │ ├── linting_and_formatting.md │ ├── modules.md │ ├── node.md │ ├── open_telemetry.md │ ├── security.md │ ├── stability_and_releases.md │ ├── standard_library.md │ ├── testing.md │ ├── typescript.md │ ├── web_dev.md │ └── workspaces.md ├── getting_started │ ├── _category_.json │ ├── command_line_interface.md │ ├── first_project.md │ ├── images │ │ ├── vscode-setup.png │ │ └── webstorm_setup.png │ ├── installation.md │ └── setup_your_environment.md ├── help.md ├── index.md └── reference │ ├── cli │ ├── _commands_reference.json │ ├── add.md │ ├── bench.md │ ├── bundler.md │ ├── check.md │ ├── clean.md │ ├── compile.md │ ├── completions.md │ ├── coverage.md │ ├── doc.md │ ├── env_variables.md │ ├── eval.md │ ├── fmt.md │ ├── index.md │ ├── info.md │ ├── init.md │ ├── install.md │ ├── jupyter.md │ ├── lint.md │ ├── lsp.md │ ├── outdated.md │ ├── publish.md │ ├── remove.md │ ├── repl.md │ ├── run.md │ ├── serve.md │ ├── task.md │ ├── test.md │ ├── types.md │ ├── uninstall.md │ ├── unstable_flags.md │ └── upgrade.md │ ├── continuous_integration.md │ ├── deno_namespace_apis.md │ ├── docker.md │ ├── documentation.md │ ├── env_variables.md │ ├── images │ ├── command_palette.png │ ├── jupyter-broadcast.mp4 │ ├── jupyter-cli.gif │ ├── jupyter-confirm-prompt.mp4 │ ├── jupyter-display.png │ ├── jupyter-html.png │ ├── jupyter-md.png │ ├── jupyter-plot.png │ ├── jupyter-svg.png │ ├── jupyter_notebook.png │ └── vscode_workspace_initialized.png │ ├── index.md │ ├── jsx.md │ ├── lint_plugins.md │ ├── lsp_integration.md │ ├── migration_guide.md │ ├── node_apis.md │ ├── ts_config_migration.md │ ├── vscode.md │ ├── wasm.md │ └── web_platform_apis.md ├── server.ts ├── static ├── .nojekyll ├── android-chrome-192x192.png ├── android-chrome-512x512.png ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── deno-deploy-button.svg ├── deno-looking-up.svg ├── dino-only.svg ├── examples.png ├── examples │ ├── local.ts │ └── welcome.ts ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── fonts │ └── inter │ │ ├── Inter-Italic.woff2 │ │ ├── Inter-Regular.woff2 │ │ ├── Inter-SemiBold.woff2 │ │ └── Inter-SemiBoldItalic.woff2 ├── github-mark.png ├── img │ ├── checkmark.svg │ ├── chevron.svg │ ├── cover@xl.avif │ ├── dark.svg │ ├── deno-balloon.svg │ ├── deno-box.svg │ ├── deno-docs-dark.svg │ ├── deno-docs.svg │ ├── deno-shield.svg │ ├── deno-tool.svg │ ├── deno_hr_circle.svg │ ├── docs-logotype.svg │ ├── docusaurus.png │ ├── fresh.svg │ ├── jsr.svg │ ├── jsx.svg │ ├── light.svg │ ├── logo-dark.svg │ ├── logo.svg │ ├── og.webp │ ├── react.svg │ ├── search.svg │ └── social.png ├── js │ ├── darkmode-toggle.client.js │ ├── darkmode.client.js │ ├── nav-toggle.client.js │ └── youtube-lite.client.js ├── reference_styles.css ├── robots.txt └── style.css ├── styleguide ├── _data.ts ├── components.mdx ├── example-page.md ├── index.md └── typography.mdx ├── styles.css ├── subhosting ├── _data.ts ├── api │ ├── authentication.md │ ├── images │ │ ├── org-id.png │ │ └── subhosting-org-structure.svg │ └── index.md ├── index.md └── manual │ ├── acceptable_use_policy.md │ ├── events.md │ ├── index.md │ ├── planning_your_implementation.md │ ├── pricing_and_limits.md │ └── quick_start.md ├── tabs.client.ts ├── tailwind.config.js ├── timeUtils.ts ├── translation.json ├── types.ts ├── update_lint_rules.ts └── zhCN.ts /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu 2 | COPY --from=denoland/deno:bin-2.0.4 /deno /usr/local/bin/deno 3 | 4 | EXPOSE 3000 5 | EXPOSE 8000 6 | 7 | WORKDIR /app 8 | 9 | COPY . . 10 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Deno", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | 7 | // Set *default* container specific settings.json values on container create. 8 | "customizations": { 9 | "vscode": { 10 | "extensions": ["denoland.vscode-deno"], 11 | "settings": { "terminal.integrated.shell.linux": "/bin/bash" } 12 | } 13 | }, 14 | 15 | "forwardPorts": [3000, 8000], 16 | 17 | "mounts": [], 18 | "remoteEnv": { 19 | "SOME_ENV": "some-value" 20 | }, 21 | "postCreateCommand": "deno install && cd reference_gen && deno task types && deno task doc && cd .." 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [main] 5 | pull_request: 6 | branches: [main] 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 10 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: denoland/setup-deno@v2 14 | 15 | - run: deno fmt --check 16 | - run: deno task test 17 | -------------------------------------------------------------------------------- /.github/workflows/update_versions.yml: -------------------------------------------------------------------------------- 1 | name: update_versions 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | name: update replacements.json 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 30 11 | 12 | steps: 13 | - name: Clone repository 14 | uses: actions/checkout@v2 15 | with: 16 | token: ${{ secrets.DENOBOT_PAT }} 17 | 18 | - name: Install deno 19 | uses: denoland/setup-deno@v2 20 | 21 | - name: Build and Create PR 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.DENOBOT_PAT }} 24 | GH_WORKFLOW_ACTOR: ${{ github.actor }} 25 | run: | 26 | git config user.email "${{ github.actor }}@users.noreply.github.com" 27 | git config user.name "${{ github.actor }}" 28 | deno run -A --no-lock .github/workflows/update_versions.ts --create-pr 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | _cache 3 | _broken_links.json 4 | 5 | .idea 6 | 7 | node_modules 8 | 9 | reference_gen/gen 10 | reference_gen/node_modules 11 | reference_gen/types 12 | 13 | .DS_Store 14 | .env 15 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "editor.defaultFormatter": "denoland.vscode-deno", 4 | "editor.formatOnSave": true, 5 | "editor.formatOnPaste": false, 6 | "[typescriptreact]": { 7 | "editor.defaultFormatter": "denoland.vscode-deno" 8 | }, 9 | "editor.detectIndentation": true 10 | } 11 | -------------------------------------------------------------------------------- /_components/Base.tsx: -------------------------------------------------------------------------------- 1 | import type { PageBase, ToCCtx } from "@deno/doc"; 2 | 3 | export default function Base( 4 | { data, comp, children }: Lume.Data & { data: PageBase }, 5 | _helpers: Lume.Helpers, 6 | ) { 7 | return ( 8 | <> 9 |
10 | 11 | 12 |
13 | {children} 14 |
15 |
16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /_components/Breadcrumbs.css: -------------------------------------------------------------------------------- 1 | .crumbs { 2 | display: flex; 3 | flex-wrap: wrap; 4 | text-align: center; 5 | margin-top: 0.5rem; 6 | margin-left: -0.75rem; 7 | color: hsl(var(--foreground-secondary)); 8 | } 9 | 10 | .crumb-link { 11 | display: flex; 12 | align-items: center; 13 | &::after { 14 | content: ""; 15 | width: 1em; 16 | height: 1em; 17 | background: url(./img/chevron.svg) no-repeat center; 18 | display: inline-block; 19 | margin-left: 1rem; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /_components/ExternalLink.css: -------------------------------------------------------------------------------- 1 | .external { 2 | display: none; 3 | } 4 | @media (min-width: 650px) { 5 | .external { 6 | display: block; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /_components/ExternalLink.tsx: -------------------------------------------------------------------------------- 1 | export default function ExternalLink( 2 | { href, children }: { href: string; children: string }, 3 | ) { 4 | return ( 5 | 10 | {children} 11 | 12 | ); 13 | } 14 | 15 | export const css = "@import './_components/ExternalLink.css';"; 16 | -------------------------------------------------------------------------------- /_components/FourOhFour.css: -------------------------------------------------------------------------------- 1 | .fourohfour { 2 | display: grid; 3 | place-items: center; 4 | padding: 6rem 5vw 0; 5 | } 6 | -------------------------------------------------------------------------------- /_components/FourOhFour.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 |
4 |

5 |
6 | 404 7 |
8 | 抱歉,找不到那个页面。 9 |

10 |

11 | 也许这些链接中有你要找的内容? 12 |

13 |
14 | ); 15 | } 16 | 17 | export const css = "@import './_components/FourOhFour.css';"; 18 | -------------------------------------------------------------------------------- /_components/Hamburger.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 | <> 4 | 9 | 10 | 11 | ); 12 | } 13 | 14 | export const css = "@import './_components/Hamburger.css';"; 15 | -------------------------------------------------------------------------------- /_components/Header.tsx: -------------------------------------------------------------------------------- 1 | import { NavData } from "../types.ts"; 2 | 3 | export default function (data: Lume.Data) { 4 | return ( 5 |
6 | 7 | 8 | 9 | 22 | 23 | deno.com 24 | 25 | 26 | 27 |
28 | ); 29 | } 30 | 31 | export const css = "@import './_components/Header.css';"; 32 | -------------------------------------------------------------------------------- /_components/HeaderAnchor.tsx: -------------------------------------------------------------------------------- 1 | export function HeaderAnchor(props: { id: string }) { 2 | return ( 3 | 4 | Jump to heading 5 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /_components/MainNav.css: -------------------------------------------------------------------------------- 1 | .main-nav { 2 | display: flex; 3 | flex-direction: column; 4 | margin: 0.5rem 0.5rem 1rem; 5 | padding: 0.5rem; 6 | border-radius: 0.5rem; 7 | border: 1px solid hsl(var(--background-tertiary)); 8 | background-color: hsl(var(--background-secondary)); 9 | list-style: none; 10 | } 11 | 12 | .main-nav-link { 13 | display: block; 14 | padding: 0.5rem 0.75rem; 15 | border-radius: 0.25rem; 16 | color: hsl(var(--foreground-primary)); 17 | &:hover { 18 | background-color: hsl(var(--background-tertiary)); 19 | text-decoration: none; 20 | } 21 | } 22 | 23 | .main-nav-link[data-active] { 24 | font-weight: bold; 25 | background-color: hsl(var(--background-tertiary)); 26 | } 27 | 28 | @media (min-width: 1024px) { 29 | .main-nav { 30 | display: none; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /_components/MainNav.tsx: -------------------------------------------------------------------------------- 1 | import { NavData } from "../types.ts"; 2 | 3 | export default function (data: Lume.Data) { 4 | return ( 5 | 22 | ); 23 | } 24 | 25 | export const css = "@import './_components/MainNav.css';"; 26 | -------------------------------------------------------------------------------- /_components/Navigation.css: -------------------------------------------------------------------------------- 1 | .nav { 2 | height: 100%; 3 | border-right: 1px solid hsl(var(--foreground-tertiary)); 4 | font-size: 0.8rem; 5 | background-color: hsl(var(--background-primary)); 6 | overflow-y: auto; 7 | scrollbar-width: thin; 8 | z-index: 3; 9 | } 10 | 11 | @media (max-width: 1023px) { 12 | .nav { 13 | position: fixed; 14 | top: 4rem; 15 | width: 100%; 16 | max-width: 650px; 17 | transition: transform 200ms ease-in-out; 18 | transform: translateX(-100%); 19 | background-color: hsl(var(--background-primary)); 20 | } 21 | 22 | .hamburger-label { 23 | position: fixed; 24 | top: 1rem; 25 | left: 1rem; 26 | } 27 | 28 | .hamburger-checkbox:checked + .nav { 29 | transform: translateX(0); 30 | box-shadow: 350px 0px 0px 0px rgba(0, 0, 0, 0.5); 31 | } 32 | } 33 | 34 | @media (min-width: 1024px) { 35 | .nav { 36 | position: sticky; 37 | top: 4rem; 38 | height: calc(100vh - 4rem); 39 | overflow-y: auto; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /_components/RefHeader.css: -------------------------------------------------------------------------------- 1 | .refheader { 2 | position: sticky; 3 | top: calc(4rem - 1px); 4 | padding: 0.5rem; 5 | padding-left: 0; 6 | background-color: hsl(var(--background-secondary)); 7 | border-bottom: 1px solid hsl(var(--foreground-tertiary)); 8 | z-index: 5; 9 | } 10 | 11 | .refheader-link[data-active] { 12 | color: hsl(var(--primary)); 13 | } 14 | 15 | .nav[data-section="api"] { 16 | height: calc(100vh - 6.5rem); 17 | top: 6.5rem; 18 | padding-top: 0.5rem; 19 | } 20 | 21 | /* putting other reference styles in here for now until they are moved out into components*/ 22 | 23 | .refcrumbs { 24 | position: sticky; 25 | top: 6.5rem; 26 | width: 100%; 27 | padding: 1rem; 28 | padding-left: 0 !important; 29 | margin: 0; 30 | background-color: hsl(var(--background-primary)); 31 | z-index: 2; 32 | } 33 | -------------------------------------------------------------------------------- /_components/SearchInput.css: -------------------------------------------------------------------------------- 1 | .search { 2 | margin-bottom: 0; 3 | } 4 | 5 | .search-input { 6 | width: 100%; 7 | min-width: 10rem; 8 | border-radius: 0.5rem; 9 | font-size: 0.875rem; 10 | line-height: 1.5rem; 11 | padding: 0.375rem 0.75rem 0.375rem 0.5rem; 12 | padding-left: 2em; 13 | border: 1px solid; 14 | transition: all 150ms ease-in-out; 15 | background: url(/img/search.svg) no-repeat 0.5em 50%; 16 | background-size: 1em; 17 | background-color: hsl(var(--foreground-quaternary)); 18 | color: hsl(var(--foreground-primary)); 19 | border-color: hsl(var(--foreground-tertiary)); 20 | &:hover, &:focus { 21 | background-color: hsl(var(--background-secondary)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /_components/SearchInput.tsx: -------------------------------------------------------------------------------- 1 | export default function SearchInput() { 2 | return ( 3 | <> 4 |
10 | 17 | 18 |
19 | 20 | ); 21 | } 22 | 23 | export const css = `@import "./_components/SearchInput.css";`; 24 | -------------------------------------------------------------------------------- /_components/TabItem.tsx: -------------------------------------------------------------------------------- 1 | export default function TabItem() { 2 | return
; 3 | } 4 | -------------------------------------------------------------------------------- /_components/TableOfContents.tsx: -------------------------------------------------------------------------------- 1 | import type { TableOfContentsItem as TableOfContentsItem_ } from "../types.ts"; 2 | 3 | export default function TableOfContents({ data, toc }: { 4 | data: Lume.Data; 5 | toc: TableOfContentsItem_[]; 6 | }) { 7 | if (!toc || toc.length === 0) { 8 | return null; 9 | } 10 | 11 | return ( 12 | 17 | ); 18 | } 19 | 20 | export const css = `@import './_components/TableOfContents.css';`; 21 | -------------------------------------------------------------------------------- /_components/TableOfContentsItem.tsx: -------------------------------------------------------------------------------- 1 | import type { TableOfContentsItem as TableOfContentsItem_ } from "../types.ts"; 2 | 3 | export default function TableOfContentsItem( 4 | props: { item: TableOfContentsItem_ }, 5 | ) { 6 | return ( 7 |
  • 8 | 12 | {props.item.text.replaceAll(/ \([0-9/]+?\)/g, "")} 13 | 14 | {props.item.children.length > 0 && ( 15 | 20 | )} 21 |
  • 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /_components/TableOfContentsMobile.tsx: -------------------------------------------------------------------------------- 1 | import type { TableOfContentsItem as TableOfContentsItem_ } from "../types.ts"; 2 | 3 | export default function TableOfContents({ data, toc }: { 4 | data: Lume.Data; 5 | toc: TableOfContentsItem_[]; 6 | }) { 7 | if (!toc || toc.length === 0) { 8 | return null; 9 | } 10 | 11 | return ( 12 |
    13 | 14 | 在当前页面 15 | 16 | 17 | 22 |
    23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /_components/Tabs.tsx: -------------------------------------------------------------------------------- 1 | export default function Tabs() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /_components/ThemeToggle.css: -------------------------------------------------------------------------------- 1 | .theme-toggle { 2 | flex-shrink: 0; 3 | height: 2.3rem; 4 | width: 2.3rem; 5 | font-size: 0; 6 | color: transparent; 7 | background: transparent no-repeat center; 8 | background-size: 1.5rem; 9 | cursor: pointer; 10 | border-radius: 0.25rem; 11 | border: 1px solid transparent; 12 | transition: all 200ms ease-in-out; 13 | color: hsl(var(--foreground-secondary)); 14 | &:hover { 15 | text-decoration: none; 16 | background-color: hsl(var(--background-secondary)); 17 | border-color: hsl(var(--background-tertiary)); 18 | } 19 | } 20 | 21 | .light .theme-toggle { 22 | background-image: url(/img/dark.svg); 23 | } 24 | 25 | .dark .theme-toggle { 26 | background-image: url(/img/light.svg); 27 | } 28 | -------------------------------------------------------------------------------- /_components/ThemeToggle.tsx: -------------------------------------------------------------------------------- 1 | export const css = "@import './_components/ThemeToggle.css';"; 2 | 3 | export default function () { 4 | return ( 5 | 13 | ); 14 | } 15 | 16 | export const js = ` 17 | import "/js/darkmode.client.js"; 18 | import "/js/darkmode-toggle.client.js"; 19 | `; 20 | -------------------------------------------------------------------------------- /_components/ToTop.tsx: -------------------------------------------------------------------------------- 1 | export default function ToTop() { 2 | return ( 3 | 4 | 5 | 返回顶部 6 | 7 | 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /_config-styleguide.ts: -------------------------------------------------------------------------------- 1 | // Further refine the global Lume config for this section of the site 2 | import site from "./_config.ts"; 3 | 4 | // Ignore everythig not in the styleguide folder 5 | site.ignore((path) => { 6 | return path.match(/^\/styleguide.*$/) === null; 7 | }); 8 | 9 | export default site; 10 | -------------------------------------------------------------------------------- /_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigation": [ 3 | { 4 | "name": "手册", 5 | "href": "/runtime/" 6 | }, 7 | { 8 | "name": "API 参考", 9 | "href": "/api/" 10 | }, 11 | { 12 | "name": "示例", 13 | "href": "/examples/" 14 | }, 15 | { 16 | "name": "部署", 17 | "href": "/deploy/manual/" 18 | }, 19 | { 20 | "name": "托管", 21 | "href": "/subhosting/manual/" 22 | } 23 | ], 24 | "sidebar": [ 25 | { 26 | "items": [ 27 | { 28 | "title": "deno.com", 29 | "href": "https://deno.com" 30 | } 31 | ] 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /_includes/raw.tsx: -------------------------------------------------------------------------------- 1 | export const layout = "layout.tsx"; 2 | 3 | export default function Raw(props: Lume.Data, helpers: Lume.Helpers) { 4 | const reference = props.url.startsWith("/api"); 5 | 6 | return ( 7 | <> 8 |
    9 | {props.children} 10 | {reference && } 11 |
    12 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /_includes/reference/allSymbols.tsx: -------------------------------------------------------------------------------- 1 | import type { AllSymbolsCtx } from "@deno/doc"; 2 | 3 | export const layout = "doc.tsx"; 4 | 5 | export default function AllSymbols( 6 | { comp, data }: { data: AllSymbolsCtx } & Lume.Data, 7 | _helpers: Lume.Helpers, 8 | ) { 9 | return ( 10 | 11 |
    12 | 13 |
    14 |
    15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /_includes/reference/index.tsx: -------------------------------------------------------------------------------- 1 | import type { IndexCtx } from "@deno/doc"; 2 | 3 | export const layout = "doc.tsx"; 4 | 5 | export default function Index( 6 | { data, comp }: { data: IndexCtx } & Lume.Data, 7 | _helpers: Lume.Helpers, 8 | ) { 9 | return ( 10 | 11 |
    12 | 13 | {data.module_doc && } 14 | {data.overview && 15 | } 16 |
    17 |
    18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /_includes/reference/symbol.tsx: -------------------------------------------------------------------------------- 1 | import type { SymbolPageCtx } from "@deno/doc"; 2 | export const layout = "doc.tsx"; 3 | 4 | export default function Symbol( 5 | { data, comp }: { data: SymbolPageCtx } & Lume.Data, 6 | _helpers: Lume.Helpers, 7 | ) { 8 | return ( 9 | 10 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /_includes/video.tsx: -------------------------------------------------------------------------------- 1 | export const layout = "doc.tsx"; 2 | 3 | export default function Raw(data: Lume.Data) { 4 | return ( 5 | <> 6 | 7 | 8 | {data.children} 9 | 10 |
    11 | 在示例页面 和我们的{" "} 12 | 13 | YouTube 频道 14 | 上查看更多视频。 15 |
    16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /copy.client.ts: -------------------------------------------------------------------------------- 1 | document.addEventListener("click", (event) => { 2 | const btn = (event.target as HTMLElement).closest("button[data-copy]"); 3 | 4 | if (!btn) { 5 | return; 6 | } 7 | 8 | let textToCopy = btn.getAttribute("data-copy") as string; 9 | 10 | // CLEAN COMMANDS: Remove leading spaces, $, and > from each line 11 | textToCopy = textToCopy.replace(/^[\$>\s]+/, ""); 12 | 13 | navigator?.clipboard?.writeText(textToCopy).then(() => { 14 | if (!btn) { 15 | return; 16 | } 17 | 18 | const copyIcon = btn.querySelector(".copy-icon"); 19 | const checkIcon = btn.querySelector(".check-icon"); 20 | 21 | if (copyIcon && checkIcon) { 22 | copyIcon.classList.add("hidden"); 23 | checkIcon.classList.remove("hidden"); 24 | 25 | setTimeout(() => { 26 | copyIcon.classList.remove("hidden"); 27 | checkIcon.classList.add("hidden"); 28 | }, 2000); 29 | } 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "path": "/runtime/manual/basics/testing/#test-definition-filtering", 4 | "title": "测试定义过滤", 5 | "content": "在测试内部,您有两种过滤选项。\n", 6 | "section": "Deno 中的测试", 7 | "category": "运行时" 8 | }, 9 | { 10 | "path": "/runtime/reference/cli/test/", 11 | "title": "deno test", 12 | "content": "使用 Deno 内置的测试运行器运行测试。\n", 13 | "section": "deno test", 14 | "category": "运行时" 15 | }, 16 | { 17 | "path": "/deploy/manual/pricing-and-limits/#tls-proxying", 18 | "title": "TLS 代理", 19 | "content": "对于到端口 443(用于 HTTPS 的端口)的出站连接,需要 TLS 终止。使用 Deno.connect 连接到这些端口是被禁止的。如果您需要建立到端口 443 的 TLS 连接,请改用 Deno.connectTls。fetch 不受此限制影响。\n此限制的存在是因为在未终止 TLS 的情况下连接到端口 443 通常用于 TLS-over-TLS 代理,根据我们的可接受使用政策,这在 Deno Deploy 上是禁止的。\n", 20 | "section": "定价和限制", 21 | "category": "部署" 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /deploy/docs-images/add_custom_domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/add_custom_domain.png -------------------------------------------------------------------------------- /deploy/docs-images/blank_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/blank_project.png -------------------------------------------------------------------------------- /deploy/docs-images/change_dns_records.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/change_dns_records.png -------------------------------------------------------------------------------- /deploy/docs-images/discord-slash-command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/discord-slash-command.png -------------------------------------------------------------------------------- /deploy/docs-images/dns_records_modal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/dns_records_modal.png -------------------------------------------------------------------------------- /deploy/docs-images/fauna1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/fauna1.png -------------------------------------------------------------------------------- /deploy/docs-images/fauna2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/fauna2.png -------------------------------------------------------------------------------- /deploy/docs-images/get_certificates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/get_certificates.png -------------------------------------------------------------------------------- /deploy/docs-images/green_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/green_check.png -------------------------------------------------------------------------------- /deploy/docs-images/neon_postgres_env_variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/neon_postgres_env_variable.png -------------------------------------------------------------------------------- /deploy/docs-images/new_github_repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/new_github_repo.png -------------------------------------------------------------------------------- /deploy/docs-images/organizations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/organizations.png -------------------------------------------------------------------------------- /deploy/docs-images/postgres_env_variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/postgres_env_variable.png -------------------------------------------------------------------------------- /deploy/docs-images/preview_deployment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/preview_deployment.png -------------------------------------------------------------------------------- /deploy/docs-images/project_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/project_name.png -------------------------------------------------------------------------------- /deploy/docs-images/promote_to_production.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/promote_to_production.png -------------------------------------------------------------------------------- /deploy/docs-images/proxy_to_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/proxy_to_example.png -------------------------------------------------------------------------------- /deploy/docs-images/vite-branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/vite-branch.png -------------------------------------------------------------------------------- /deploy/docs-images/vite-deploy-yaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/vite-deploy-yaml.png -------------------------------------------------------------------------------- /deploy/docs-images/vite-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/vite-link.png -------------------------------------------------------------------------------- /deploy/docs-images/vite-ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/vite-ok.png -------------------------------------------------------------------------------- /deploy/docs-images/vite-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/docs-images/vite-project.png -------------------------------------------------------------------------------- /deploy/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/index.md -------------------------------------------------------------------------------- /deploy/kv/manual/_admonition.tsx: -------------------------------------------------------------------------------- 1 | export function Admonition({ type, children }) { 2 | return
    TODO
    ; 3 | } 4 | 5 | // :::caution Deno KV is currently in beta 6 | 7 | // Deno KV and related cloud primitive APIs like queues and cron are currently 8 | // **experimental** and **subject to change**. While we do our best to ensure data 9 | // durability, data loss is possible, especially around Deno updates. 10 | 11 | // Deno programs that use KV require the `--unstable` flag when launching the 12 | // program, as shown below: 13 | 14 | // ```sh 15 | // deno run -A --unstable my_kv_code.ts 16 | // ``` 17 | 18 | // ::: 19 | -------------------------------------------------------------------------------- /deploy/kv/manual/images/backup-add-bucket-to-dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/backup-add-bucket-to-dash.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/backup-bucket-create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/backup-bucket-create.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/backup-gcs-bucket-create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/backup-gcs-bucket-create.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/backup-gcs-create-hmac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/backup-gcs-create-hmac.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/backup-gcs-grant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/backup-gcs-grant.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/cron-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/cron-tasks.png -------------------------------------------------------------------------------- /deploy/kv/manual/images/kv-connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/manual/images/kv-connect.png -------------------------------------------------------------------------------- /deploy/kv/tutorials/images/github_webhook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/kv/tutorials/images/github_webhook.png -------------------------------------------------------------------------------- /deploy/manual/acceptable-use-policy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "可接受使用政策" 3 | --- 4 | 5 | Deno Deploy 服务包含的资源(CPU 6 | 时间、请求次数)受此可接受使用政策的约束。本文档可以大致估算我们认为是“可接受使用”的内容,以及我们不接受的内容。 7 | 8 | ### 可接受使用示例 9 | 10 | - ✅ 服务器端渲染的网站 11 | - ✅ Jamstack 站点和应用 12 | - ✅ 单页应用程序 13 | - ✅ 查询数据库或外部 API 的 API 14 | - ✅ 个人博客 15 | - ✅ 公司网站 16 | - ✅ 电子商务网站 17 | - ✅ 反向代理 18 | 19 | ### 不可接受使用 20 | 21 | - ❌ 加密货币挖矿 22 | - ❌ 高度 CPU 密集型负载(例如机器学习) 23 | - ❌ 为外部站点托管媒体 24 | - ❌ 爬虫 25 | - ❌ 正向代理 26 | - ❌ VPN 27 | 28 | ## 指南 29 | 30 | 我们预计大多数项目都会在使用限制范围内。如果您的项目使用情况显著偏离常态,我们将通知您。在采取任何行动以解决对我们基础设施的不合理负担之前,我们将在可能的情况下与您联系。 31 | -------------------------------------------------------------------------------- /deploy/manual/fulfillment-policy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "履行政策" 3 | --- 4 | 5 | ## 退款政策 6 | 7 | 在 Deno 8 | Deploy,我们致力于提供卓越的服务。如果您对我们的服务不满意,您可以在以下条件下申请退款: 9 | 10 | 退款必须在首次购买或升级任何订阅计划后的 14 11 | 天内提出。如果服务无法正常运行,并且我们的支持团队无法在合理的时间内解决问题,则可能会考虑退款。对于违反我们服务条款使用的服务,或明显归因于用户错误或外部平台更改的问题,将不予退款。定期订阅可以取消,但只有在 12 | 14 天内提出请求时,才有资格获得初始计费周期的退款。 13 | 14 | ## 取消政策 15 | 16 | 您可以在以下条款下随时取消您的 Deno Deploy 订阅: 17 | 18 | 订阅取消立即生效,服务将继续运行直到当前计费周期结束。要取消您的订阅,请导航至 19 | Deno Deploy 20 | 仪表板中的账户设置,然后选择“取消订阅”。一旦订阅被取消,将不会产生进一步费用,但您需负责在取消生效日期之前产生的任何费用。如需了解更多关于我们履行政策的信息,或需要帮助,请联系我们的支持团队 21 | [deploy@deno.com](mailto:deploy@deno.com)。 22 | -------------------------------------------------------------------------------- /deploy/manual/how-to-deploy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "通过 GitHub 集成部署" 3 | --- 4 | 5 | 部署更复杂项目的最简单方法是通过我们的 Github 集成。 这允许你将 Deno Deploy 6 | 项目链接到 GitHub 仓库。每次你推送到仓库时,你的更改将自动部署。 7 | 8 | 通过 Github 集成,你可以添加一个 Github Action,在部署过程中定义构建步骤。 9 | 10 | 有关更多详细信息,请参阅 [Github 集成页面](ci_github)。 11 | 12 | ### 使用 [`deployctl`](./deployctl.md) 从命令行部署 13 | 14 | `deployctl` 是一个命令行工具,用于将你的代码部署到 Deno Deploy。通过使用 15 | `deployctl`,你可以比上述自动 GitHub 集成更详细地控制部署。 16 | 17 | 有关更多详细信息,请参阅 [`deployctl` 页面](./deployctl.md)。 18 | 19 | ### 通过 playground 部署 20 | 21 | 部署代码的最简单方法是通过 Deno Deploy playground。 22 | 23 | 有关更多详细信息,请参阅 [playground 页面](playgrounds)。 24 | -------------------------------------------------------------------------------- /deploy/manual/images/deploy_onboarding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/manual/images/deploy_onboarding.png -------------------------------------------------------------------------------- /deploy/manual/images/deployctl-deployments-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/manual/images/deployctl-deployments-list.png -------------------------------------------------------------------------------- /deploy/manual/images/deployctl-deployments-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/manual/images/deployctl-deployments-show.png -------------------------------------------------------------------------------- /deploy/manual/images/project_deployments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/manual/images/project_deployments.png -------------------------------------------------------------------------------- /deploy/manual/logs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "应用日志记录" 3 | --- 4 | 5 | 应用程序可以在运行时使用控制台 API 生成日志,例如使用 6 | `console.log`、`console.error` 等方法。这些日志可以通过以下方式实时查看: 7 | 8 | - 导航到项目或部署的 `Logs` 面板。 9 | - 使用 [deployctl](https://docs.denohub.com/deploy/manual/deployctl) 中的 `logs` 10 | 子命令。 11 | 12 | 日志将直接从应用程序流式传输到日志面板,或在 `deployctl logs` 中显示。 13 | 14 | 除了实时日志外,日志还会保留一定的时间,具体取决于您所订阅的计划。要查看持久化的日志,您可以: 15 | 16 | - 如果您在浏览器中使用日志面板,请在搜索框旁边的下拉菜单中从 `Live` 切换到 17 | `Recent` 或 `Custom`。 18 | - 如果您更喜欢命令行,请在 `deployctl logs` 命令中添加 `--since=` 19 | 和/或 `--until=`。更多详细信息,请参考 `deployctl logs --help`。 20 | 21 | 超过保留期限的日志会自动从系统中删除。 22 | 23 | ## 限制 24 | 25 | 日志消息的大小和在一定时间内生成的日志量都有所限制。 26 | 27 | 日志消息的最大大小为 2KB。超过此限制的消息将被截断为 2KB。 28 | 29 | 每个部署每秒最多允许生成 1000 条日志条目。如果超过此限制,我们可能会终止该部署。 30 | -------------------------------------------------------------------------------- /deploy/manual/middleware.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "反向代理中间件" 3 | --- 4 | 5 | 本快速入门将介绍如何部署一小段中间件,该中间件反向代理另一台服务器(在本例中为 6 | example.com)。有关常见中间件功能的更多示例,请参阅 7 | [示例库](../tutorials/index.md)。 8 | 9 | ## **步骤 1:** 在 Deno Deploy 上创建一个新的 playground 项目 10 | 11 | 导航到 https://dash.deno.com/projects 并点击“New Playground”按钮。 12 | 13 | ## **步骤 2:** 通过 playground 部署中间件代码 14 | 15 | 在下一页中,将以下代码复制并粘贴到编辑器中。这是一个 HTTP 16 | 服务器,它将所有请求代理到 https://example.com。 17 | 18 | ```ts 19 | async function reqHandler(req: Request) { 20 | const reqPath = new URL(req.url).pathname; 21 | return await fetch("https://example.com" + reqPath, { headers: req.headers }); 22 | } 23 | 24 | Deno.serve(reqHandler); 25 | ``` 26 | 27 | 点击 **保存并部署**。 28 | 29 | 您应该会看到类似以下内容: 30 | 31 | ![图片](../docs-images/proxy_to_example.png) 32 | -------------------------------------------------------------------------------- /deploy/manual/organizations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "组织" 3 | --- 4 | 5 | **组织** 6 | 允许您与其他用户协作。在组织中创建的项目对该组织的所有成员都可访问。用户应首先注册 7 | Deno Deploy,然后才能被添加到组织中。 8 | 9 | 目前,所有组织成员都拥有对组织的完全访问权限。他们可以添加/删除成员,并创建/删除/修改组织中的所有项目。 10 | 11 | ### 创建组织 12 | 13 | 1. 在您的 Deploy 仪表板上,点击屏幕左上角导航栏中的组织下拉菜单。 14 | ![组织](../docs-images/organizations.png) 15 | 2. 选择 **组织 +**。 16 | 3. 输入您的组织名称,然后点击 **创建**。 17 | 18 | ### 添加成员 19 | 20 | 1. 在屏幕左上角导航栏中的组织下拉菜单中选择所需的组织。 21 | 2. 点击 **成员** 图标按钮。 22 | 3. 在 **成员** 面板下,点击 **+ 邀请成员**。 23 | > **注意:** 用户应首先使用 [此链接](https://dash.deno.com/signin) 注册 Deno 24 | > Deploy,然后您才能邀请他们。 25 | 4. 输入用户的 GitHub 用户名,然后点击 **邀请**。 26 | 27 | Deploy 28 | 将向用户发送邀请邮件。他们可以选择接受或拒绝您的邀请。一旦他们接受邀请,他们就会被添加到您的组织中,并显示在成员面板中。 29 | 30 | 待处理的邀请显示在 **邀请** 31 | 面板中。您可以通过点击待处理邀请旁边的删除图标来撤销邀请。 32 | 33 | ### 移除成员 34 | 35 | 1. 在屏幕左上角导航栏中的组织下拉菜单中选择所需的组织。 36 | 2. 点击 **成员** 图标按钮。 37 | 3. 在 **成员** 面板中,点击您要移除的用户旁边的删除按钮。 38 | -------------------------------------------------------------------------------- /deploy/manual/pricing-and-limits.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "定价与限制" 3 | --- 4 | 5 | 请参阅 [我们的定价页面](https://deno.com/deploy/pricing) 6 | 以了解所有计划中可用功能的概述。如果您有超出这些限制的用例,[请联系我们](mailto:deploy@deno.com)。 7 | 8 | 在 Deno Deploy 的初始公开测试期间,不提供正常运行时间保证。服务的访问将受 9 | [我们的可接受使用政策](/deploy/manual/acceptable-use-policy) 10 | 控制。任何我们认为违反此政策的用户,其账户可能会被终止。 11 | 12 | ## 部署的最大大小 13 | 14 | 在上传资源到部署时,部署中所有文件(源文件和静态文件)的总大小 **不应超过 15 | 1GB**。 16 | 17 | ## 内存分配 18 | 19 | 应用程序的最大内存分配为 512MB 20 | 21 | ## TLS 代理 22 | 23 | 对于到端口 443(用于 HTTPS 的端口)的出站连接,需要 TLS 终止。使用 24 | [Deno.connect](https://docs.denohub.com/api/deno/~/Deno.connect) 25 | 连接到这些端口是被禁止的。如果您需要建立到端口 443 的 TLS 连接,请使用 26 | [Deno.connectTls](https://docs.denohub.com/api/deno/~/Deno.connectTls) 27 | 代替。`fetch` 不受此限制的影响。 28 | 29 | 此限制的存在是因为在没有终止 TLS 的情况下连接到端口 443 通常用于 TLS-over-TLS 30 | 代理,而根据 [我们的可接受使用政策](/deploy/manual/acceptable-use-policy),这在 31 | Deno Deploy 上是禁止的。 32 | -------------------------------------------------------------------------------- /deploy/manual/regions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "区域" 3 | --- 4 | 5 | Deno Deploy 6 | 在全球范围内部署您的代码。每个新请求都会从最接近用户的区域提供服务。目前,Deploy 7 | 位于以下区域: 8 | 9 | - 新加坡 (`asia-southeast1`) 10 | - 伦敦 (`europe-west2`) 11 | - 法兰克福 (`europe-west3`) 12 | - 圣保罗 (`southamerica-east1`) 13 | - 北弗吉尼亚 (`us-east4`) 14 | - 加利福尼亚 (`us-west2`) 15 | 16 | 此列表将不断更新,以反映我们区域的最新概况。 17 | 18 | 代码将部署到所有区域,并从最接近最终用户的区域提供服务,以最小化延迟。目前无法限制代码部署的区域。 19 | -------------------------------------------------------------------------------- /deploy/manual/running-scripts-locally.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "本地开发" 3 | --- 4 | 5 | 对于本地开发,你可以使用 `deno` CLI。要安装 `deno`,请按照 6 | [Deno 手册](https://deno.land/manual/getting_started/installation) 7 | 中的说明进行操作。 8 | 9 | 安装完成后,你可以在本地运行你的脚本: 10 | 11 | ```shell 12 | $ deno run --allow-net=:8000 https://deno.com/examples/hello.js 13 | Listening on http://localhost:8000 14 | ``` 15 | 16 | 要监听文件更改,请添加 `--watch` 标志: 17 | 18 | ```shell 19 | $ deno run --allow-net=:8000 --watch ./main.js 20 | Listening on http://localhost:8000 21 | ``` 22 | 23 | 有关 Deno CLI 的更多信息,以及如何配置你的开发环境和 IDE,请访问 Deno 手册的 24 | [入门][manual-gs] 部分。 25 | 26 | [manual-gs]: https://deno.land/manual/getting_started 27 | -------------------------------------------------------------------------------- /deploy/manual/security.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "安全与负责任披露" 3 | --- 4 | 5 | 我们将系统安全及由这些系统控制的所有数据视为重中之重。无论我们在系统安全上投入多少努力,仍可能存在安全漏洞。我们赞赏由善意、道德的安全研究人员进行的系统安全调查工作。如果您发现了一个漏洞,无论多小,我们都希望了解,以便尽快采取适当措施加以解决。本页概述了我们与安全研究社区合作解决系统安全的方法。 6 | 7 | ## 报告漏洞 8 | 9 | 请将您的发现通过电子邮件发送至 10 | security@deno.com。我们致力于尽快解决所有问题,并非常乐意在问题解决后积极参与撰写报告的发布。 11 | 12 | ## 请遵循以下事项: 13 | 14 | - 不要利用您发现的漏洞或问题。例如,仅下载为演示漏洞所需的数据——不要下载更多内容。同时,不要删除、修改或查看他人的数据。 15 | - 在问题解决之前,不要公开或透露该问题。 16 | - 不要使用物理安全攻击、社会工程、分布式拒绝服务、垃圾邮件或第三方应用程序。 17 | - 请提供足够的信息以重现问题,以便我们能够尽快解决。通常,受影响系统的 IP 地址或 18 | URL 以及漏洞描述就足够了,但复杂的漏洞可能需要进一步解释。 19 | 20 | ## 我们的承诺 21 | 22 | - 如果您按照本政策行事,我们将不会就您的报告对您采取法律行动。 23 | - 我们将严格保密处理您的报告,并在未经您许可的情况下不会将您的个人信息透露给第三方。 24 | -------------------------------------------------------------------------------- /deploy/manual/use-cases.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Deno Deploy 使用案例" 3 | --- 4 | 5 | 目前 Deno 的一些流行使用案例包括: 6 | 7 | - [中间件](#中间件) 8 | - [API 服务器](#api-服务器) 9 | - [完整网站](#完整网站) 10 | 11 | ## 中间件 12 | 13 | 中间件是指在请求到达应用服务器之前和之后执行的一些代码片段。如果你想在请求的早期快速执行一些 14 | JavaScript 或其他代码,你将会编写中间件。通过在边缘部署你的中间件代码,Deno 15 | Deploy 确保你的应用获得最佳性能。 16 | 17 | 一些例子包括: 18 | 19 | - 设置 cookie 20 | - 根据地理位置提供不同版本的网站 21 | - 路径重写 22 | - 重定向请求 23 | - 在服务器返回 HTML 到用户之前动态修改 HTML 24 | 25 | Deno Deploy 是你目前可能用于托管中间件的其他平台的一个很好的替代品,例如: 26 | 27 | - Cloudflare Workers 28 | - AWS Lambda@Edge 29 | - 传统的负载均衡器如 nginx 30 | - 自定义规则 31 | 32 | ## API 服务器 33 | 34 | Deno 也非常适合用于 API 35 | 服务器。通过在“边缘”部署这些服务器,更接近使用它们的客户端,Deno Deploy 36 | 能够提供比传统托管平台(如 Heroku)甚至现代集中式托管服务(如 37 | DigitalOcean)更低的延迟、更好的性能和更低的带宽成本。 38 | 39 | ## 完整网站 40 | 41 | 我们预见到一个未来,你实际上可以在边缘函数上编写整个网站。一些已经在这样做的网站例子包括: 42 | 43 | - [博客](https://github.com/ry/tinyclouds) 44 | - [聊天](https://github.com/denoland/showcase_chat) 45 | - [calendly 克隆](https://github.com/denoland/meet-me) 46 | -------------------------------------------------------------------------------- /deploy/tutorials/images/simple_api_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/tutorials/images/simple_api_dashboard.png -------------------------------------------------------------------------------- /deploy/tutorials/images/simple_api_deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/tutorials/images/simple_api_deploy.png -------------------------------------------------------------------------------- /deploy/tutorials/images/simple_api_deploy_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/deploy/tutorials/images/simple_api_deploy_settings.png -------------------------------------------------------------------------------- /deploy/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "教程" 3 | sidebar_title: "概览" 4 | pagination_next: /deploy/tutorials/tutorial-http-server 5 | --- 6 | 7 | 在这里,您将找到 Deno Deploy 8 | 的教程和示例应用程序集合。查看我们不断扩展的教程列表,并访问 9 | [examples.deno.land](https://examples.deno.land) 获取更多内容。 10 | 11 | ## 代码示例 12 | 13 | - [构建一个简单的 API 服务器](./simple-api.md) 14 | - [提供静态资源](./static-site.md) 15 | 16 | ## 应用构建教程 17 | 18 | - [构建一个 Fresh 应用](./fresh.md) 19 | - [构建一个 Discord 斜杠命令](./discord-slash.md) 20 | - [使用 Vite 构建一个站点](./vite.md) 21 | -------------------------------------------------------------------------------- /deploy/tutorials/tutorial-blog-fresh.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "使用 Fresh 构建博客" 3 | oldUrl: 4 | - /deploy/docs/tutorial-blog-fresh/ 5 | --- 6 | 7 | 教程 [在此](https://deno.com/blog/build-a-blog-with-fresh)。 8 | -------------------------------------------------------------------------------- /deploy/tutorials/tutorial-hugo-blog.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "使用 Hugo 构建博客" 3 | oldUrl: 4 | - /deploy/docs/tutorial-hugo-blog/ 5 | --- 6 | 7 | 教程 [在此](https://deno.com/blog/hugo-blog-with-deno-deploy)。 8 | -------------------------------------------------------------------------------- /examples/_components/CopyButton.tsx: -------------------------------------------------------------------------------- 1 | export function CopyButton(props: { text: string }) { 2 | return ( 3 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /examples/_components/ExampleIcon.tsx: -------------------------------------------------------------------------------- 1 | export function ExampleIcon() { 2 | return ( 3 | 8 | 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /examples/_components/TutorialIcon.tsx: -------------------------------------------------------------------------------- 1 | export function TutorialIcon() { 2 | return ( 3 | 8 | 16 | 24 | 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /examples/_pages/VideoPage.tsx: -------------------------------------------------------------------------------- 1 | import { EmbedVideo } from "../_components/EmbedVideo.tsx"; 2 | import { VideoReference } from "../types.ts"; 3 | 4 | type Props = { video: VideoReference }; 5 | 6 | export default function VideoPage({ video }: Props) { 7 | return ( 8 | <> 9 | 10 |
    11 | 在示例页面 和我们的{" "} 12 | 13 | YouTube 频道 14 | 上找到更多视频。 15 |
    16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /examples/_pages/examples_test.ts: -------------------------------------------------------------------------------- 1 | import { join } from "@std/path"; 2 | import { walk } from "@std/fs"; 3 | import { assertEquals, assertNotMatch } from "@std/assert"; 4 | 5 | const decoder = new TextDecoder(); 6 | 7 | Deno.test("Check examples", async (t) => { 8 | for await (const item of walk("./examples/scripts/")) { 9 | const path = join("examples/scripts", item.name); 10 | 11 | if (!path.endsWith(".ts")) continue; 12 | 13 | await t.step("Check graph: " + path, async () => { 14 | const result = await new Deno.Command(Deno.execPath(), { 15 | args: ["info", path], 16 | }).output(); 17 | assertEquals(result.code, 0); 18 | assertNotMatch(decoder.decode(result.stdout), /\(resolve error\)/); 19 | }); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /examples/index.tsx: -------------------------------------------------------------------------------- 1 | export const layout = "raw.tsx"; 2 | 3 | export const toc = []; 4 | 5 | export default function* ( 6 | data: Lume.Data, 7 | ) { 8 | yield { 9 | url: `/examples/`, 10 | title: `Deno 示例和教程`, 11 | content: , 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /examples/scripts/deno_version.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Getting the Deno version 3 | * @difficulty beginner 4 | * @tags cli 5 | * @run 6 | * @resource {https://docs.denohub.com/api/deno/~/Deno.version} Doc: Deno.version 7 | * @group CLI 8 | * 9 | * How to examine the version of Deno being used. 10 | */ 11 | 12 | // To print the current version of Deno, just reach into the Deno global object 13 | // where all non-web-standard APIs reside. 14 | console.log("Current Deno version", Deno.version.deno); 15 | 16 | // Deno has two main dependencies: the V8 JavaScript engine (from the Chrome web 17 | // browser) and the TypeScript compiler. The versions of these are also 18 | // accessible in the `Deno.version` object. 19 | console.log("Current TypeScript version", Deno.version.typescript); 20 | console.log("Current V8 version", Deno.version.v8); 21 | -------------------------------------------------------------------------------- /examples/scripts/hello_world.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Hello world 3 | * @difficulty beginner 4 | * @tags cli, deploy, web 5 | * @run 6 | * @resource {https://docs.denohub.com/runtime/manual/getting_started/installation} Deno: Installation 7 | * @resource {https://docs.denohub.com/runtime/manual/getting_started/setup_your_environment} Manual: Set up your environment 8 | * @group Basics 9 | * @sortOrder 0 10 | * The one and only line in this program will print "Hello, World!" to the console. Run this file with the Deno CLI and the run command. 11 | */ 12 | 13 | // Log "Hello, World!" to the console. 14 | console.log("Hello, World!"); 15 | -------------------------------------------------------------------------------- /examples/scripts/hono.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Hono HTTP server 3 | * @difficulty intermediate 4 | * @tags cli, deploy 5 | * @run --allow-net 6 | * @resource {https://jsr.io/@hono/hono} Hono on jsr.io 7 | * @resource {https://hono.dev/docs} Hono documentation 8 | * @group Network 9 | * 10 | * An example of a HTTP server that uses the Hono framework. 11 | */ 12 | 13 | // Import the Hono framework 14 | import { Hono } from "jsr:@hono/hono"; 15 | 16 | // Create a new Hono server 17 | const app = new Hono(); 18 | 19 | // Define a route that responds with "Hello, World!" 20 | // The first argument is the path, the second is the request handler 21 | app.get("/", (c) => c.text("Hello, World!")); 22 | 23 | // Call Deno.serve with the request handler to start the server on the default port (8000) 24 | Deno.serve(app.fetch); 25 | 26 | // Test the server with: curl http://localhost:8000 27 | // Should output "Hello, World!" 28 | 29 | // Read more about Hono with Deno at https://hono.dev/docs/getting-started/deno 30 | -------------------------------------------------------------------------------- /examples/scripts/http_server.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title HTTP Server: Hello world 3 | * @difficulty intermediate 4 | * @tags cli, deploy 5 | * @run --allow-net 6 | * @resource {https://docs.denohub.com/api/deno/~/Deno.serve} Doc: Deno.serve 7 | * @resource {https://developer.mozilla.org/zh-CN/docs/Web/API/Response} MDN: Response 8 | * @playground https://dash.deno.com/playground/example-helloworld 9 | * @group Network 10 | * 11 | * An example of a HTTP server that serves a "Hello World" message. 12 | */ 13 | 14 | // HTTP servers need a handler function. This function is called for every 15 | // request that comes in. It must return a `Response`. The handler function can 16 | // be asynchronous (it may return a `Promise`). 17 | function handler(_req: Request): Response { 18 | return new Response("Hello, World!"); 19 | } 20 | 21 | // To start the server on the default port, call `Deno.serve` with the handler. 22 | Deno.serve(handler); 23 | -------------------------------------------------------------------------------- /examples/scripts/importing_json.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Importing JSON 3 | * @difficulty beginner 4 | * @tags cli, web 5 | * @run 6 | * @group Encoding 7 | * 8 | * JSON files can be imported in JS and TS files using the `import` keyword. 9 | * This makes including static data in a library much easier. 10 | */ 11 | 12 | // File: ./main.ts 13 | 14 | // JSON files can be imported in JS and TS modules. When doing so, you need to 15 | // specify the "json" import assertion type. 16 | import file from "./version.json" with { type: "json" }; 17 | console.log(file.version); 18 | 19 | // Dynamic imports are also supported. 20 | const module = await import("./version.json", { 21 | with: { type: "json" }, 22 | }); 23 | console.log(module.default.version); 24 | 25 | /* File: ./version.json 26 | { 27 | "version": "1.0.0" 28 | } 29 | */ 30 | -------------------------------------------------------------------------------- /examples/scripts/node_built_in.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Use Node.js built-in modules 3 | * @difficulty beginner 4 | * @tags cli, deploy 5 | * @run --allow-env 6 | * @resource {https://docs.denohub.com/runtime/fundamentals/node} Node.js / npm support in Deno 7 | * @resource {https://docs.denohub.com/runtime/fundamentals/node/#node_specifiers} node: specifiers 8 | * @group Basics 9 | * 10 | * Deno supports most built-in Node.js modules natively - you can include them 11 | * in your code using "node:" specifiers in your imports. 12 | */ 13 | 14 | // Import the os module from core Node to get operating system info 15 | import os from "node:os"; 16 | 17 | // Use the module as you would in Node.js 18 | console.log("Current architecture is:", os.arch()); 19 | console.log("Home directory is:", os.homedir()); 20 | -------------------------------------------------------------------------------- /examples/scripts/pid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Process information 3 | * @difficulty beginner 4 | * @tags cli 5 | * @run 6 | * @group System 7 | */ 8 | 9 | // The current process's process ID is available in the `Deno.pid` variable. 10 | console.log(Deno.pid); 11 | 12 | // The parent process ID is available in the Deno namespace too. 13 | console.log(Deno.ppid); 14 | -------------------------------------------------------------------------------- /examples/scripts/postgres.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Connect to Postgres 3 | * @difficulty intermediate 4 | * @tags cli, deploy 5 | * @run --allow-net --allow-env 6 | * @group Databases 7 | * 8 | * Using the npm Postgres client, you can connect to a Postgres database 9 | * running anywhere. 10 | */ 11 | 12 | // Import the Postgres package from 13 | import postgres from "npm:postgres"; 14 | 15 | // Initialize the client with connection information for your database, and 16 | // create a connection. 17 | const sql = postgres({ 18 | user: "user", 19 | database: "test", 20 | hostname: "localhost", 21 | port: 5432, 22 | }); 23 | 24 | // Execute a SQL query 25 | const result = await sql` 26 | SELECT ID, NAME FROM PEOPLE 27 | `; 28 | console.log(result); 29 | 30 | // Close the connection to the database 31 | await sql.end(); 32 | -------------------------------------------------------------------------------- /examples/scripts/tcp_connector.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title TCP connector: Ping 3 | * @difficulty intermediate 4 | * @tags cli 5 | * @run --allow-net 6 | * @resource {https://docs.denohub.com/api/deno/~/Deno.connect} Doc: Deno.connect 7 | * @resource {/examples/tcp_listener} Example: TCP Listener 8 | * @group Network 9 | * 10 | * An example of connecting to a TCP server on localhost and writing a 'ping' message to the server. 11 | */ 12 | 13 | // Instantiate an instance of text encoder to write to the TCP stream. 14 | const encoder = new TextEncoder(); 15 | // Establish a connection to our TCP server that is currently being run on localhost port 8080. 16 | const conn = await Deno.connect({ 17 | hostname: "127.0.0.1", 18 | port: 8080, 19 | transport: "tcp", 20 | }); 21 | // Encode the 'ping' message and write to the TCP connection for the server to receive. 22 | await conn.write(encoder.encode("ping")); 23 | -------------------------------------------------------------------------------- /examples/scripts/typescript_support.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Built-in TypeScript support 3 | * @difficulty beginner 4 | * @tags cli, deploy 5 | * @run 6 | * @resource {https://www.typescriptlang.org/docs/handbook/intro.html} TypeScript handbook 7 | * @group Basics 8 | * 9 | * Deno natively understands TypeScript code with no compiler to configure. 10 | * Start writing code in .ts files, and the runtime will work with them just 11 | * fine. 12 | */ 13 | 14 | // Define an interface in TypeScript 15 | interface Person { 16 | name: string; 17 | age: number; 18 | } 19 | 20 | // Provide a typed input to a function 21 | function greet(person: Person) { 22 | return "Hello, " + person.name + "!"; 23 | } 24 | 25 | // Everything works with zero config! 26 | console.log(greet({ name: "Alice", age: 36 })); 27 | -------------------------------------------------------------------------------- /examples/scripts/unzip_gzipped_file.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @title Unzip gzipped file 3 | * @difficulty beginner 4 | * @tags cli, deploy 5 | * @run --allow-write --allow-read 6 | * @group File System 7 | * 8 | * An example of how to decompress a gzipped file and save it to disk. 9 | */ 10 | 11 | // Open the gzipped file for reading 12 | const file = await Deno.open("large_file.json.gz"); 13 | 14 | // Create a new file to write the decompressed data 15 | const outputPath = await Deno.create("large_file.json"); 16 | 17 | // Get the writable stream of the output file 18 | const writableStream = outputPath.writable; 19 | 20 | // Create a decompression stream for gzip format 21 | const stream = new DecompressionStream("gzip"); 22 | 23 | // Pipe the readable stream of the gzipped file through the decompression stream and then to the writable stream of the output file 24 | file.readable.pipeThrough(stream).pipeTo(writableStream); 25 | -------------------------------------------------------------------------------- /examples/tutorials/images/deno-educator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/deno-educator.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/astro/dynamic-page.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/astro/dynamic-page.webp -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/astro/hello-astro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/astro/hello-astro.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/astro/index-page.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/astro/index-page.webp -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/aws-lightsail/create-container-service-on-aws.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/aws-lightsail/create-container-service-on-aws.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/aws-lightsail/hello-world-from-deno-and-aws-lightsail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/aws-lightsail/hello-world-from-deno-and-aws-lightsail.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/aws-lightsail/hello-world-from-localhost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/aws-lightsail/hello-world-from-localhost.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/aws-lightsail/new-image-on-docker-hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/aws-lightsail/new-image-on-docker-hub.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/cloudflare-workers/main-on-cloudflare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/cloudflare-workers/main-on-cloudflare.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/digital-ocean/hello-from-deno-and-digital-ocean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/digital-ocean/hello-from-deno-and-digital-ocean.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/digital-ocean/hello-world-from-localhost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/digital-ocean/hello-world-from-localhost.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/digital-ocean/new-deno-image-on-digital-ocean-container-registry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/digital-ocean/new-deno-image-on-digital-ocean-container-registry.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/drizzle/table-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/drizzle/table-diagram.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/google-cloud-run/hello-from-google-cloud-run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/google-cloud-run/hello-from-google-cloud-run.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/google-cloud-run/hello-world-from-localhost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/google-cloud-run/hello-world-from-localhost.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/google-cloud-run/image-in-google-artifact-registry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/google-cloud-run/image-in-google-artifact-registry.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/google-cloud-run/new-repository-in-google-artifact-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/google-cloud-run/new-repository-in-google-artifact-repository.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/next/dinoapp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/next/dinoapp.gif -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/nuxt/nuxt-1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/nuxt/nuxt-1.webp -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/nuxt/nuxt-2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/nuxt/nuxt-2.webp -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/nuxt/nuxt-3.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/nuxt/nuxt-3.mp4 -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/nuxt/nuxt-4.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/nuxt/nuxt-4.mp4 -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/prisma/1-dinosaurs-in-prisma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/prisma/1-dinosaurs-in-prisma.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/prisma/2-dinosaurs-from-api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/prisma/2-dinosaurs-from-api.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/prisma/3-new-dinosaur-in-prisma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/prisma/3-new-dinosaur-in-prisma.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/qwik/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/qwik/demo.mp4 -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/react/react-dinosaur-app-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/react/react-dinosaur-app-demo.gif -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/redis/cached-redis-body.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/redis/cached-redis-body.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/redis/cached-redis-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/redis/cached-redis-header.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/redis/uncached-redis-body.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/redis/uncached-redis-body.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/redis/uncached-redis-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/redis/uncached-redis-header.png -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/solidjs/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/solidjs/demo.mp4 -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/tanstack/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/tanstack/demo.mp4 -------------------------------------------------------------------------------- /examples/tutorials/images/how-to/vue/vue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/how-to/vue/vue.gif -------------------------------------------------------------------------------- /examples/tutorials/images/quick-fix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/quick-fix.png -------------------------------------------------------------------------------- /examples/tutorials/images/websockets.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/websockets.gif -------------------------------------------------------------------------------- /examples/tutorials/images/word_finder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/examples/tutorials/images/word_finder.png -------------------------------------------------------------------------------- /examples/videos/backward_compat_with_node_npm.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "与 Node 和 npm 的兼容性" 3 | url: /examples/backward_compat_with_node_npm/ 4 | videoUrl: https://www.youtube.com/watch?v=QPLchkJ7eas&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=12 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/command_line_utility.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "构建命令行工具" 3 | url: /examples/command_line_utility/ 4 | videoUrl: https://www.youtube.com/watch?v=TUxj2TS5pNo&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=14 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/configuration_with_deno_json.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "使用 Deno JSON 进行配置" 3 | url: /examples/configuration_with_deno_json/ 4 | videoUrl: https://www.youtube.com/watch?v=P2BBYNPpgW8 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/deno_bench.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "使用 Deno bench 进行基准测试" 3 | url: /examples/deno_bench/ 4 | videoUrl: https://www.youtube.com/watch?v=IVde_GTN6TM 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/deno_coverage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Deno 覆盖率" 3 | url: /examples/deno_coverage/ 4 | videoUrl: https://www.youtube.com/watch?v=P2BBYNPpgW8 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/deno_fmt.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "使用 Deno fmt 进行格式化" 3 | url: /examples/deno_fmt/ 4 | videoUrl: https://www.youtube.com/watch?v=Ouzso9gQqnc 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/deno_test.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Deno 测试入门" 3 | url: /examples/deno_test/ 4 | videoUrl: https://www.youtube.com/watch?v=gDtDVfsgHgs 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/esmodules.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "ECMAScript 模块" 3 | url: /examples/esmodules/ 4 | videoUrl: https://www.youtube.com/watch?v=cTFBiwYY3vs&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=9 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/intro_to_deno_apis.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Deno API 简介" 3 | url: /examples/intro_to_deno_apis/ 4 | videoUrl: https://www.youtube.com/watch?v=p28ujFMrdA0&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=7 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/mongoose.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "连接 Mongoose 和 MongoDB" 3 | url: /examples/mongoose/ 4 | videoUrl: https://www.youtube.com/watch?v=dmZ9Ih0CR9g 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/prisma.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "连接到 Prisma" 3 | url: /examples/prisma/ 4 | videoUrl: https://www.youtube.com/watch?v=P8VzA_XSF8w 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/react_app_video.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "构建一个 React 应用" 3 | url: /examples/react_app_video/ 4 | videoUrl: https://www.youtube.com/watch?v=eStwt_2THd8 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/realtime_websocket_app.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "构建实时 WebSocket 应用" 3 | url: /examples/realtime_websocket_app/ 4 | videoUrl: https://www.youtube.com/watch?v=FC4IrkHEg4A&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=15 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/ts_jsx.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "TypeScript 和 JSX" 3 | url: /examples/ts_jsx/ 4 | videoUrl: https://www.youtube.com/watch?v=KoM8ahe8O74&list=PLvvLnBDNuTEov9EBIp3MMfHlBxaKGRWTe&index=11 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /examples/videos/vue_app_video.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "构建一个 Vue 应用" 3 | url: /examples/vue_app_video/ 4 | videoUrl: https://www.youtube.com/watch?v=MDPauM8fZDE 5 | layout: video.tsx 6 | --- 7 | -------------------------------------------------------------------------------- /lint/rules/ban-ts-comment.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在没有注释的情况下使用 Typescript 指令。 6 | 7 | Typescript 8 | 指令会降低编译器的有效性,这种情况只应在特殊情况下使用。使用指令的原因应在注释中与指令一起记录。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | // @ts-expect-error 14 | let a: number = "I am a string"; 15 | ``` 16 | 17 | ```typescript 18 | // @ts-ignore 19 | let a: number = "I am a string"; 20 | ``` 21 | 22 | ```typescript 23 | // @ts-nocheck 24 | let a: number = "I am a string"; 25 | ``` 26 | 27 | **有效示例:** 28 | 29 | ```typescript 30 | // @ts-expect-error: 临时解决方案(参见工单 #422) 31 | let a: number = "I am a string"; 32 | ``` 33 | 34 | ```typescript 35 | // @ts-ignore: 临时解决方案(参见工单 #422) 36 | let a: number = "I am a string"; 37 | ``` 38 | 39 | ```typescript 40 | // @ts-nocheck: 临时解决方案(参见工单 #422) 41 | let a: number = "I am a string"; 42 | ``` 43 | -------------------------------------------------------------------------------- /lint/rules/ban-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用原始包装对象(例如 `String` 对象是 `string` 6 | 原始类型的包装器),以及非显式的 `Function` 类型和被误解的 `Object` 类型。 7 | 8 | 很少有情况下需要使用原始包装对象,更多时候是原始类型的误用。你也不能将原始包装对象赋值给原始类型,这会导致后续的类型问题。作为参考,[TypeScript 手册] 9 | 也指出我们不应该使用这些包装对象。 10 | 11 | [TypeScript 手册]: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#number-string-boolean-symbol-and-object 12 | 13 | 对于 `Function`,最好显式定义整个函数签名,而不是使用非特定的 `Function` 14 | 类型,后者无法提供函数类型的安全性。 15 | 16 | 最后,`Object` 和 `{}` 表示“任何非空值”,而不是“任何对象类型”。`object` 17 | 是表示“任何对象类型”的良好选择。 18 | 19 | **无效:** 20 | 21 | ```typescript 22 | let a: Boolean; 23 | let b: String; 24 | let c: Number; 25 | let d: Symbol; 26 | let e: Function; 27 | let f: Object; 28 | let g: {}; 29 | ``` 30 | 31 | **有效:** 32 | 33 | ```typescript 34 | let a: boolean; 35 | let b: string; 36 | let c: number; 37 | let d: symbol; 38 | let e: () => number; 39 | let f: object; 40 | let g: Record; 41 | ``` 42 | -------------------------------------------------------------------------------- /lint/rules/ban-unknown-rule-code.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 警告在忽略指令中使用未知规则代码的情况。 6 | 7 | 有时我们出于某些原因需要抑制并忽略 lint 错误。我们可以使用 8 | [忽略指令](/go/lint-ignore/) 并指定要忽略的规则名称来实现,如下所示: 9 | 10 | ```typescript 11 | // deno-lint-ignore no-explicit-any no-unused-vars 12 | const foo: any = 42; 13 | ``` 14 | 15 | 此规则检查指定的规则名称是否有效(即 `deno_lint` 是否提供了该规则)。 16 | 17 | **无效示例:** 18 | 19 | ```typescript 20 | // 拼写错误 21 | // deno-lint-ignore eq-eq-e 22 | console.assert(x == 42); 23 | 24 | // 未知规则名称 25 | // deno-lint-ignore UNKNOWN_RULE_NAME 26 | const b = "b"; 27 | ``` 28 | 29 | **有效示例:** 30 | 31 | ```typescript 32 | // deno-lint-ignore eq-eq-eq 33 | console.assert(x == 42); 34 | 35 | // deno-lint-ignore no-unused-vars 36 | const b = "b"; 37 | ``` 38 | -------------------------------------------------------------------------------- /lint/rules/ban-untagged-ignore.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 需要将 `deno-lint-ignore` 注释与一个或多个规则名称一起使用。 6 | 7 | 忽略所有规则可能会掩盖意外或未来的问题。因此,您需要明确指定要忽略的规则。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | // deno-lint-ignore 13 | export function duplicateArgumentsFn(a, b, a) {} 14 | ``` 15 | 16 | **有效示例:** 17 | 18 | ```typescript 19 | // deno-lint-ignore no-dupe-args 20 | export function duplicateArgumentsFn(a, b, a) {} 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/ban-untagged-todo.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 要求 TODOs 必须使用用户标签(`@user`)或问题引用(`#issue`)进行注释。 6 | 7 | 没有引用用户或问题的 TODOs 会变得陈旧,且无法轻松获取更多信息。 8 | 9 | **无效:** 10 | 11 | ```typescript 12 | // TODO Improve calc engine 13 | export function calcValue(): number {} 14 | ``` 15 | 16 | ```typescript 17 | // TODO Improve calc engine (@djones) 18 | export function calcValue(): number {} 19 | ``` 20 | 21 | ```typescript 22 | // TODO Improve calc engine (#332) 23 | export function calcValue(): number {} 24 | ``` 25 | 26 | **有效:** 27 | 28 | ```typescript 29 | // TODO(djones) Improve calc engine 30 | export function calcValue(): number {} 31 | ``` 32 | 33 | ```typescript 34 | // TODO(@djones) Improve calc engine 35 | export function calcValue(): number {} 36 | ``` 37 | 38 | ```typescript 39 | // TODO(#332) 40 | export function calcValue(): number {} 41 | ``` 42 | 43 | ```typescript 44 | // TODO(#332) Improve calc engine 45 | export function calcValue(): number {} 46 | ``` 47 | -------------------------------------------------------------------------------- /lint/rules/ban-unused-ignore.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 警告未使用的忽略指令。 6 | 7 | 有时我们出于某些原因需要抑制并忽略 lint 错误,我们可以使用 8 | [忽略指令](/go/lint-ignore/) 来实现。 9 | 10 | 然而,在某些情况下,比如重构之后,我们可能会留下不再必要的忽略指令。这些多余的忽略指令可能会让未来的代码阅读者感到困惑,更糟糕的是,可能会无意中隐藏未来的 11 | lint 错误。为了防止这种情况,此规则会检测未使用的、多余的忽略指令。 12 | 13 | **无效示例:** 14 | 15 | ```typescript 16 | // 实际上这行代码是有效的,因为 `export` 意味着“已使用”, 17 | // 所以这个指令是多余的 18 | // deno-lint-ignore no-unused-vars 19 | export const foo = 42; 20 | ``` 21 | 22 | **有效示例:** 23 | 24 | ```typescript 25 | export const foo = 42; 26 | ``` 27 | -------------------------------------------------------------------------------- /lint/rules/button-has-type.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 检查 `; 12 | const btn = ; 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```tsx 18 | const btn = ; 19 | const btn = ; 20 | const btn = ; 21 | const btn = ; 22 | ``` 23 | -------------------------------------------------------------------------------- /lint/rules/jsx-curly-braces.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx] 3 | --- 4 | 5 | 确保在 JSX 表达式中一致地使用花括号。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 | const foo = />; 11 | const foo = ; 12 | const foo =
    {"foo"}
    ; 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```tsx 18 | const foo = } />; 19 | const foo = ; 20 | const foo =
    foo
    ; 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/jsx-key.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx] 3 | --- 4 | 5 | 在将可迭代对象传递到 JSX 时,确保 `key` 属性存在。它允许框架优化检查元素的顺序。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 | const foo = [
    foo
    ]; 11 | const foo = [<>foo]; 12 | [1, 2, 3].map(() =>
    ); 13 | Array.from([1, 2, 3], () =>
    ); 14 | ``` 15 | 16 | **有效示例:** 17 | 18 | ```tsx 19 | const foo = [
    foo
    ]; 20 | const foo = [foo]; 21 | [1, 2, 3].map((x) =>
    ); 22 | Array.from([1, 2, 3], (x) =>
    ); 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/jsx-no-children-prop.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx, fresh] 3 | --- 4 | 5 | 将子元素作为 JSX 子元素传递,而不是作为属性。 6 | 7 | **无效:** 8 | 9 | ```tsx 10 |
    11 |
    , ]} /> 12 | ``` 13 | 14 | **有效:** 15 | 16 | ```tsx 17 |
    foo
    18 |
    19 | ``` 20 | -------------------------------------------------------------------------------- /lint/rules/jsx-no-comment-text-nodes.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx, fresh] 3 | --- 4 | 5 | 在 JSX 中,文本节点内的 JavaScript 注释会被渲染为纯文本。这通常是出乎意料的。 6 | 7 | **无效:** 8 | 9 | ```tsx 10 |
    // comment
    11 |
    /* comment */
    12 | ``` 13 | 14 | **有效:** 15 | 16 | ```tsx 17 |
    {/* comment */}
    ; 18 | ``` 19 | -------------------------------------------------------------------------------- /lint/rules/jsx-no-duplicate-props.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx] 3 | --- 4 | 5 | 禁止重复的 JSX 属性。后面的属性总是会覆盖前面的属性,通常会导致意外的结果。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 |
    ; 11 | ; 12 | ; 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```tsx 18 |
    19 | 20 | 21 | 22 | ``` 23 | -------------------------------------------------------------------------------- /lint/rules/jsx-no-unescaped-entities.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [推荐, react, jsx, 新鲜] 3 | --- 4 | 5 | 在 JSX 中留下 `>` 或 `}` 6 | 字符通常是不希望的,并且难以发现。强制要求这些字符必须作为字符串传递。 7 | 8 | **无效:** 9 | 10 | ```tsx 11 |
    >
    12 |
    }
    13 | ``` 14 | 15 | **有效:** 16 | 17 | ```tsx 18 |
    >
    , 19 |
    {">"}
    , 20 |
    {"}"}
    , 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/jsx-no-useless-fragment.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx, fresh] 3 | --- 4 | 5 | Fragments 仅在 JSX "块" 的顶部且存在多个子元素时才需要。在其他场景中不需要使用 6 | Fragments。 7 | 8 | **无效:** 9 | 10 | ```tsx 11 | <> 12 | <>
    13 | <> 14 |

    foo <>bar

    15 | ``` 16 | 17 | **有效:** 18 | 19 | ```tsx 20 | <>{foo} 21 | <>
    22 | <>foo
    23 |

    foo bar

    24 | ``` 25 | -------------------------------------------------------------------------------- /lint/rules/jsx-props-no-spread-multi.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx] 3 | --- 4 | 5 | 重复展开相同的表达式通常是一个错误,会导致不必要的计算。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 |
    11 |
    12 | 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```tsx 18 |
    19 |
    20 | 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/jsx-void-dom-elements-no-children.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended, react, jsx, fresh] 3 | --- 4 | 5 | 确保 HTML 中的空元素没有任何子元素,因为这是无效的 HTML。有关更多信息,请参阅 6 | MDN 上的 7 | [`Void element` 文章](https://developer.mozilla.org/zh-CN/docs/Glossary/Void_element)。 8 | 9 | **无效:** 10 | 11 | ```tsx 12 |
    foo
    13 | foo 14 | ``` 15 | 16 | **有效:** 17 | 18 | ```tsx 19 |
    20 | 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/no-array-constructor.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 强制使用数组构造的常规用法。 6 | 7 | 数组构造通常通过字面量表示法完成,例如 `[]` 或 `[1, 2, 3]`。不鼓励使用 8 | `new Array()`,也不鼓励使用 9 | `new Array(1, 2, 3)`。这有两个原因。第一个原因是,单个提供的参数定义了数组的长度,而多个参数则填充了不固定大小的数组。当仅使用字面量表示法创建预填充数组时,可以避免这种混淆。第二个避免使用 10 | `Array` 构造函数的理由是,`Array` 全局变量可能会被重新定义。 11 | 12 | 此规则的一个例外是创建固定大小的新数组时,例如 13 | `new Array(6)`。这是创建固定长度数组的常规方式。 14 | 15 | **无效:** 16 | 17 | ```typescript 18 | // 这是 4 个元素,而不是大小为 100 的 3 个元素的数组 19 | const a = new Array(100, 1, 2, 3); 20 | 21 | const b = new Array(); // 应使用 [] 代替 22 | ``` 23 | 24 | **有效:** 25 | 26 | ```typescript 27 | const a = new Array(100); 28 | const b = []; 29 | const c = [1, 2, 3]; 30 | ``` 31 | -------------------------------------------------------------------------------- /lint/rules/no-async-promise-executor.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 要求不使用异步的 Promise 执行器函数。 6 | 7 | Promise 构造函数接受一个执行器函数作为参数,该函数带有 `resolve` 和 `reject` 8 | 参数,可用于控制创建的 Promise 9 | 的状态。虽然允许此函数是异步的,但通常不建议这样做,原因如下: 10 | 11 | - 如果异步执行器函数抛出错误,该错误将会丢失,并且不会导致新创建的 Promise 12 | 被拒绝。这可能会使调试和处理某些错误变得困难。 13 | - 如果异步的 Promise 执行器函数使用了 14 | `await`,那么这通常表明实际上没有必要使用新的 Promise 15 | 构造函数,代码可以重构以避免使用 Promise,或者可以减少新 Promise 16 | 构造函数的作用范围,提取异步代码并将其改为同步。 17 | 18 | **无效:** 19 | 20 | ```typescript 21 | new Promise(async function (resolve, reject) {}); 22 | new Promise(async (resolve, reject) => {}); 23 | ``` 24 | 25 | **有效:** 26 | 27 | ```typescript 28 | new Promise(function (resolve, reject) {}); 29 | new Promise((resolve, reject) => {}); 30 | ``` 31 | -------------------------------------------------------------------------------- /lint/rules/no-await-in-loop.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 要求 `await` 不在 for 循环体中使用。 6 | 7 | 在 Javascript 中,`async` 和 `await` 用于提供并行执行。如果在 for 8 | 循环中对每个元素使用 `await`,那么这将抵消使用 `async/await` 9 | 的好处,因为在当前元素完成之前,循环中的其他元素无法继续处理。 10 | 11 | 常见的解决方案是重构代码,使循环体异步运行并捕获生成的 12 | promises。循环结束后,您可以一次性等待所有 promises。 13 | 14 | **无效示例:** 15 | 16 | ```javascript 17 | async function doSomething(items) { 18 | const results = []; 19 | for (const item of items) { 20 | // 数组中的每个元素都会阻塞,直到前一个元素完成 21 | results.push(await someAsyncProcessing(item)); 22 | } 23 | return processResults(results); 24 | } 25 | ``` 26 | 27 | **有效示例:** 28 | 29 | ```javascript 30 | async function doSomething(items) { 31 | const results = []; 32 | for (const item of items) { 33 | // 异步启动所有元素处理... 34 | results.push(someAsyncProcessing(item)); 35 | } 36 | // ...然后在循环结束后等待它们完成 37 | return processResults(await Promise.all(results)); 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /lint/rules/no-await-in-sync-fn.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在非异步函数中使用 `await` 关键字。 6 | 7 | 在非异步函数中使用 `await` 关键字会导致语法错误。为了能够在函数中使用 8 | `await`,该函数需要通过 `async` 关键字标记为异步函数。 9 | 10 | **无效示例:** 11 | 12 | ```javascript 13 | function foo() { 14 | await bar(); 15 | } 16 | 17 | const fooFn = function foo() { 18 | await bar(); 19 | }; 20 | 21 | const fooFn = () => { 22 | await bar(); 23 | }; 24 | ``` 25 | 26 | **有效示例:** 27 | 28 | ```javascript 29 | async function foo() { 30 | await bar(); 31 | } 32 | 33 | const fooFn = async function foo() { 34 | await bar(); 35 | }; 36 | 37 | const fooFn = async () => { 38 | await bar(); 39 | }; 40 | ``` 41 | -------------------------------------------------------------------------------- /lint/rules/no-class-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止修改类声明中的变量。 6 | 7 | 声明一个类,例如 `class A {}`,会创建一个变量 8 | `A`。与任何变量一样,这可以被修改或重新赋值。在大多数情况下,这是一个错误,并非本意。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | class A {} 14 | A = 0; // 重新赋值类变量本身 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | class A {} 21 | let c = new A(); 22 | c = 0; // 重新赋值变量 `c` 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/no-compare-neg-zero.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止与负零 (`-0`) 进行比较。 6 | 7 | 直接与负零进行比较可能不会按预期工作,因为它也会通过非负零(即 `0` 和 8 | `+0`)的检查。可以使用 `Object.is` 来显式地与负零进行比较。 9 | 10 | **无效:** 11 | 12 | ```typescript 13 | if (x === -0) {} 14 | ``` 15 | 16 | **有效:** 17 | 18 | ```typescript 19 | if (x === 0) {} 20 | 21 | if (Object.is(x, -0)) {} 22 | ``` 23 | -------------------------------------------------------------------------------- /lint/rules/no-cond-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在条件语句中使用赋值运算符 `=`。 6 | 7 | 在条件语句中使用赋值运算符通常是误输入了相等运算符 `==` 8 | 的结果。如果确实需要在条件语句中进行赋值,可以通过将赋值操作放在括号中来允许此操作。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | let x; 14 | if (x = 0) { 15 | let b = 1; 16 | } 17 | ``` 18 | 19 | ```typescript 20 | function setHeight(someNode) { 21 | do { 22 | someNode.height = "100px"; 23 | } while (someNode = someNode.parentNode); 24 | } 25 | ``` 26 | 27 | **有效示例:** 28 | 29 | ```typescript 30 | let x; 31 | if (x === 0) { 32 | let b = 1; 33 | } 34 | ``` 35 | 36 | ```typescript 37 | function setHeight(someNode) { 38 | do { 39 | someNode.height = "100px"; 40 | } while ((someNode = someNode.parentNode)); 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /lint/rules/no-console.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用 `console` 全局对象。 6 | 7 | 通常情况下,开发者在调试后会不小心提交 `console.log`/`console.error` 8 | 语句。此外,在代码中使用这些语句可能会将敏感信息泄露到输出中,或者用不必要的信息污染控制台。此规则通过禁止使用 9 | `console` 来帮助保持代码的整洁和安全。 10 | 11 | 此规则在几乎从不希望输出到控制台的库中尤其有用。 12 | 13 | **无效示例:** 14 | 15 | ```typescript 16 | console.log("调试信息"); 17 | console.error("调试信息"); 18 | console.debug(obj); 19 | 20 | if (debug) console.log("调试中"); 21 | 22 | function log() { 23 | console.log("日志"); 24 | } 25 | ``` 26 | 27 | **有效示例:** 28 | 29 | 建议通过 `deno-lint-ignore` 注释显式启用 30 | `console`,以便在确实需要使用它的地方进行调用。 31 | 32 | ```typescript 33 | function logWarning(message: string) { 34 | // deno-lint-ignore no-console 35 | console.warn(message); 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /lint/rules/no-const-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止修改声明为 `const` 的变量。 6 | 7 | 修改声明为 `const` 的变量将导致运行时错误。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | const a = 0; 13 | a = 1; 14 | a += 1; 15 | a++; 16 | ++a; 17 | ``` 18 | 19 | **有效示例:** 20 | 21 | ```typescript 22 | const a = 0; 23 | const b = a + 1; 24 | 25 | // `c` 在每次循环迭代时都超出作用域,允许重新赋值 26 | for (const c in [1, 2, 3]) {} 27 | ``` 28 | -------------------------------------------------------------------------------- /lint/rules/no-constant-condition.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在条件测试中使用常量表达式。 6 | 7 | 在条件测试中使用常量表达式通常是一个错误,或者是开发过程中引入的临时情况,不适合用于生产环境。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | if (true) {} 13 | if (2) {} 14 | do {} while (x = 2); // 无限循环 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | if (x) {} 21 | if (x === 0) {} 22 | do {} while (x === 2); 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/no-control-regex.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在正则表达式中使用 ASCII 控制字符。 6 | 7 | 控制字符是 ASCII 范围 0-31 8 | 中的不可见字符。在正则表达式中使用这些字符并不常见,更多时候是正则表达式中的错误。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | // 使用 ASCII (31) 回车符 (十六进制 x0d) 的示例 14 | const pattern1 = /\x0d/; 15 | const pattern2 = /\u000d/; 16 | const pattern3 = new RegExp("\\x0d"); 17 | const pattern4 = new RegExp("\\u000d"); 18 | ``` 19 | 20 | **有效示例:** 21 | 22 | ```typescript 23 | // 使用 ASCII (32) 空格符 (十六进制 x20) 的示例 24 | const pattern1 = /\x20/; 25 | const pattern2 = /\u0020/; 26 | const pattern3 = new RegExp("\\x20"); 27 | const pattern4 = new RegExp("\\u0020"); 28 | ``` 29 | -------------------------------------------------------------------------------- /lint/rules/no-debugger.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 `debugger` 语句。 6 | 7 | `debugger` 是一种用于停止 JavaScript 8 | 执行环境并在该语句处启动调试器的语句。现代调试器和工具不再需要此语句,保留它可能会导致代码在生产环境中停止执行。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | function isLongString(x: string) { 14 | debugger; 15 | return x.length > 100; 16 | } 17 | ``` 18 | 19 | **有效示例:** 20 | 21 | ```typescript 22 | function isLongString(x: string) { 23 | return x.length > 100; // 在此处设置断点代替 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-delete-var.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止删除变量。 6 | 7 | `delete` 用于从对象中移除属性。通过 `var`、`let` 和 `const` 8 | 声明的变量无法被删除(`delete` 会返回 `false`)。在启用 `strict` 9 | 模式时,尝试删除变量会引发语法错误。 10 | 11 | **无效示例:** 12 | 13 | ```typescript 14 | const a = 1; 15 | let b = 2; 16 | let c = 3; 17 | delete a; // 会返回 false 18 | delete b; // 会返回 false 19 | delete c; // 会返回 false 20 | ``` 21 | 22 | **有效示例:** 23 | 24 | ```typescript 25 | let obj = { 26 | a: 1, 27 | }; 28 | delete obj.a; // 返回 true 29 | ``` 30 | -------------------------------------------------------------------------------- /lint/rules/no-dupe-args.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在函数签名中多次使用相同的参数名称。 6 | 7 | 如果你在函数中提供了多个相同名称的参数,最后一个实例将会覆盖前面的实例。这很可能是一个无意的拼写错误。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | function withDupes(a, b, a) { 13 | console.log("I'm the value of the second a:", a); 14 | } 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | function withoutDupes(a, b, c) { 21 | console.log("I'm the value of the first (and only) a:", a); 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/no-dupe-class-members.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在类中多次使用相同的成员函数名称。 6 | 7 | 在类中两次声明相同名称的函数会导致之前的声明被覆盖,从而引发意外行为。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | class Foo { 13 | bar() {} 14 | bar() {} 15 | } 16 | ``` 17 | 18 | **有效示例:** 19 | 20 | ```typescript 21 | class Foo { 22 | bar() {} 23 | fizz() {} 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-dupe-else-if.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在 `if`/`else if` 语句中重复使用相同的条件。 6 | 7 | 当你在 `if`/`else if` 8 | 语句中重复使用一个条件时,重复的条件将永远不会被触发(除非有异常的副作用),这意味着这几乎总是一个错误。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | if (a) {} 14 | else if (b) {} 15 | else if (a) {} // 重复了上面的条件 16 | 17 | if (a === 5) {} 18 | else if (a === 6) {} 19 | else if (a === 5) {} // 重复了上面的条件 20 | ``` 21 | 22 | **有效示例:** 23 | 24 | ```typescript 25 | if (a) {} 26 | else if (b) {} 27 | else if (c) {} 28 | 29 | if (a === 5) {} 30 | else if (a === 6) {} 31 | else if (a === 7) {} 32 | ``` 33 | -------------------------------------------------------------------------------- /lint/rules/no-dupe-keys.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在对象字面量中使用重复的键。 6 | 7 | 在对象字面量中多次设置相同的键会覆盖对该键的其他赋值,并可能导致意外行为。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | const foo = { 13 | bar: "baz", 14 | bar: "qux", 15 | }; 16 | ``` 17 | 18 | ```typescript 19 | const foo = { 20 | "bar": "baz", 21 | bar: "qux", 22 | }; 23 | ``` 24 | 25 | ```typescript 26 | const foo = { 27 | 0x1: "baz", 28 | 1: "qux", 29 | }; 30 | ``` 31 | 32 | **有效示例:** 33 | 34 | ```typescript 35 | const foo = { 36 | bar: "baz", 37 | quxx: "qux", 38 | }; 39 | ``` 40 | -------------------------------------------------------------------------------- /lint/rules/no-duplicate-case.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在 `switch` 语句中多次使用相同的 `case` 子句。 6 | 7 | 当你在 `switch` 语句中重复使用 `case` 测试表达式时,重复的 `case` 8 | 将永远不会被执行,这意味着这几乎总是一个错误。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | const someText = "a"; 14 | switch (someText) { 15 | case "a": // (1) 16 | break; 17 | case "b": 18 | break; 19 | case "a": // 重复了 (1) 20 | break; 21 | default: 22 | break; 23 | } 24 | ``` 25 | 26 | **有效示例:** 27 | 28 | ```typescript 29 | const someText = "a"; 30 | switch (someText) { 31 | case "a": 32 | break; 33 | case "b": 34 | break; 35 | case "c": 36 | break; 37 | default: 38 | break; 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /lint/rules/no-empty-character-class.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在正则表达式中使用空字符类。 6 | 7 | 正则表达式字符类是括号内的一系列字符,例如 8 | `[abc]`。如果在括号内没有提供任何内容,它将不会匹配任何内容,这很可能是一个拼写错误或错误。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | /^abc[]/.test("abcdefg"); // false,因为 `d` 不匹配空字符类 14 | "abcdefg".match(/^abc[]/); // null 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | // 不使用字符类 21 | /^abc/.test("abcdefg"); // true 22 | "abcdefg".match(/^abc/); // ["abc"] 23 | 24 | // 使用有效的字符类 25 | /^abc[a-z]/.test("abcdefg"); // true 26 | "abcdefg".match(/^abc[a-z]/); // ["abcd"] 27 | ``` 28 | -------------------------------------------------------------------------------- /lint/rules/no-empty-enum.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止声明空枚举。 6 | 7 | 没有成员的枚举没有任何意义。此规则将捕获这些情况,认为它们是不必要的代码或错误的空实现。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | enum Foo {} 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```typescript 18 | enum Foo { 19 | ONE = "ONE", 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/no-empty-interface.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止声明空接口。 6 | 7 | 没有成员的接口没有任何作用。此规则将捕获这些情况,要么是多余的代码,要么是错误地实现了空接口。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | interface Foo {} 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```typescript 18 | interface Foo { 19 | name: string; 20 | } 21 | 22 | interface Bar { 23 | age: number; 24 | } 25 | 26 | // 允许使用至少有一个扩展的空接口。 27 | 28 | // 使用空接口将 Baz 的身份从类型更改为接口。 29 | type Baz = { profession: string }; 30 | interface Foo extends Baz {} 31 | 32 | // 使用空接口扩展已存在的 Foo 声明 33 | // 并包含 Bar 接口的成员 34 | interface Foo extends Bar {} 35 | 36 | // 使用空接口作为联合类型 37 | interface Baz extends Foo, Bar {} 38 | ``` 39 | -------------------------------------------------------------------------------- /lint/rules/no-empty-pattern.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在解构中使用空模式。 6 | 7 | 在解构中,可能会使用诸如 `{}` 或 `[]` 8 | 这样的空模式,这些模式没有任何效果,很可能不是作者的本意。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | // 在下面的示例中,{} 和 [] 不是对象字面量或空数组, 14 | // 而是解构变量名的占位符 15 | const {} = someObj; 16 | const [] = someArray; 17 | const {a: {}} = someObj; 18 | const [a: []] = someArray; 19 | function myFunc({}) {} 20 | function myFunc([]) {} 21 | ``` 22 | 23 | **有效示例:** 24 | 25 | ```typescript 26 | const { a } = someObj; 27 | const [a] = someArray; 28 | 29 | // 正确的方式是将解构变量默认设置为对象字面量 30 | const { a = {} } = someObj; 31 | 32 | // 正确的方式是将解构变量默认设置为空数组 33 | const [a = []] = someArray; 34 | 35 | function myFunc({ a }) {} 36 | function myFunc({ a = {} }) {} 37 | function myFunc([a]) {} 38 | function myFunc([a = []]) {} 39 | ``` 40 | -------------------------------------------------------------------------------- /lint/rules/no-empty.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用空的块语句。 6 | 7 | 空的块语句是合法的,但通常表示遗漏了某些内容,并且可能使代码的可读性降低。此规则忽略仅包含注释的块语句。此规则还忽略空的构造函数和函数体(包括箭头函数)。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | if (foo) {} 13 | 14 | while (foo) {} 15 | 16 | switch (foo) {} 17 | 18 | try { 19 | doSomething(); 20 | } catch (e) { 21 | } finally { 22 | } 23 | ``` 24 | 25 | **有效示例:** 26 | 27 | ```typescript 28 | if (foo) { 29 | // empty 30 | } 31 | 32 | while (foo) { 33 | /* empty */ 34 | } 35 | 36 | try { 37 | doSomething(); 38 | } catch (e) { 39 | // continue regardless of error 40 | } 41 | 42 | try { 43 | doSomething(); 44 | } finally { 45 | /* continue regardless of error */ 46 | } 47 | ``` 48 | -------------------------------------------------------------------------------- /lint/rules/no-eval.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用 `eval`。 6 | 7 | `eval` 8 | 是一个潜在危险的函数,可能会使你的代码面临多种安全漏洞。除了速度较慢之外,`eval` 9 | 通常也是不必要的,因为有更好的解决方案可用。 10 | 11 | **无效示例:** 12 | 13 | ```typescript 14 | const obj = { x: "foo" }; 15 | const key = "x", 16 | const value = eval("obj." + key); 17 | ``` 18 | 19 | **有效示例:** 20 | 21 | ```typescript 22 | const obj = { x: "foo" }; 23 | const value = obj[x]; 24 | ``` 25 | -------------------------------------------------------------------------------- /lint/rules/no-ex-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止重新分配异常参数。 6 | 7 | 通常没有充分的理由去重新分配异常参数。一旦重新分配,从该点开始的代码将不再引用错误。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | try { 13 | someFunc(); 14 | } catch (e) { 15 | e = true; 16 | // 无法再访问抛出的错误 17 | } 18 | ``` 19 | 20 | **有效示例:** 21 | 22 | ```typescript 23 | try { 24 | someFunc(); 25 | } catch (e) { 26 | const anotherVar = true; 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /lint/rules/no-explicit-any.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 `any` 类型。 6 | 7 | 使用 `any` 类型会禁用该变量周围的类型检查系统,违背了 TypeScript 8 | 提供类型安全代码的初衷。此外,使用 `any` 9 | 会降低代码的可读性,因为无法立即清楚引用的值是什么类型。最好明确所有类型。如果无法选择更具体的类型,可以使用 10 | `unknown` 作为 `any` 的更类型安全的替代方案。 11 | 12 | **无效示例:** 13 | 14 | ```typescript 15 | const someNumber: any = "two"; 16 | function foo(): any { 17 | return undefined; 18 | } 19 | ``` 20 | 21 | **有效示例:** 22 | 23 | ```typescript 24 | const someNumber: string = "two"; 25 | function foo(): undefined { 26 | return undefined; 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /lint/rules/no-external-import.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用外部导入。 6 | 7 | - 这条 lint 规则的动机是什么? 8 | - 如果通过 URL 导入外部模块,此规则会发出警告。"deps.ts" 和导入映射是例外。 9 | - 为什么被 lint 的代码被认为是不好的? 10 | - 导入外部模块虽然可以正常工作,但如果你想升级这些模块,并且它们在项目中的多个地方被导入,将会花费时间和精力。 11 | - 什么时候应该使用它? 12 | - 为了避免这种情况,你可以使用 "deps.ts 约定" 或 13 | [导入映射](https://docs.denohub.com/runtime/manual/basics/import_maps),在其中导入所有外部模块,然后重新导出它们或为它们分配别名。 14 | - 如果你想遵循 "deps.ts 约定" 或使用导入映射。 15 | 16 | **无效:** 17 | 18 | ```typescript 19 | import { assertEquals } from "https://deno.land/std@0.126.0/testing/asserts.ts"; 20 | ``` 21 | 22 | **有效:** 23 | 24 | ```typescript 25 | import { assertEquals } from "./deps.ts"; 26 | ``` 27 | 28 | ```typescript 29 | // deps.ts 30 | 31 | export { 32 | assert, 33 | assertEquals, 34 | assertStringIncludes, 35 | } from "https://deno.land/std@0.126.0/testing/asserts.ts"; 36 | ``` 37 | 38 | 你可以在这里参考此约定的解释 39 | https://docs.denohub.com/runtime/manual/basics/modules/#it-seems-unwieldy-to-import-urls-everywhere 40 | -------------------------------------------------------------------------------- /lint/rules/no-extra-boolean-cast.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止不必要的布尔类型转换。 6 | 7 | 在某些上下文中,例如 `if`、`while` 或 `for` 8 | 语句,表达式会自动转换为布尔值。因此,诸如双重否定(`!!foo`)或类型转换(`Boolean(foo)`)等技术是不必要的,并且与不使用否定或转换时产生的结果相同。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | if (!!foo) {} 14 | if (Boolean(foo)) {} 15 | while (!!foo) {} 16 | for (; Boolean(foo);) {} 17 | ``` 18 | 19 | **有效示例:** 20 | 21 | ```typescript 22 | if (foo) {} 23 | while (foo) {} 24 | for (; foo;) {} 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-extra-non-null-assertion.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止不必要非空断言。 6 | 7 | 非空断言使用 `!` 来告诉编译器你知道这个值不是 8 | null。在一行中多次使用此操作符,或与可选链操作符(`?`)结合使用,会让人感到困惑且没有必要。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | const foo: { str: string } | null = null; 14 | const bar = foo!!.str; 15 | 16 | function myFunc(bar: undefined | string) { 17 | return bar!!; 18 | } 19 | function anotherFunc(bar?: { str: string }) { 20 | return bar!?.str; 21 | } 22 | ``` 23 | 24 | **有效示例:** 25 | 26 | ```typescript 27 | const foo: { str: string } | null = null; 28 | const bar = foo!.str; 29 | 30 | function myFunc(bar: undefined | string) { 31 | return bar!; 32 | } 33 | function anotherFunc(bar?: { str: string }) { 34 | return bar?.str; 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /lint/rules/no-fallthrough.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止 case 语句的隐式贯穿。 6 | 7 | 没有 `break` 的 case 语句会执行其主体,然后贯穿到下一个 case 或 default 8 | 块并执行该块。虽然有时这是故意的,但很多时候开发者忘记添加 break 9 | 语句,原本只希望执行单个 case 语句。此规则强制要求你必须在每个 case 10 | 语句的末尾添加 break 语句或显式注释,表明贯穿是故意的。贯穿注释必须包含 11 | `fallthrough`、`falls through` 或 `fall through` 之一。 12 | 13 | **无效:** 14 | 15 | ```typescript 16 | switch (myVar) { 17 | case 1: 18 | console.log("1"); 19 | 20 | case 2: 21 | console.log("2"); 22 | } 23 | // 如果 myVar = 1,输出 `1` 和 `2`。这是故意的吗? 24 | ``` 25 | 26 | **有效:** 27 | 28 | ```typescript 29 | switch (myVar) { 30 | case 1: 31 | console.log("1"); 32 | break; 33 | 34 | case 2: 35 | console.log("2"); 36 | break; 37 | } 38 | // 如果 myVar = 1,仅输出 `1` 39 | 40 | switch (myVar) { 41 | case 1: 42 | console.log("1"); 43 | /* falls through */ 44 | case 2: 45 | console.log("2"); 46 | } 47 | // 如果 myVar = 1,故意输出 `1` 和 `2` 48 | ``` 49 | -------------------------------------------------------------------------------- /lint/rules/no-func-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止覆盖/重新分配现有函数。 6 | 7 | Javascript 8 | 允许重新分配函数定义。这通常是开发人员的错误,或者是糟糕的编码实践,因为代码的可读性和可维护性会受到影响。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | function foo() {} 14 | foo = bar; 15 | 16 | const a = function baz() { 17 | baz = "now I'm a string"; 18 | }; 19 | 20 | myFunc = existingFunc; 21 | function myFunc() {} 22 | ``` 23 | 24 | **有效示例:** 25 | 26 | ```typescript 27 | function foo() {} 28 | const someVar = foo; 29 | 30 | const a = function baz() { 31 | const someStr = "now I'm a string"; 32 | }; 33 | 34 | const anotherFuncRef = existingFunc; 35 | 36 | let myFuncVar = function () {}; 37 | myFuncVar = bar; // 变量重新分配,不是函数重新声明 38 | ``` 39 | -------------------------------------------------------------------------------- /lint/rules/no-global-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止对原生 JavaScript 对象进行赋值。 6 | 7 | 在 JavaScript 中,例如 `String` 和 `Object` 8 | 是原生对象。与任何对象一样,它们可以被重新赋值,但这样做几乎总是不明智的,因为这可能导致意想不到的结果和难以追踪的错误。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | Object = null; 14 | undefined = true; 15 | window = {}; 16 | ``` 17 | -------------------------------------------------------------------------------- /lint/rules/no-implicit-declare-namespace-export.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止在 ["ambient" 命名空间] 中使用隐式导出。 6 | 7 | TypeScript 会隐式导出 ["ambient" 命名空间] 中的所有成员,除非存在命名导出。 8 | 9 | ["ambient" 命名空间]: https://www.typescriptlang.org/docs/handbook/namespaces.html#ambient-namespaces 10 | 11 | **无效示例:** 12 | 13 | ```ts 14 | // foo.ts 或 foo.d.ts 15 | declare namespace ns { 16 | interface ImplicitlyExported {} 17 | export type Exported = true; 18 | } 19 | ``` 20 | 21 | **有效示例:** 22 | 23 | ```ts 24 | // foo.ts 或 foo.d.ts 25 | declare namespace ns { 26 | interface NonExported {} 27 | export {}; 28 | } 29 | 30 | declare namespace ns { 31 | interface Exported {} 32 | export { Exported }; 33 | } 34 | 35 | declare namespace ns { 36 | export interface Exported {} 37 | } 38 | ``` 39 | -------------------------------------------------------------------------------- /lint/rules/no-import-assertions.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在导入属性中使用 `assert` 关键字。 6 | 7 | ES 导入属性(之前称为导入断言)已更改为使用 `with` 关键字。仍支持使用 `assert` 8 | 的旧语法,但已弃用。 9 | 10 | **无效:** 11 | 12 | ```typescript 13 | import obj from "./obj.json" assert { type: "json" }; 14 | import("./obj2.json", { assert: { type: "json" } }); 15 | ``` 16 | 17 | **有效:** 18 | 19 | ```typescript 20 | import obj from "./obj.json" with { type: "json" }; 21 | import("./obj2.json", { with: { type: "json" } }); 22 | ``` 23 | -------------------------------------------------------------------------------- /lint/rules/no-import-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止重新分配导入的模块绑定。 6 | 7 | ES 8 | 模块的导入绑定应被视为只读,因为在代码执行期间修改它们可能会导致运行时错误。这也使得代码可读性变差,维护困难。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | import defaultMod, { namedMod } from "./mod.js"; 14 | import * as modNameSpace from "./mod2.js"; 15 | 16 | defaultMod = 0; 17 | namedMod = true; 18 | modNameSpace.someExportedMember = "hello"; 19 | modNameSpace = {}; 20 | ``` 21 | 22 | **有效示例:** 23 | 24 | ```typescript 25 | import defaultMod, { namedMod } from "./mod.js"; 26 | import * as modNameSpace from "./mod2.js"; 27 | 28 | // 可以设置绑定导入的属性 29 | defaultMod.prop = 1; 30 | namedMod.prop = true; 31 | modNameSpace.someExportedMember.prop = "hello"; 32 | ``` 33 | -------------------------------------------------------------------------------- /lint/rules/no-inner-declarations.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在嵌套块中定义变量或函数。 6 | 7 | 在嵌套块中声明函数可能导致代码可读性降低,并且由于不同 JavaScript 8 | 运行时的兼容性问题,可能会产生意外的结果。这不适用于在嵌套块上下文中有效的命名函数或匿名函数。 9 | 10 | 在嵌套块中使用 `var` 11 | 声明的变量也可能导致代码可读性降低。由于这些变量会被提升到模块的根部,为了清晰起见,最好在根部声明它们。请注意,使用 12 | `let` 或 `const` 声明的变量是块作用域的,因此此规则不适用于它们。 13 | 14 | **无效示例:** 15 | 16 | ```typescript 17 | if (someBool) { 18 | function doSomething() {} 19 | } 20 | 21 | function someFunc(someVal: number): void { 22 | if (someVal > 4) { 23 | var a = 10; 24 | } 25 | } 26 | ``` 27 | 28 | **有效示例:** 29 | 30 | ```typescript 31 | function doSomething() {} 32 | if (someBool) {} 33 | 34 | var a = 10; 35 | function someFunc(someVal: number): void { 36 | var foo = true; 37 | if (someVal > 4) { 38 | let b = 10; 39 | const fn = function doSomethingElse() {}; 40 | } 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /lint/rules/no-invalid-regexp.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在 RegExp 构造函数中指定无效的正则表达式。 6 | 7 | 指定无效的正则表达式字面量会在编译时导致 SyntaxError,然而在 RegExp 8 | 构造函数中指定无效的正则表达式字符串只能在运行时发现。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | const invalidRegExp = new RegExp(")"); 14 | ``` 15 | 16 | **有效示例:** 17 | 18 | ```typescript 19 | const goodRegExp = new RegExp("."); 20 | ``` 21 | -------------------------------------------------------------------------------- /lint/rules/no-irregular-whitespace.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用非空格或非制表符的空白字符。 6 | 7 | 非空格或非制表符的空白字符在代码中很难被发现,因为编辑器通常会以不可见的方式渲染它们。这些不可见字符可能会导致问题或意外行为。有时这些字符会通过复制/粘贴或错误的键盘快捷键无意中添加。 8 | 9 | 以下字符被禁止使用: 10 | 11 | ``` 12 | \u000B - 行制表符 (\v) - 13 | \u000C - 换页符 (\f) - 14 | \u00A0 - 不换行空格 - 15 | \u0085 - 下一行 16 | \u1680 - 欧甘空格标记 17 | \u180E - 蒙古语元音分隔符 - 18 | \ufeff - 零宽度不换行空格 - 19 | \u2000 - 半角空格 20 | \u2001 - 全角空格 21 | \u2002 - 半角空格 - 22 | \u2003 - 全角空格 - 23 | \u2004 - 三分之一全角空格 24 | \u2005 - 四分之一全角空格 25 | \u2006 - 六分之一全角空格 26 | \u2007 - 数字空格 27 | \u2008 - 标点空格 - 28 | \u2009 - 细空格 29 | \u200A - 极细空格 30 | \u200B - 零宽度空格 - 31 | \u2028 - 行分隔符 32 | \u2029 - 段落分隔符 33 | \u202F - 窄不换行空格 34 | \u205f - 中等数学空格 35 | \u3000 - 表意空格 36 | ``` 37 | 38 | 要修复此 linting 39 | 问题,请将上述字符替换为常规空格、制表符或换行符。如果不清楚违规字符的位置,请尝试从头重新输入该行。 40 | -------------------------------------------------------------------------------- /lint/rules/no-misused-new.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在接口中定义 `constructor` 或在类中定义 `new` 方法 6 | 7 | 在接口中指定 `constructor` 或在类中定义 `new` 方法是错误的,应避免这样做。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | class C { 13 | new(): C; 14 | } 15 | 16 | interface I { 17 | constructor(): void; 18 | } 19 | ``` 20 | 21 | **有效示例:** 22 | 23 | ```typescript 24 | class C { 25 | constructor() {} 26 | } 27 | 28 | interface I { 29 | new (): C; 30 | } 31 | ``` 32 | -------------------------------------------------------------------------------- /lint/rules/no-namespace.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在 TypeScript 代码中使用 `namespace` 和 `module` 关键字。 6 | 7 | `namespace` 和 `module` 都被认为是过时的关键字来组织代码。相反,通常更推荐使用 8 | ES2015 模块语法(例如 `import`/`export`)。 9 | 10 | 然而,此规则仍然允许在以下两种情况下使用这些关键字: 11 | 12 | - 它们与 `declare` 关键字一起用于定义 ["ambient" 命名空间] 13 | - 它们写在 TypeScript 的类型定义文件中:`.d.ts` 14 | 15 | ["ambient" 命名空间]: https://www.typescriptlang.org/docs/handbook/namespaces.html#ambient-namespaces 16 | 17 | **无效:** 18 | 19 | ```typescript 20 | // foo.ts 21 | module mod {} 22 | namespace ns {} 23 | ``` 24 | 25 | ```dts 26 | // bar.d.ts 27 | // 在 `.d.ts` 中允许使用 `module` 和 `namespace` 关键字 28 | ``` 29 | 30 | **有效:** 31 | 32 | ```typescript 33 | // foo.ts 34 | declare global {} 35 | declare module mod1 {} 36 | declare module "mod2" {} 37 | declare namespace ns {} 38 | ``` 39 | 40 | ```dts 41 | // bar.d.ts 42 | module mod1 {} 43 | namespace ns1 {} 44 | declare global {} 45 | declare module mod2 {} 46 | declare module "mod3" {} 47 | declare namespace ns2 {} 48 | ``` 49 | -------------------------------------------------------------------------------- /lint/rules/no-new-symbol.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 `new` 操作符与内置的 `Symbol` 一起使用。 6 | 7 | `Symbol` 是通过作为函数调用来创建的,但我们有时会错误地使用 `new` 8 | 操作符来调用它。此规则检测这种错误的 `new` 操作符用法。 9 | 10 | **无效:** 11 | 12 | ```typescript 13 | const foo = new Symbol("foo"); 14 | ``` 15 | 16 | **有效:** 17 | 18 | ```typescript 19 | const foo = Symbol("foo"); 20 | 21 | function func(Symbol: typeof SomeClass) { 22 | // 这里的 `Symbol` 不是内置的 23 | const bar = new Symbol(); 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-node-globals.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 NodeJS 全局对象。 6 | 7 | NodeJS 暴露了一组与 deno(以及 8 | web)不同的全局对象,因此代码不应假设它们可用。相反,根据需要从定义它们的模块中导入这些对象。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | // foo.ts 14 | const buf = Buffer.from("foo", "utf-8"); // Buffer 在 deno 中不是全局对象 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | // foo.ts 21 | import { Buffer } from "node:buffer"; 22 | 23 | const foo = Buffer.from("foo", "utf-8"); 24 | ``` 25 | -------------------------------------------------------------------------------- /lint/rules/no-non-null-asserted-optional-chain.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止在可选链表达式后使用非空断言。 6 | 7 | `?.` 可选链表达式在对象为 `null` 或 `undefined` 时返回 `undefined`。使用 `!` 8 | 非空断言来断言 `?.` 可选链表达式的结果为非空值很可能是错误的。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | foo?.bar!; 14 | foo?.bar()!; 15 | ``` 16 | 17 | **有效示例:** 18 | 19 | ```typescript 20 | foo?.bar; 21 | foo?.bar(); 22 | ``` 23 | -------------------------------------------------------------------------------- /lint/rules/no-non-null-assertion.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用 `!` 后缀运算符进行非空断言。 6 | 7 | TypeScript 的 `!` 非空断言运算符向类型系统断言某个表达式是非空的,即不是 `null` 8 | 或 9 | `undefined`。使用断言来向类型系统传递新信息通常表明代码并不完全类型安全。通常更好的做法是构建程序逻辑,使 10 | TypeScript 能够理解值何时可能为空。 11 | 12 | **无效示例:** 13 | 14 | ```typescript 15 | interface Example { 16 | property?: string; 17 | } 18 | declare const example: Example; 19 | 20 | const includes = example.property!.includes("foo"); 21 | ``` 22 | 23 | **有效示例:** 24 | 25 | ```typescript 26 | interface Example { 27 | property?: string; 28 | } 29 | declare const example: Example; 30 | 31 | const includes = example.property?.includes("foo") ?? false; 32 | ``` 33 | -------------------------------------------------------------------------------- /lint/rules/no-obj-calls.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止像函数一样调用内置的全局对象。 6 | 7 | 以下内置对象不应像函数一样被调用,即使它们看起来像构造函数: 8 | 9 | - `Math` 10 | - `JSON` 11 | - `Reflect` 12 | - `Atomics` 13 | 14 | 像函数一样调用这些对象会导致运行时错误。此规则静态地防止了这种错误的使用方式。 15 | 16 | **无效:** 17 | 18 | ```typescript 19 | const math = Math(); 20 | const newMath = new Math(); 21 | 22 | const json = JSON(); 23 | const newJSON = new JSON(); 24 | 25 | const reflect = Reflect(); 26 | const newReflect = new Reflect(); 27 | 28 | const atomics = Atomics(); 29 | const newAtomics = new Atomics(); 30 | ``` 31 | 32 | **有效:** 33 | 34 | ```typescript 35 | const area = (radius: number): number => Math.PI * radius * radius; 36 | 37 | const parsed = JSON.parse("{ foo: 42 }"); 38 | 39 | const x = Reflect.get({ x: 1, y: 2 }, "x"); 40 | 41 | const first = Atomics.load(foo, 0); 42 | ``` 43 | -------------------------------------------------------------------------------- /lint/rules/no-octal.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止通过以 `0` 开头的数字字面量表示八进制数。 6 | 7 | 八进制数可以通过以 `0` 开头的数字字面量表示,例如 8 | `042`,但这种表示方式常常让程序员感到困惑。这就是为什么 ECMAScript 9 | 的严格模式会对此类表达式抛出 `SyntaxError`。 10 | 11 | 自 ES2015 起,引入了另一种前缀 `0o` 12 | 作为替代方案。在当今的代码中,始终鼓励使用这种新的表示方式。 13 | 14 | **无效:** 15 | 16 | ```typescript 17 | const a = 042; 18 | const b = 7 + 042; 19 | ``` 20 | 21 | **有效:** 22 | 23 | ```typescript 24 | const a = 0o42; 25 | const b = 7 + 0o42; 26 | const c = "042"; 27 | ``` 28 | -------------------------------------------------------------------------------- /lint/rules/no-process-global.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 NodeJS 的 `process` 全局变量。 6 | 7 | NodeJS 和 Deno 暴露了 `process` 8 | 全局变量,但它们很难被工具静态分析,因此代码不应假设它们可用。相反,应使用 9 | `import process from "node:process"`。 10 | 11 | **无效示例:** 12 | 13 | ```typescript 14 | // foo.ts 15 | const foo = process.env.FOO; 16 | ``` 17 | 18 | **有效示例:** 19 | 20 | ```typescript 21 | // foo.ts 22 | import process from "node:process"; 23 | 24 | const foo = process.env.FOO; 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-prototype-builtins.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止直接使用 `Object.prototype` 内置方法。 6 | 7 | 如果对象是通过 `Object.create(null)` 8 | 创建的,它们没有指定的原型。当你假设对象具有 `Object.prototype` 9 | 的属性并尝试调用以下方法时,这可能会导致运行时错误: 10 | 11 | - `hasOwnProperty` 12 | - `isPrototypeOf` 13 | - `propertyIsEnumerable` 14 | 15 | 相反,始终鼓励从 `Object.prototype` 显式调用这些方法。 16 | 17 | **无效:** 18 | 19 | ```typescript 20 | const a = foo.hasOwnProperty("bar"); 21 | const b = foo.isPrototypeOf("bar"); 22 | const c = foo.propertyIsEnumerable("bar"); 23 | ``` 24 | 25 | **有效:** 26 | 27 | ```typescript 28 | const a = Object.prototype.hasOwnProperty.call(foo, "bar"); 29 | const b = Object.prototype.isPrototypeOf.call(foo, "bar"); 30 | const c = Object.prototype.propertyIsEnumerable.call(foo, "bar"); 31 | ``` 32 | -------------------------------------------------------------------------------- /lint/rules/no-redeclare.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用相同名称重新声明变量、函数、参数。 6 | 7 | JavaScript 允许我们使用 `var` 重新声明同名变量,但 8 | 不应使用重新声明,因为它会使变量难以追踪。 9 | 10 | 此外,此 lint 规则还禁止使用 `let` 或 `const` 进行重新声明, 尽管 ESLint 11 | 允许这样做。这很有用,因为我们可以在实际运行代码之前注意到语法错误。 12 | 13 | 对于函数和参数,JavaScript 只是将这些视为运行时错误, 在运行时抛出 14 | `SyntaxError`。静态检测此类错误也很有益。 15 | 16 | **无效示例:** 17 | 18 | ```typescript 19 | var a = 3; 20 | var a = 10; 21 | 22 | let b = 3; 23 | let b = 10; 24 | 25 | const c = 3; 26 | const c = 10; 27 | 28 | function d() {} 29 | function d() {} 30 | 31 | function e(arg: number) { 32 | var arg: number; 33 | } 34 | 35 | function f(arg: number, arg: string) {} 36 | ``` 37 | 38 | **有效示例:** 39 | 40 | ```typescript 41 | var a = 3; 42 | function f() { 43 | var a = 10; 44 | } 45 | 46 | if (foo) { 47 | let b = 2; 48 | } else { 49 | let b = 3; 50 | } 51 | ``` 52 | -------------------------------------------------------------------------------- /lint/rules/no-self-assign.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止自我赋值。 6 | 7 | 像 `a = a;` 8 | 这样的自我赋值完全没有效果。如果代码中存在自我赋值,很可能意味着作者仍在重构过程中,还有剩余的工作需要完成。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | a = a; 14 | [a] = [a]; 15 | [a, b] = [a, b]; 16 | [a, b] = [a, c]; 17 | [a, ...b] = [a, ...b]; 18 | a.b = a.b; 19 | ``` 20 | 21 | **有效示例:** 22 | 23 | ```typescript 24 | let a = a; 25 | a += a; 26 | a = [a]; 27 | [a, b] = [b, a]; 28 | a.b = a.c; 29 | ``` 30 | -------------------------------------------------------------------------------- /lint/rules/no-self-compare.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止在比较的两边完全相同的情况下进行比较。 6 | 7 | 将变量或值与自身进行比较通常是一个错误,可能是打字错误或重构错误。这会让读者感到困惑,并可能引入运行时错误。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | if (x === x) { 13 | } 14 | if ("x" === "x") { 15 | } 16 | if (a.b === a.b) { 17 | } 18 | if (a["b"] === a["b"]) { 19 | } 20 | ``` 21 | 22 | **有效示例:** 23 | 24 | ```typescript 25 | if (x === y) { 26 | } 27 | if ("x" === "y") { 28 | } 29 | if (a.b === a.c) { 30 | } 31 | if (a["b"] === a["c"]) { 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /lint/rules/no-sloppy-imports.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 强制要求在模块说明符中明确指定路径引用。 6 | 7 | 非明确的说明符是模糊的,并且需要在每次运行时探测正确的文件路径,这会带来性能开销。 8 | 9 | 注意:此 lint 规则仅在启用 `--unstable-sloppy-imports` 时生效。 10 | 11 | ### 无效示例: 12 | 13 | ```typescript 14 | import { add } from "./math/add"; 15 | import { ConsoleLogger } from "./loggers"; 16 | ``` 17 | 18 | ### 有效示例: 19 | 20 | ```typescript 21 | import { add } from "./math/add.ts"; 22 | import { ConsoleLogger } from "./loggers/index.ts"; 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/no-slow-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [jsr] 3 | --- 4 | 5 | 强制使用明确或可以简单推断的类型。 6 | 7 | 阅读更多:https://jsr.io/docs/about-slow-types 8 | -------------------------------------------------------------------------------- /lint/rules/no-sparse-arrays.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用稀疏数组。 6 | 7 | 稀疏数组是指包含 _空槽_ 的数组,这些空槽可能会被处理为 `undefined` 8 | 值或被数组方法跳过,这可能导致意外的行为: 9 | 10 | ```typescript 11 | [1, , 2].join(); // => '1,,2' 12 | [1, undefined, 2].join(); // => '1,,2' 13 | 14 | [1, , 2].flatMap((item) => item); // => [1, 2] 15 | [1, undefined, 2].flatMap((item) => item); // => [1, undefined, 2] 16 | ``` 17 | 18 | **无效:** 19 | 20 | ```typescript 21 | const items = ["foo", , "bar"]; 22 | ``` 23 | 24 | **有效:** 25 | 26 | ```typescript 27 | const items = ["foo", "bar"]; 28 | ``` 29 | -------------------------------------------------------------------------------- /lint/rules/no-sync-fn-in-async-fn.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止在异步函数中使用同步函数。 6 | 7 | 使用像 `Deno.readTextFileSync` 这样的同步函数会阻塞 deno 8 | 的事件循环,因此不建议在异步函数中使用它,因为它会阻止所有其他异步任务的进展。 9 | 10 | **无效示例:** 11 | 12 | ```javascript 13 | async function foo() { 14 | Deno.readTextFileSync(""); 15 | } 16 | 17 | const fooFn = async function foo() { 18 | Deno.readTextFileSync(""); 19 | }; 20 | 21 | const fooFn = async () => { 22 | Deno.readTextFileSync(""); 23 | }; 24 | ``` 25 | 26 | **有效示例:** 27 | 28 | ```javascript 29 | async function foo() { 30 | await Deno.readTextFile(""); 31 | } 32 | 33 | function foo() { 34 | Deno.readTextFileSync(""); 35 | } 36 | 37 | const fooFn = function foo() { 38 | Deno.readTextFileSync(""); 39 | }; 40 | 41 | const fooFn = () => { 42 | Deno.readTextFileSync(""); 43 | }; 44 | ``` 45 | -------------------------------------------------------------------------------- /lint/rules/no-this-before-super.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在构造函数中调用 `super()` 之前使用 `this` 或 `super`。 6 | 7 | 在派生类的构造函数中,在调用 `super()` 之前访问 `this` 或 `super` 会导致 8 | [`ReferenceError`]。为了防止这种情况,该 lint 规则会检查在构造函数中调用 9 | `super()` 之前是否存在对 `this` 或 `super` 的访问。 10 | 11 | [`ReferenceError`]: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError 12 | 13 | **无效示例:** 14 | 15 | ```typescript 16 | class A extends B { 17 | constructor() { 18 | this.foo = 0; 19 | super(); 20 | } 21 | } 22 | 23 | class C extends D { 24 | constructor() { 25 | super.foo(); 26 | super(); 27 | } 28 | } 29 | ``` 30 | 31 | **有效示例:** 32 | 33 | ```typescript 34 | class A extends B { 35 | constructor() { 36 | super(); 37 | this.foo = 0; 38 | } 39 | } 40 | 41 | class C extends D { 42 | constructor() { 43 | super(); 44 | super.foo(); 45 | } 46 | } 47 | 48 | class E { 49 | constructor() { 50 | this.foo = 0; 51 | } 52 | } 53 | ``` 54 | -------------------------------------------------------------------------------- /lint/rules/no-throw-literal.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止将字面量作为异常抛出。 6 | 7 | 最佳实践是仅 `throw` `Error` 对象本身或以 `Error` 8 | 对象为基础对象的用户自定义异常对象。`Error` 9 | 对象的基本优势在于它们会自动跟踪其构建和起源的位置。 10 | 11 | **无效示例:** 12 | 13 | ```typescript 14 | throw "error"; 15 | throw 0; 16 | throw undefined; 17 | throw null; 18 | ``` 19 | 20 | **有效示例:** 21 | 22 | ```typescript 23 | throw new Error("error"); 24 | ``` 25 | -------------------------------------------------------------------------------- /lint/rules/no-top-level-await.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用顶层 await 表达式。 6 | 7 | 在通过 dnt 分发 CommonJS/UMD 时,不能使用顶层 await。 8 | 9 | **无效:** 10 | 11 | ```typescript 12 | await foo(); 13 | for await (item of items) {} 14 | ``` 15 | 16 | **有效:** 17 | 18 | ```typescript 19 | async function foo() { 20 | await task(); 21 | } 22 | async function foo() { 23 | for await (item of items) {} 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /lint/rules/no-undef.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用未声明的变量。 6 | 7 | **无效示例:** 8 | 9 | ```typescript 10 | const foo = someFunction(); 11 | const bar = a + 1; 12 | ``` 13 | -------------------------------------------------------------------------------- /lint/rules/no-unsafe-finally.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止在 `finally` 块中使用控制流语句。 6 | 7 | 使用控制流语句(`return`、`throw`、`break` 和 `continue`)会覆盖可能在 `try` 或 8 | `catch` 块中使用的任何控制流语句,这通常不是期望的行为。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | let foo = function () { 14 | try { 15 | return 1; 16 | } catch (err) { 17 | return 2; 18 | } finally { 19 | return 3; 20 | } 21 | }; 22 | ``` 23 | 24 | ```typescript 25 | let foo = function () { 26 | try { 27 | return 1; 28 | } catch (err) { 29 | return 2; 30 | } finally { 31 | throw new Error(); 32 | } 33 | }; 34 | ``` 35 | 36 | **有效示例:** 37 | 38 | ```typescript 39 | let foo = function () { 40 | try { 41 | return 1; 42 | } catch (err) { 43 | return 2; 44 | } finally { 45 | console.log("hola!"); 46 | } 47 | }; 48 | ``` 49 | -------------------------------------------------------------------------------- /lint/rules/no-unsafe-negation.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止将否定运算符 `!` 作为关系运算符的左操作数使用。 6 | 7 | 在以下运算符的左操作数中出现 `!` 8 | 运算符时,由于运算符优先级的原因,有时会导致意外行为: 9 | 10 | - `in` 运算符 11 | - `instanceof` 运算符 12 | 13 | 例如,当开发者编写类似 `!key in someObject` 的代码时,他们很可能希望它的行为与 14 | `!(key in someObject)` 相同,但实际上它的行为类似于 `(!key) in someObject`。此 15 | lint 规则会警告此类 `!` 运算符的使用,以减少混淆。 16 | 17 | **无效示例:** 18 | 19 | 20 | 21 | ```typescript 22 | if (!key in object) {} 23 | if (!foo instanceof Foo) {} 24 | ``` 25 | 26 | **有效示例:** 27 | 28 | ```typescript 29 | if (!(key in object)) {} 30 | if (!(foo instanceof Foo)) {} 31 | if ((!key) in object) {} 32 | if ((!foo) instanceof Foo) {} 33 | ``` 34 | -------------------------------------------------------------------------------- /lint/rules/no-unused-labels.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止未使用的标签。 6 | 7 | 声明但从未使用的标签很可能是开发者的错误。如果该标签旨在被使用,那么编写代码以确保它被使用。否则,请移除该标签。 8 | 9 | **无效示例:** 10 | 11 | ```typescript 12 | LABEL1: 13 | while (true) { 14 | console.log(42); 15 | } 16 | 17 | LABEL2: 18 | for (let i = 0; i < 5; i++) { 19 | console.log(42); 20 | } 21 | 22 | LABEL3: 23 | for (const x of xs) { 24 | console.log(x); 25 | } 26 | ``` 27 | 28 | **有效示例:** 29 | 30 | ```typescript 31 | LABEL1: 32 | while (true) { 33 | console.log(42); 34 | break LABEL1; 35 | } 36 | 37 | LABEL2: 38 | for (let i = 0; i < 5; i++) { 39 | console.log(42); 40 | continue LABEL2; 41 | } 42 | 43 | for (const x of xs) { 44 | console.log(x); 45 | } 46 | ``` 47 | -------------------------------------------------------------------------------- /lint/rules/no-useless-rename.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止无用的重命名操作,其中原始名称和新名称完全相同。这通常是重构过程中的遗留物,可以安全地移除。 6 | 7 | **无效示例:** 8 | 9 | ```ts 10 | import { foo as foo } from "foo"; 11 | const { foo: foo } = obj; 12 | export { foo as foo }; 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```ts 18 | import { foo as bar } from "foo"; 19 | const { foo: bar } = obj; 20 | export { foo as bar }; 21 | ``` 22 | -------------------------------------------------------------------------------- /lint/rules/no-var.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 强制使用块作用域变量,而不是更容易出错的功能作用域变量。块作用域变量使用 `const` 6 | 和 `let` 关键字定义。 7 | 8 | `const` 和 `let` 9 | 关键字确保使用这些关键字定义的变量在其块作用域之外不可访问。另一方面,使用 `var` 10 | 关键字定义的变量仅受其功能作用域的限制。 11 | 12 | **无效:** 13 | 14 | ```typescript 15 | var foo = "bar"; 16 | ``` 17 | 18 | **有效:** 19 | 20 | ```typescript 21 | const foo = 1; 22 | let bar = 2; 23 | ``` 24 | -------------------------------------------------------------------------------- /lint/rules/no-window.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 `window` 对象。 6 | 7 | 在 Deno 中,`window` 全局变量不再可用。Deno 没有 `window`,并且 8 | `typeof window === "undefined"` 通常用于判断代码是否在浏览器中运行。 9 | 10 | **无效示例:** 11 | 12 | ```typescript 13 | const a = await window.fetch("https://deno.land"); 14 | 15 | const b = window.Deno.metrics(); 16 | console.log(window); 17 | 18 | window.addEventListener("load", () => { 19 | console.log("Loaded."); 20 | }); 21 | ``` 22 | 23 | **有效示例:** 24 | 25 | ```typescript 26 | const a1 = await fetch("https://deno.land"); 27 | const a2 = await globalThis.fetch("https://deno.land"); 28 | const a3 = await self.fetch("https://deno.land"); 29 | 30 | const b1 = Deno.metrics(); 31 | const b2 = globalThis.Deno.metrics(); 32 | const b3 = self.Deno.metrics(); 33 | console.log(globalThis); 34 | 35 | addEventListener("load", () => { 36 | console.log("Loaded."); 37 | }); 38 | ``` 39 | -------------------------------------------------------------------------------- /lint/rules/no-with.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用 `with` 语句。 6 | 7 | 不推荐使用 `with` 语句,因为它可能是导致混淆的 bug 8 | 和兼容性问题的根源。更多详情,请参阅 [with - JavaScript | MDN]。 9 | 10 | [with - JavaScript | MDN]: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/with 11 | 12 | **无效示例:** 13 | 14 | ```typescript 15 | with (someVar) { 16 | console.log("foo"); 17 | } 18 | ``` 19 | -------------------------------------------------------------------------------- /lint/rules/prefer-as-const.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 建议使用 const 断言(`as const`)而不是显式指定字面量类型或使用类型断言。 6 | 7 | 在声明一个原始字面量类型的新变量时,有三种方式: 8 | 9 | 1. 添加显式类型注解 10 | 2. 使用普通类型断言(如 `as "foo"` 或 `<"foo">`) 11 | 3. 使用 const 断言(`as const`) 12 | 13 | 此 lint 规则建议使用 const 断言,因为它通常会使代码更安全。有关 const 14 | 断言的更多详细信息,请参阅 15 | [官方手册](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions)。 16 | 17 | **无效:** 18 | 19 | ```typescript 20 | let a: 2 = 2; // 类型注解 21 | let b = 2 as 2; // 类型断言 22 | let c = <2> 2; // 类型断言 23 | let d = { foo: 1 as 1 }; // 类型断言 24 | ``` 25 | 26 | **有效:** 27 | 28 | ```typescript 29 | let a = 2 as const; 30 | let b = 2 as const; 31 | let c = 2 as const; 32 | let d = { foo: 1 as const }; 33 | 34 | let x = 2; 35 | let y: string = "hello"; 36 | let z: number = someVariable; 37 | ``` 38 | -------------------------------------------------------------------------------- /lint/rules/prefer-namespace-keyword.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 建议在声明 TypeScript 模块时使用 `namespace` 关键字而非 `module` 关键字。 6 | 7 | TypeScript 支持使用 `module` 关键字来组织代码,但这种表述可能会与 ECMAScript 8 | 的模块概念产生混淆。自 TypeScript v1.5 起,它为我们提供了替代关键字 9 | `namespace`,鼓励我们在编写 TypeScript 时始终使用 `namespace`。更多详情请参阅 10 | [TypeScript v1.5 发布说明](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-5.html#namespace-keyword)。 11 | 12 | **无效示例:** 13 | 14 | ```typescript 15 | module modA {} 16 | 17 | declare module modB {} 18 | ``` 19 | 20 | **有效示例:** 21 | 22 | ```typescript 23 | namespace modA {} 24 | 25 | // "ambient modules" 是允许的 26 | // https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules 27 | declare module "modB"; 28 | declare module "modC" {} 29 | ``` 30 | -------------------------------------------------------------------------------- /lint/rules/react-no-danger-with-children.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [react, fresh] 3 | --- 4 | 5 | 将 JSX 子元素与 `dangerouslySetInnerHTML` 一起使用是无效的,因为它们将被忽略。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 |
    hello" }}> 11 |

    this will never be rendered

    12 |
    ; 13 | ``` 14 | 15 | **有效示例:** 16 | 17 | ```tsx 18 |
    hello" }} />; 19 | ``` 20 | -------------------------------------------------------------------------------- /lint/rules/react-no-danger.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [react, fresh] 3 | --- 4 | 5 | 防止使用 `dangerouslySetInnerHTML`,如果使用不当可能导致 XSS 漏洞。 6 | 7 | **无效示例:** 8 | 9 | ```tsx 10 | const hello =
    ; 11 | ``` 12 | 13 | **有效示例:** 14 | 15 | ```tsx 16 | const hello =
    Hello World!
    ; 17 | ``` 18 | -------------------------------------------------------------------------------- /lint/rules/react-rules-of-hooks.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [react, fresh] 3 | --- 4 | 5 | 确保在 React/Preact 组件中正确调用 6 | hooks。它们必须在组件的顶层调用,而不是在条件语句或循环内部。 7 | 8 | **无效示例:** 9 | 10 | ```tsx 11 | // 错误:在条件内部调用 12 | function MyComponent() { 13 | if (condition) { 14 | const [count, setCount] = useState(0); 15 | } 16 | } 17 | 18 | // 错误:在 for 循环内部调用 19 | function MyComponent() { 20 | for (const item of items) { 21 | const [count, setCount] = useState(0); 22 | } 23 | } 24 | 25 | // 错误:在 while 循环内部调用 26 | function MyComponent() { 27 | while (condition) { 28 | const [count, setCount] = useState(0); 29 | } 30 | } 31 | 32 | // 错误:在条件之后调用 33 | function MyComponent() { 34 | if (condition) { 35 | // ... 36 | } 37 | 38 | const [count, setCount] = useState(0); 39 | } 40 | ``` 41 | 42 | **有效示例:** 43 | 44 | ```tsx 45 | function MyComponent() { 46 | const [count, setCount] = useState(0); 47 | } 48 | ``` 49 | -------------------------------------------------------------------------------- /lint/rules/require-yield.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止使用没有 `yield` 的生成器函数。 6 | 7 | JavaScript 提供了通过 `function*` 8 | 表示的生成器函数,我们可以在其中暂停并在稍后恢复函数的执行。在这些暂停点,我们使用 9 | `yield` 关键字。换句话说,创建不包含 `yield` 10 | 关键字的生成器函数毫无意义,因为这样的函数可以写成普通函数。 11 | 12 | **无效示例:** 13 | 14 | ```typescript 15 | function* f1() { 16 | return "f1"; 17 | } 18 | ``` 19 | 20 | **有效示例:** 21 | 22 | ```typescript 23 | function* f1() { 24 | yield "f1"; 25 | } 26 | 27 | // 允许空的生成器函数 28 | function* f2() {} 29 | 30 | function f3() { 31 | return "f3"; 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /lint/rules/single-var-declarator.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止在同一声明语句中定义多个变量。 6 | 7 | **无效示例:** 8 | 9 | ```typescript 10 | const foo = 1, bar = "2"; 11 | ``` 12 | 13 | **有效示例:** 14 | 15 | ```typescript 16 | const foo = 1; 17 | const bar = "2"; 18 | ``` 19 | -------------------------------------------------------------------------------- /lint/rules/triple-slash-reference.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [] 3 | --- 4 | 5 | 禁止使用某些三斜杠指令,推荐使用 ES6 风格的 import 声明。 6 | 7 | TypeScript 的 `///` 8 | 三斜杠引用是一种指示文件中可以使用另一个模块的类型的方式。通常不推荐使用三斜杠引用类型指令,而是推荐使用 9 | ECMAScript 模块导入。此规则报告 10 | `/// `、`/// ` 或 11 | `/// ` 指令的使用。 12 | 13 | **无效:** 14 | 15 | ```typescript 16 | /// 17 | import * as foo from "foo"; 18 | ``` 19 | 20 | **有效:** 21 | 22 | ```typescript 23 | import * as foo from "foo"; 24 | ``` 25 | -------------------------------------------------------------------------------- /lint/rules/use-isnan.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [recommended] 3 | --- 4 | 5 | 禁止与 `NaN` 进行比较。 6 | 7 | 由于 `NaN` 在 JavaScript 中是独一无二的,它不等于任何值,包括它自己,因此与 8 | `NaN` 进行比较的结果会令人困惑: 9 | 10 | - `NaN === NaN` 或 `NaN == NaN` 的值为 `false` 11 | - `NaN !== NaN` 或 `NaN != NaN` 的值为 `true` 12 | 13 | 因此,该规则要求你使用 `isNaN()` 或 `Number.isNaN()` 来判断某个值是否为 `NaN`。 14 | 15 | **无效示例:** 16 | 17 | ```typescript 18 | if (foo == NaN) { 19 | // ... 20 | } 21 | 22 | if (foo != NaN) { 23 | // ... 24 | } 25 | 26 | switch (NaN) { 27 | case foo: 28 | // ... 29 | } 30 | 31 | switch (foo) { 32 | case NaN: 33 | // ... 34 | } 35 | ``` 36 | 37 | **有效示例:** 38 | 39 | ```typescript 40 | if (isNaN(foo)) { 41 | // ... 42 | } 43 | 44 | if (!isNaN(foo)) { 45 | // ... 46 | } 47 | ``` 48 | -------------------------------------------------------------------------------- /lint/rules/verbatim-module-syntax.md: -------------------------------------------------------------------------------- 1 | --- 2 | tags: [jsr] 3 | --- 4 | 5 | 强制将类型导入声明为类型导入。 6 | 7 | 此规则确保在启用 `verbatimModuleSyntax` TypeScript 8 | 编译器选项时代码能够正常工作。这对于分发 TypeScript 9 | 代码的库非常有用,以便在更多场景中工作。 10 | 11 | **无效示例:** 12 | 13 | ```typescript 14 | import { Person } from "./person.ts"; 15 | 16 | const person: Person = { 17 | name: "David", 18 | }; 19 | console.log(person); 20 | ``` 21 | 22 | ```typescript 23 | import { output, Person } from "./person.ts"; 24 | 25 | const person: Person = { 26 | name: "David", 27 | }; 28 | output(person); 29 | ``` 30 | 31 | **有效示例:** 32 | 33 | ```typescript 34 | import type { Person } from "./person.ts"; 35 | 36 | const person: Person = { 37 | name: "David", 38 | }; 39 | console.log(person); 40 | ``` 41 | 42 | ```typescript 43 | import { output, type Person } from "./person.ts"; 44 | 45 | const person: Person = { 46 | name: "David", 47 | }; 48 | output(person); 49 | ``` 50 | -------------------------------------------------------------------------------- /lint_rules.client.ts: -------------------------------------------------------------------------------- 1 | const searchbar = document.getElementById("lint-rule-search"); 2 | 3 | if (searchbar) { 4 | searchbar.addEventListener("input", (e) => { 5 | const query = e.currentTarget?.value; 6 | 7 | const allBoxes = document.querySelectorAll(".lint-rule-box"); 8 | 9 | for (const box of allBoxes) { 10 | if (!box.id.includes(query)) { 11 | box.style.display = "none"; 12 | } else { 13 | box.style.display = "block"; 14 | } 15 | } 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /lume.ts: -------------------------------------------------------------------------------- 1 | import "lume/cli.ts"; 2 | -------------------------------------------------------------------------------- /markdown-it/codeblock-title.ts: -------------------------------------------------------------------------------- 1 | // deno-lint-ignore-file no-explicit-any 2 | 3 | export default function codeblockTitlePlugin(md: any) { 4 | const defaultRender = md.renderer.rules.fence; 5 | 6 | md.renderer.rules.fence = function ( 7 | tokens: any[], 8 | idx: number, 9 | options, 10 | env, 11 | self, 12 | ) { 13 | const render = defaultRender(tokens, idx, options, env, self); 14 | 15 | const maybeTitle = (tokens[idx].info ?? "").match(/title="(.+?)"/)?.[1]; 16 | if (maybeTitle) { 17 | return `
    ${maybeTitle}
    ${render}
    `; 18 | } 19 | 20 | return render; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /markdown-it/replacer.ts: -------------------------------------------------------------------------------- 1 | // deno-lint-ignore-file no-explicit-any 2 | import REPLACEMENTS from "../replacements.json" with { type: "json" }; 3 | 4 | export default function replacerPlugin(md: any) { 5 | md.core.ruler.before("inline", "replacer", (state) => { 6 | state.tokens.forEach((token) => { 7 | Object.entries(REPLACEMENTS).forEach(([key, value]) => { 8 | token.content = token.content.replace( 9 | new RegExp(`\\$${key}`, "g"), 10 | value, 11 | ); 12 | }); 13 | }); 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /middleware/functionRoutes.ts: -------------------------------------------------------------------------------- 1 | import type { RequestHandler } from "lume/core/server.ts"; 2 | import defaultRoutes from "./functions/routes.ts"; 3 | 4 | export default function createRoutingMiddleware( 5 | routeObject: Record = defaultRoutes, 6 | ) { 7 | return function functionRoutesMiddleware( 8 | req: Request, 9 | next: RequestHandler, 10 | ): Promise { 11 | const url = new URL(req.url); 12 | const route = routeObject[url.pathname]; 13 | return route ? route(req) : next(req); 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /middleware/functions/feedback_test.ts: -------------------------------------------------------------------------------- 1 | import { loadSync } from "@std/dotenv"; 2 | loadSync({ export: true }); 3 | 4 | import { assertEquals } from "@std/assert"; 5 | import feedbackRequestHandler from "./feedback.ts"; 6 | 7 | Deno.test("integration: can insert record into feedback google sheet", async () => { 8 | const request = new Request("http://localhost:8000/_api/send-feedback"); 9 | 10 | const result = await feedbackRequestHandler(request); 11 | 12 | assertEquals(result.status, 200); 13 | }); 14 | -------------------------------------------------------------------------------- /middleware/functions/health.ts: -------------------------------------------------------------------------------- 1 | export default async function healthRequestHandler( 2 | _: Request, 3 | ): Promise { 4 | return new Response("OK", { status: 200 }); 5 | } 6 | -------------------------------------------------------------------------------- /middleware/functions/routes.ts: -------------------------------------------------------------------------------- 1 | import type { RequestHandler } from "lume/core/server.ts"; 2 | import healthRequestHandler from "./health.ts"; 3 | import feedbackRequestHandler from "./feedback.ts"; 4 | 5 | export default { 6 | "/_api/health": healthRequestHandler, 7 | "/_api/send-feedback": feedbackRequestHandler, 8 | } satisfies Record; 9 | -------------------------------------------------------------------------------- /middleware/null.ts: -------------------------------------------------------------------------------- 1 | import type { RequestHandler } from "lume/core/server.ts"; 2 | 3 | export default function nullMiddleware( 4 | req: Request, 5 | next: RequestHandler, 6 | ): Promise { 7 | return next(req); 8 | } 9 | -------------------------------------------------------------------------------- /prism.ts: -------------------------------------------------------------------------------- 1 | import Prism from "npm:prismjs@1.29.0"; 2 | import "npm:prismjs@1.29.0/components/prism-typescript.js"; 3 | import "npm:prismjs@1.29.0/components/prism-diff.js"; 4 | import "npm:prismjs@1.29.0/components/prism-json.js"; 5 | import "npm:prismjs@1.29.0/components/prism-bash.js"; 6 | import "npm:prismjs@1.29.0/components/prism-json5.js"; 7 | import "npm:prismjs@1.29.0/components/prism-jsx.js"; 8 | import "npm:prismjs@1.29.0/components/prism-tsx.js"; 9 | 10 | Prism.languages.jsonc = Prism.languages.json5; 11 | 12 | export default Prism; 13 | -------------------------------------------------------------------------------- /reference/_components/Anchor.tsx: -------------------------------------------------------------------------------- 1 | import type { AnchorCtx } from "@deno/doc"; 2 | 3 | export default function ({ anchor }: { anchor: AnchorCtx }) { 4 | return ( 5 | 11 | # 12 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /reference/_components/Arrow.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 | 10 | 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /reference/_components/Check.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 | 15 | 16 | 17 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /reference/_components/Copy.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 | 11 | 12 | 13 | 17 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /reference/_components/Deprecated.tsx: -------------------------------------------------------------------------------- 1 | export default function ({ markdownContent }) { 2 | if (markdownContent === null) { 3 | return null; 4 | } 5 | 6 | return ( 7 |
    8 |
    9 | 已弃用 10 |
    11 | 12 | {/*markdown rendering*/} 13 | {markdownContent && ( 14 |
    15 | )} 16 |
    17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /reference/_components/DocBlockSubtitleInterface.tsx: -------------------------------------------------------------------------------- 1 | import type { DocBlockSubtitleInterfaceValueCtx } from "@deno/doc"; 2 | 3 | export default function ( 4 | { subtitle }: { subtitle: DocBlockSubtitleInterfaceValueCtx }, 5 | ) { 6 | return ( 7 |
    8 | extends{" "} 9 | {subtitle.extends.map((item, i) => ( 10 | <> 11 | 12 | {/*typedef rendering*/} 13 | {i > 1 && ,{" "}} 14 | 15 | ))} 16 |
    17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /reference/_components/DocNodeKindIcon.tsx: -------------------------------------------------------------------------------- 1 | import type { DocNodeKindCtx } from "@deno/doc"; 2 | 3 | export default function ({ kinds }: { kinds: DocNodeKindCtx[] }) { 4 | return ( 5 |
    6 | {kinds.map((item, index) => ( 7 |
    12 | {item.char} 13 |
    14 | ))} 15 |
    16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /reference/_components/Example.tsx: -------------------------------------------------------------------------------- 1 | import type { ExampleCtx } from "@deno/doc"; 2 | 3 | export default function ( 4 | { comp, example }: { comp: any; example: ExampleCtx }, 5 | ) { 6 | return ( 7 |
    8 | 9 | 10 | {/*markdown rendering; usually not markdown but just a string, but some cases might be markdown (ie the title contains inline-code)*/} 11 | 12 | {/*markdown rendering*/} 13 |
    14 |
    15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /reference/_components/IndexSignature.tsx: -------------------------------------------------------------------------------- 1 | import type { DocEntryCtx } from "@deno/doc"; 2 | 3 | export default function ( 4 | { comp, indexSignature }: { comp: any; indexSignature: DocEntryCtx }, 5 | ) { 6 | return ( 7 |
    8 | 9 | {indexSignature.readonly && readonly} 10 | {/* param rendering */} 11 | [ 12 | ] 13 | {/* typedef rendering */} 14 | 15 |
    16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /reference/_components/ModuleDoc.tsx: -------------------------------------------------------------------------------- 1 | import type { ModuleDocCtx } from "@deno/doc"; 2 | 3 | export default function ( 4 | { comp, moduleDoc }: { comp: any; moduleDoc: ModuleDocCtx }, 5 | ) { 6 | return ( 7 |
    8 |
    9 | {moduleDoc.deprecated && ( 10 | 11 | )} 12 | 13 |
    14 |
    15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /reference/_components/RefNav.tsx: -------------------------------------------------------------------------------- 1 | export default function (data: Lume.Data, url: string) { 2 | return ( 3 | 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /reference/_components/Section.css: -------------------------------------------------------------------------------- 1 | h1.ref-h1 { 2 | font-size: 1.6rem; 3 | border: 0; 4 | padding: 0; 5 | } 6 | 7 | code.inline-code-block { 8 | display: inline-block; 9 | margin-bottom: 1rem; 10 | padding: 1rem; 11 | } 12 | 13 | hr.hr { 14 | height: 1px; 15 | } 16 | 17 | .anchorable-heading .context-link { 18 | color: hsl(var(--foreground-primary)); 19 | } 20 | -------------------------------------------------------------------------------- /reference/_components/See.tsx: -------------------------------------------------------------------------------- 1 | export default function ({ sees }: { sees: string[] }) { 2 | return ( 3 |
      4 | {/*markdown rendering*/} 5 | {sees.map((see) =>
    • )} 6 |
    7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /reference/_components/SymbolContent.tsx: -------------------------------------------------------------------------------- 1 | import type { SymbolContentCtx } from "@deno/doc"; 2 | 3 | export default function ( 4 | { symbolContent, comp }: { comp: any; symbolContent: SymbolContentCtx }, 5 | ) { 6 | return ( 7 |
    8 | {/*markdown rendering*/} 9 | {symbolContent.docs && ( 10 |
    11 | )} 12 | 13 | {symbolContent.sections.map((section) => ( 14 | 15 | ))} 16 |
    17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /reference/_components/UsageLarge.tsx: -------------------------------------------------------------------------------- 1 | import type { UsagesCtx } from "@deno/doc"; 2 | 3 | export default function ({ usages }: { usages: UsagesCtx | null }) { 4 | if (!usages?.usages?.[0]) { 5 | return null; 6 | } 7 | 8 | return ( 9 |
    10 |

    Usage in Deno

    11 | 12 | {/*markdown rendering*/} 13 |
    14 |
    15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /reference_gen/deno-doc.ts: -------------------------------------------------------------------------------- 1 | import { doc, generateHtmlAsJSON } from "@deno/doc"; 2 | import { 3 | hrefResolver, 4 | renderMarkdown, 5 | stripMarkdown, 6 | } from "./common.ts"; 7 | import categoryDocs from "./deno-categories.json" with { type: "json" }; 8 | 9 | const url = import.meta.resolve("./types/deno.d.ts"); 10 | 11 | console.log("Generating doc nodes..."); 12 | 13 | const nodes = await doc([url], { includeAll: true }); 14 | 15 | console.log("Generating json structure..."); 16 | 17 | const files = await generateHtmlAsJSON(nodes, { 18 | packageName: "Deno", 19 | categoryDocs, 20 | disableSearch: true, 21 | hrefResolver, 22 | usageComposer: { 23 | singleMode: true, 24 | compose(_currentResolve, _usageToMd) { 25 | return new Map(); 26 | }, 27 | }, 28 | markdownRenderer: renderMarkdown, 29 | markdownStripper: stripMarkdown, 30 | }); 31 | 32 | await Deno.writeTextFile("./gen/deno.json", JSON.stringify(files)); 33 | -------------------------------------------------------------------------------- /reference_gen/node-default-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "assert": "assert" 3 | } 4 | -------------------------------------------------------------------------------- /reference_gen/node-exclude-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "assert.d.ts": [ 3 | "assert" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /reference_gen/node-symbol-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "buffer": { 3 | "Blob": "/api/web/~/Blob" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/assert.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/async_hooks.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | AsyncResource: The AsyncResource implementation is a non-functional stub. 4 | executionAsyncId: The executionAsyncId implementation is a non-functional stub. 5 | createHook: The createHook implementation is a non-functional stub. 6 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/buffer.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/child_process.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/cluster.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: All exports are non-functional stubs. 3 | symbols: 4 | "*": This symbol is a non-functional stub. 5 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/console.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/crypto.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | symbols: 3 | Certificate: The methods are non-functional stubs. 4 | generateKeyPair: The `x448` option is not supported. 5 | generatePrime: The `safe`, `add` and `rem` option is not supported. 6 | KeyObject: | 7 | The following are non-functional stubs: 8 | - from 9 | - symmetricKeySize 10 | - equals 11 | - export 12 | publicDecrypt: This symbol is a non-functional stub. 13 | secureHeapUsed: This symbol is a non-functional stub. 14 | setEngine: This symbol is a non-functional stub. 15 | ECDH: The `convertKey` method is a non-functional sub. 16 | Sign: The `sign` and `verify` methods are not supported with non BinaryLike input. 17 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/dgram.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | Socket: | 4 | The following methods are non-functional stubs: 5 | - addMembership 6 | - addSourceSpecificMembership 7 | - dropMembership 8 | - dropSourceSpecificMembership 9 | - setBroadcast 10 | - setMulticastInterface 11 | - setMulticastLoopback 12 | - setMulticastTtl 13 | - setTtl 14 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/diagnostics_channel.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/dns.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | resolve: The `ttl` option is not supported. 4 | resolve4: The `ttl` option is not supported. 5 | resolve6: The `ttl` option is not supported. 6 | resolveCname: The `ttl` option is not supported. 7 | resolveCaa: The `ttl` option is not supported. 8 | resolveMx: The `ttl` option is not supported. 9 | resolveNaptr: The `ttl` option is not supported. 10 | resolveNs: The `ttl` option is not supported. 11 | resolvePtr: The `ttl` option is not supported. 12 | resolveSoa: The `ttl` option is not supported. 13 | resolveSrv: The `ttl` option is not supported. 14 | resolveTxt: The `ttl` option is not supported. 15 | resolveAny: The `ttl` option is not supported. 16 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/domain.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: | 3 | All exports are non-functional stubs. 4 | This is a deprecated Node module. 5 | 6 | symbols: 7 | "*": This symbol is a non-functional stub. 8 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/events.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/fs--promises.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | symbols: 3 | lchmod: The lchmod implementation is a not implemented. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/fs.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | symbols: 3 | writeFile: Missing `utf16le`, `latin1` and `ucs2` encoding. 4 | writeFileSync: Missing `utf16le`, `latin1` and `ucs2` encoding. 5 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/http.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | RequestOptions: Option `createConnection` is not supported. 4 | ClientRequestArgs: Option `createConnection` is not supported. 5 | ClientRequest: Constructor option `createConnection` is not supported. 6 | request: Constructor option `createConnection` is not supported. 7 | get: Constructor option `createConnection` is not supported. 8 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/http2.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | Http2Session: | 4 | The following methods are non-functional stubs: 5 | - setLocalWindowSize 6 | - ping 7 | - localSettings 8 | - remoteSettings 9 | - settings 10 | - ref 11 | - unref 12 | ServerHttp2Session: All methods are non-functional stubs. 13 | Http2Stream: | 14 | The following methods are non-functional stubs: 15 | - aborted 16 | - bufferSize 17 | - endAfterHeaders 18 | - id 19 | - pending 20 | - priority 21 | - rstCode 22 | - sentHeaders 23 | - sentInfoHeaders 24 | - sentTrailers 25 | - state 26 | ClientHttp2Stream: All methods are non-functional stubs. 27 | getDefaultSettings: This function is a non-functional stub. 28 | getPackedSettings: This function is a non-functional stub. 29 | getUnpackedSettings: This function is a non-functional stub. 30 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/https.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | Server: The `cert` and `key` options do not support an array input. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/inspector.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | description: "`console` is supported. Other APIs are non-functional stubs." 3 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/module.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | symbols: 3 | Module: The `register` method is a non-functional stub. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/net.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | Socket: The `fd` option is not supported. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/os.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/path.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/perf_hooks.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | performance: | 4 | The `eventLoopUtilization` method is a non-functional stub. 5 | The `timerify` method is not implemented. 6 | monitorEventLoopDelay: This symbol is not implemented. 7 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/process.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | description: The `multipleResolves` and `worker` events are not supported. 3 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/punycode.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/querystring.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/readline.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/repl.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: All symbols are not supported. 3 | 4 | symbols: 5 | "*": This symbol is not supported. 6 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/sea.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: All symbols are not supported. 3 | 4 | symbols: 5 | "*": This symbol is not supported. 6 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/sqlite.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | description: This module has been added in Deno v2.2. 3 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/stream.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/string_decoder.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/test.yaml: -------------------------------------------------------------------------------- 1 | # TODO: we currently don't render the test module 2 | status: partial 3 | description: Currently only `test` API is supported. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/timers.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/tls.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | createSecurePair: This symbol is currently not supported. 4 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/trace_events.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: All exports are non-functional stubs. 3 | symbols: 4 | "*": This symbol is a non-functional stub. 5 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/tty.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/url.yaml: -------------------------------------------------------------------------------- 1 | status: good 2 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/util.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | transferableAbortSignal: This symbol is currently not supported. 4 | transferableAbortController: This symbol is currently not supported. 5 | MIMEParams: This symbol is currently not supported. 6 | MIMEType: This symbol is currently not supported. 7 | getSystemErrorMap: This symbol is currently not supported. 8 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/v8.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | description: | 3 | `cachedDataVersionTag` and `getHeapStatistics`, `serialize` and `deserialize` are supported. 4 | `setFlagsFromStrings` is a noop. 5 | Other APIs are not supported and will throw and error. 6 | 7 | symbols: 8 | setFlagsFromStrings: This function is a noop. 9 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/vm.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | measureMemory: This is a non-functional stub. 4 | compile: The `importModuleDynamically` parameter is not supported. 5 | createContext: The `importModuleDynamically` parameter is not supported. 6 | Script: | 7 | The `importModuleDynamically` parameter is not supported. 8 | The `runInContext` method does not support break on `SIGINT`. 9 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/wasi.yaml: -------------------------------------------------------------------------------- 1 | status: unsupported 2 | description: All exports are non-functional stubs. 3 | symbols: 4 | "*": This symbol is a non-functional stub. 5 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/worker_threads.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | parentPort: | 4 | The `emit` method is not supported. 5 | The `removeAllListeners` method is not supported. 6 | markAsUntransferable: This symbol is not supported. 7 | moveMessagePortToContext: This symbol is not supported. 8 | receiveMessageOnPort: This symbol is not supported. 9 | Worker: The `getHeapSnapshot` method is not supported. 10 | -------------------------------------------------------------------------------- /reference_gen/node_descriptions/zlib.yaml: -------------------------------------------------------------------------------- 1 | status: partial 2 | symbols: 3 | Options: This class is not supported. 4 | BrotliOptions: This class is not supported. 5 | BrotliCompress: This class is not supported. 6 | BrotliDecompress: This class is not supported. 7 | ZlibBase: This class is not supported. 8 | -------------------------------------------------------------------------------- /reference_gen/web-doc.ts: -------------------------------------------------------------------------------- 1 | import { doc, generateHtmlAsJSON } from "@deno/doc"; 2 | import { 3 | hrefResolver, 4 | renderMarkdown, 5 | stripMarkdown, 6 | } from "./common.ts"; 7 | import categoryDocs from "./web-categories.json" with { type: "json" }; 8 | 9 | const url = import.meta.resolve("./types/web.d.ts"); 10 | 11 | console.log("Generating doc nodes..."); 12 | 13 | const nodes = await doc([url], { includeAll: true }); 14 | 15 | console.log("Generating json structure..."); 16 | 17 | const files = await generateHtmlAsJSON(nodes, { 18 | packageName: "Web", 19 | categoryDocs, 20 | disableSearch: true, 21 | hrefResolver, 22 | usageComposer: { 23 | singleMode: true, 24 | compose(_currentResolve, _usageToMd) { 25 | return new Map(); 26 | }, 27 | }, 28 | markdownRenderer: renderMarkdown, 29 | markdownStripper: stripMarkdown, 30 | }); 31 | 32 | await Deno.writeTextFile("./gen/web.json", JSON.stringify(files)); 33 | -------------------------------------------------------------------------------- /replacements.json: -------------------------------------------------------------------------------- 1 | { 2 | "CLI_VERSION": "2.2.3" 3 | } 4 | -------------------------------------------------------------------------------- /runtime/contributing/docs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Deno 文档" 3 | --- 4 | 5 | 我们欢迎并感谢对 Deno 6 | 文档的贡献。如果您发现问题,或想要添加内容,每个页面底部都有一个“编辑此页面”按钮。点击此按钮将带您进入 7 | [Deno 文档仓库](https://github.com/denoland/docs/) 8 | 中该页面的源文件。然后您可以进行更改并提交拉取请求。 9 | 10 | Deno 文档中的某些页面是从 Deno 仓库中的源文件生成的。这些页面无法直接编辑: 11 | 12 | - [API 参考](/api/deno/) 页面是从 Deno 仓库中的类型定义生成的。 13 | - 每个单独命令的 [CLI 参考](/runtime/reference/cli/) 页面是从 Deno 14 | 仓库中的源文件生成的。 15 | 16 | 如果您发现这些页面中的问题,您可以向 Deno 仓库提交拉取请求。或者在 17 | [Deno 文档仓库](https://github.com/denoland/docs/issues) 18 | 中提出问题,我们会尽快修复。 19 | -------------------------------------------------------------------------------- /runtime/contributing/examples.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 贡献一个示例 3 | --- 4 | 5 | [Deno 示例](/examples/) 是一个展示如何使用 Deno 及其 API 6 | 的示例集合。如果您贡献了一个示例,我们将免费赠送您一套贴纸! 7 | 8 | ![Deno 贴纸摆放在桌子上](./images/stickers.jpg) 9 | 10 | ## 贡献一个示例 11 | 12 | 如果您有一个想要与社区分享的 Deno 示例,您可以将其贡献到 13 | [Deno 文档仓库](https://github.com/denoland/docs?tab=readme-ov-file#examples),或者如果您希望看到某个示例,可以提出一个问题。如果您的示例被合并,我们将把您列为作者,并赠送您一些特别版的 14 | Deno 贴纸,作为对您贡献的感谢,您可以展示这些贴纸来彰显您的贡献者身份。 15 | 16 | ## 获取您的贴纸 17 | 18 | 如果您贡献了一个示例,请给我们发送邮件至 19 | [docs@deno.com](mailto:docs@deno.com),告知我们,以便我们为您寄送贴纸! 20 | -------------------------------------------------------------------------------- /runtime/contributing/images/stickers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/contributing/images/stickers.jpg -------------------------------------------------------------------------------- /runtime/contributing/release_schedule.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "发布计划" 3 | oldUrl: /runtime/manual/references/contributing/release_schedule/ 4 | --- 5 | 6 | `deno` CLI 的新次要版本计划每 12 周发布一次。 7 | 8 | 有关即将发布的版本,请参阅 9 | [Deno 的 GitHub 里程碑](https://github.com/denoland/deno/milestones)。 10 | 11 | 通常在次要版本发布后会有几个补丁版本(每周发布);之后,新功能的合并窗口将打开,为即将到来的次要版本做准备。 12 | 13 | 稳定版本可以在 [GitHub 发布页面](https://github.com/denoland/deno/releases) 14 | 找到。 15 | 16 | ## Canary 频道 17 | 18 | 除了上述的稳定频道外,Canary 19 | 版本每天会发布多次(针对主分支的每次提交)。您可以通过运行以下命令升级到最新的 20 | Canary 版本: 21 | 22 | ```console 23 | deno upgrade --canary 24 | ``` 25 | 26 | 要更新到特定的 Canary 版本,请在 `--version` 选项中传递提交哈希: 27 | 28 | ```console 29 | deno upgrade --canary --version=973af61d8bb03c1709f61e456581d58386ed4952 30 | ``` 31 | 32 | 要切换回稳定频道,请运行 `deno upgrade`。 33 | 34 | Canary 版本可以从 https://dl.deno.land 下载。 35 | -------------------------------------------------------------------------------- /runtime/fundamentals/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "基础", 3 | "position": 2, 4 | "link": { 5 | "type": "doc", 6 | "id": "index" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger1.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger2.jpg -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger3.jpg -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger4.jpg -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger5.jpg -------------------------------------------------------------------------------- /runtime/fundamentals/images/debugger7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger7.jpg -------------------------------------------------------------------------------- /runtime/fundamentals/images/deno-lts-support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/deno-lts-support.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/jb-ide-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/jb-ide-debug.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/node_modules_dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/node_modules_dir.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/private-github-new-token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-github-new-token.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/private-github-token-display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-github-token-display.png -------------------------------------------------------------------------------- /runtime/fundamentals/images/private-pat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-pat.png -------------------------------------------------------------------------------- /runtime/getting_started/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "入门指南", 3 | "position": 1, 4 | "link": { 5 | "type": "doc", 6 | "id": "index" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /runtime/getting_started/images/vscode-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/getting_started/images/vscode-setup.png -------------------------------------------------------------------------------- /runtime/getting_started/images/webstorm_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/getting_started/images/webstorm_setup.png -------------------------------------------------------------------------------- /runtime/help.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "在哪里获取帮助" 3 | oldUrl: /runtime/manual/help/ 4 | --- 5 | 6 | 遇到困难?迷失方向?从社区获取帮助。 7 | 8 | ## [社区 Discord](https://discord.gg/deno) 9 | 10 | 实时提问并与社区成员聊天。 11 | 12 | ## [Stack Overflow](https://stackoverflow.com/questions/tagged/deno) 13 | 14 | Stack Overflow 15 | 是一个流行的论坛,可以提出代码级别的问题,或者如果你遇到特定错误时寻求帮助。 16 | [提出你的问题!](https://stackoverflow.com/questions/ask?tags=deno) 17 | 18 | ## [DEV 的 Deno 社区](https://dev.to/t/deno) 19 | 20 | 这是一个寻找关于最佳实践、应用程序架构和新知识的有趣文章的好地方。使用 `deno` 21 | 标签发布你的文章。 22 | -------------------------------------------------------------------------------- /runtime/reference/cli/add.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno add" 3 | command: add 4 | --- 5 | -------------------------------------------------------------------------------- /runtime/reference/cli/check.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno check" 3 | oldUrl: /runtime/manual/tools/check/ 4 | command: check 5 | --- 6 | 7 | ## 示例 8 | 9 | 不执行代码,仅进行类型检查。 10 | 11 | ```ts title="example.ts" 12 | const x: string = 1 + 1n; 13 | ``` 14 | 15 | ```bash 16 | deno check example.ts 17 | ``` 18 | -------------------------------------------------------------------------------- /runtime/reference/cli/clean.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno clean" 3 | command: clean 4 | --- 5 | -------------------------------------------------------------------------------- /runtime/reference/cli/completions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno completions" 3 | oldUrl: /runtime/manual/tools/completions/ 4 | command: completions 5 | --- 6 | 7 | ## 示例 8 | 9 | ### 配置 Bash shell 自动补全 10 | 11 | ```bash 12 | deno completions bash > /usr/local/etc/bash_completion.d/deno.bash 13 | source /usr/local/etc/bash_completion.d/deno.bash 14 | ``` 15 | 16 | ### 配置 PowerShell shell 自动补全 17 | 18 | ```bash 19 | deno completions powershell | Out-String | Invoke-Expression 20 | ``` 21 | 22 | ### 配置 zsh shell 自动补全 23 | 24 | 首先将以下内容添加到你的 `.zshrc` 文件中: 25 | 26 | ```bash 27 | fpath=(~/.zsh/completion $fpath) 28 | autoload -U compinit 29 | compinit 30 | ``` 31 | 32 | 然后运行以下命令: 33 | 34 | ```bash 35 | deno completions zsh > _deno 36 | mv _deno ~/.zsh/completion/_deno 37 | autoload -U compinit && compinit 38 | ``` 39 | 40 | ### 配置 fish shell 自动补全 41 | 42 | ```bash 43 | deno completions fish > completions.fish 44 | chmod +x ./completions.fish 45 | ``` 46 | -------------------------------------------------------------------------------- /runtime/reference/cli/eval.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno eval" 3 | oldUrl: /runtime/manual/tools/eval/ 4 | command: eval 5 | --- 6 | -------------------------------------------------------------------------------- /runtime/reference/cli/lsp.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno lsp" 3 | oldUrl: /runtime/manual/tools/lsp/ 4 | --- 5 | 6 | :::info 7 | 8 | 通常人类不会直接使用这个子命令。'deno lsp' 可以为 IDE 9 | 提供跳转到定义支持和自动代码格式化功能。 10 | 11 | ::: 12 | 13 | 启动 Deno 14 | 语言服务器。语言服务器被编辑器用来提供智能提示、代码格式化等功能。了解更多关于 15 | [与 Deno LSP 集成](/runtime/reference/lsp_integration/) 的信息。 16 | 17 | ## 描述 18 | 19 | 'deno lsp' 子命令为代码编辑器和 IDE 提供了一种通过语言服务器协议与 Deno 20 | 交互的方式。 21 | 22 | 了解更多关于 23 | [如何将编辑器和 IDE 连接到 `deno lsp`](https://deno.land/manual@v1.42.4/getting_started/setup_your_environment#editors-and-ides) 24 | 的信息。 25 | -------------------------------------------------------------------------------- /runtime/reference/cli/remove.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno remove" 3 | command: remove 4 | --- 5 | -------------------------------------------------------------------------------- /runtime/reference/cli/serve.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno serve" 3 | oldUrl: /runtime/manual/tools/serve/ 4 | command: serve 5 | --- 6 | 7 | ## 示例 8 | 9 | 以下是一个示例,展示了如何使用声明式 fetch 创建一个简单的 HTTP 服务器: 10 | 11 | ```typescript title="server.ts" 12 | export default { 13 | async fetch(_req) { 14 | return new Response("Hello world!"); 15 | }, 16 | }; 17 | ``` 18 | 19 | 然后,你可以使用 `deno serve` 命令运行服务器: 20 | 21 | ```bash 22 | deno serve server.ts 23 | ``` 24 | 25 | `fetch` 函数中的逻辑可以自定义,以处理不同类型的请求并相应地提供内容: 26 | 27 | ```typescript title="server.ts" 28 | export default { 29 | async fetch(request) { 30 | if (request.url.startsWith("/json")) { 31 | return Response.json({ hello: "world" }); 32 | } 33 | 34 | return new Response("Hello world!"); 35 | }, 36 | }; 37 | ``` 38 | -------------------------------------------------------------------------------- /runtime/reference/cli/test.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno test" 3 | oldUrl: /runtime/manual/tools/test/ 4 | command: test 5 | --- 6 | 7 | ## 附加信息 8 | 9 | 它可以在监视模式下执行(`--watch`),支持并行执行(`--parallel`),并且可以配置为以随机顺序运行测试(`--shuffle`)。此外,还内置了对代码覆盖率(`--coverage`)和内存泄漏检测(`--trace-leaks`)的支持。 10 | 11 | ## 示例 12 | 13 | 运行测试 14 | 15 | ```bash 16 | deno test 17 | ``` 18 | 19 | 运行特定文件中的测试 20 | 21 | ```bash 22 | deno test src/fetch_test.ts src/signal_test.ts 23 | ``` 24 | 25 | 运行匹配 glob 模式的测试 26 | 27 | ```bash 28 | deno test src/*.test.ts 29 | ``` 30 | 31 | 运行测试并跳过类型检查 32 | 33 | ```bash 34 | deno test --no-check 35 | ``` 36 | 37 | 运行测试,并在文件更改时重新运行 38 | 39 | ```bash 40 | deno test --watch 41 | ``` 42 | -------------------------------------------------------------------------------- /runtime/reference/cli/types.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno types" 3 | oldUrl: /runtime/manual/tools/types/ 4 | command: types 5 | --- 6 | -------------------------------------------------------------------------------- /runtime/reference/cli/upgrade.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "deno upgrade" 3 | oldUrl: /runtime/manual/tools/upgrade/ 4 | command: upgrade 5 | --- 6 | -------------------------------------------------------------------------------- /runtime/reference/images/command_palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/command_palette.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-broadcast.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-broadcast.mp4 -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-cli.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-cli.gif -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-confirm-prompt.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-confirm-prompt.mp4 -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-display.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-html.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-md.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-md.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-plot.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter-svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-svg.png -------------------------------------------------------------------------------- /runtime/reference/images/jupyter_notebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter_notebook.png -------------------------------------------------------------------------------- /runtime/reference/images/vscode_workspace_initialized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/vscode_workspace_initialized.png -------------------------------------------------------------------------------- /runtime/reference/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 参考指南 3 | --- 4 | 5 | 在这里,您将找到详细的技术文档和全面的指南,帮助您掌握 Deno 的高级功能和工具。 6 | 7 | ## 运行时 API 8 | 9 | Deno 拥有广泛的命名空间 10 | API,提供了文件系统操作、网络请求、子进程管理等多种功能。Deno 还旨在通过将现代 11 | Web API 引入服务器端环境,弥合服务器与浏览器之间的差距。最后,Deno 提供了一组 12 | Node.js 兼容 API,帮助您将现有的 Node.js 应用程序迁移到 Deno。 13 | 14 | - [Deno API](/runtime/reference/deno_namespace_apis/) 15 | - [Web API 支持](/runtime/reference/web_platform_apis/) 16 | - [Node API 支持](/api/node/) 17 | 18 | ## 设置您的环境 19 | 20 | 获取有关如何为 Deno 开发设置 Visual Studio Code (VS Code) 21 | 的分步说明。本指南将帮助您配置开发环境,以充分利用 Deno 的功能,包括 TypeScript 22 | 支持、调试等。如果您使用的是其他编辑器,也可以查看 Deno 语言服务器。 23 | 24 | - [为 Deno 设置 VS Code](/runtime/reference/vscode/) 25 | - [Deno 语言服务器](/runtime/reference/cli/lsp_integration/) 26 | - [持续集成](/runtime/reference/continuous_integration/) 27 | 28 | ## Deno CLI 参考指南 29 | 30 | 这份全面的资源涵盖了 Deno 命令行界面中的所有命令和选项,为您提供有效管理和运行 31 | Deno 应用程序所需的知识。 32 | 33 | - [Deno CLI 参考指南](/runtime/reference/cli/) 34 | -------------------------------------------------------------------------------- /server.ts: -------------------------------------------------------------------------------- 1 | import "@std/dotenv/load"; 2 | 3 | import Server from "lume/core/server.ts"; 4 | import NotFoundMiddleware from "lume/middlewares/not_found.ts"; 5 | import apiDocumentContentTypeMiddleware from "./middleware/apiDocContentType.ts"; 6 | import redirectsMiddleware from "./middleware/redirects.ts"; 7 | import createRoutingMiddleware from "./middleware/functionRoutes.ts"; 8 | 9 | export const server = new Server({ root: "." }); 10 | 11 | server.use(redirectsMiddleware); 12 | server.use(NotFoundMiddleware({ root: ".", page404: "./404" })); 13 | server.use(createRoutingMiddleware()); 14 | server.use(apiDocumentContentTypeMiddleware); 15 | 16 | server.start(); 17 | 18 | console.log("Listening on http://localhost:8000"); 19 | -------------------------------------------------------------------------------- /static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/.nojekyll -------------------------------------------------------------------------------- /static/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/android-chrome-192x192.png -------------------------------------------------------------------------------- /static/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/android-chrome-512x512.png -------------------------------------------------------------------------------- /static/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /static/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/apple-touch-icon.png -------------------------------------------------------------------------------- /static/examples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/examples.png -------------------------------------------------------------------------------- /static/examples/local.ts: -------------------------------------------------------------------------------- 1 | const local = "This is a local variable inside of local.ts"; 2 | -------------------------------------------------------------------------------- /static/examples/welcome.ts: -------------------------------------------------------------------------------- 1 | console.log("Welcome to Deno!"); 2 | -------------------------------------------------------------------------------- /static/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon-16x16.png -------------------------------------------------------------------------------- /static/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon-32x32.png -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon.ico -------------------------------------------------------------------------------- /static/fonts/inter/Inter-Italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-Italic.woff2 -------------------------------------------------------------------------------- /static/fonts/inter/Inter-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-Regular.woff2 -------------------------------------------------------------------------------- /static/fonts/inter/Inter-SemiBold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-SemiBold.woff2 -------------------------------------------------------------------------------- /static/fonts/inter/Inter-SemiBoldItalic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-SemiBoldItalic.woff2 -------------------------------------------------------------------------------- /static/github-mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/github-mark.png -------------------------------------------------------------------------------- /static/img/checkmark.svg: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /static/img/chevron.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /static/img/cover@xl.avif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/cover@xl.avif -------------------------------------------------------------------------------- /static/img/dark.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/docusaurus.png -------------------------------------------------------------------------------- /static/img/fresh.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/img/jsr.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /static/img/jsx.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /static/img/light.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /static/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/img/og.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/og.webp -------------------------------------------------------------------------------- /static/img/react.svg: -------------------------------------------------------------------------------- 1 | 2 | React Logo 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /static/img/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /static/img/social.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/social.png -------------------------------------------------------------------------------- /static/js/darkmode.client.js: -------------------------------------------------------------------------------- 1 | const THEME_KEY = "denoDocsTheme"; 2 | const DARK_CLASS = "dark"; 3 | const LIGHT_CLASS = "light"; 4 | 5 | function getPreferredTheme() { 6 | if (THEME_KEY in localStorage) { 7 | return localStorage[THEME_KEY]; 8 | } 9 | return globalThis.matchMedia("(prefers-color-scheme: dark)").matches 10 | ? DARK_CLASS 11 | : LIGHT_CLASS; 12 | } 13 | 14 | function setTheme(theme) { 15 | const root = document.documentElement; 16 | root.classList.add(theme); 17 | root.classList.remove(theme === DARK_CLASS ? LIGHT_CLASS : DARK_CLASS); 18 | } 19 | 20 | setTheme(getPreferredTheme()); 21 | -------------------------------------------------------------------------------- /static/js/nav-toggle.client.js: -------------------------------------------------------------------------------- 1 | const sidebar = document.getElementById("nav"); 2 | 3 | if (sidebar) { 4 | const checkboxes = document.querySelectorAll(".sub-nav-toggle-checkbox"); 5 | checkboxes.forEach((checkbox) => { 6 | // on change of the checkbox, update the checked state in the local storage 7 | checkbox.addEventListener("change", (e) => { 8 | console.log("updated"); 9 | localStorage.setItem(checkbox.id, checkbox.checked); 10 | }); 11 | 12 | // set the checked state of the checkbox based on the value in the local storage 13 | const checked = localStorage.getItem(checkbox.id) === "true"; 14 | checkbox.checked = checked; 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | 4 | Sitemap: https://docs.denohub.com/sitemap.xml 5 | -------------------------------------------------------------------------------- /styleguide/_data.ts: -------------------------------------------------------------------------------- 1 | import { Sidebar } from "../types.ts"; 2 | 3 | export const sidebar = [ 4 | { 5 | title: "Style Guide", 6 | href: "/styleguide/", 7 | items: [ 8 | { 9 | title: "Typography", 10 | href: "/styleguide/typography/", 11 | }, 12 | { 13 | title: "Components", 14 | href: "/styleguide/components/", 15 | }, 16 | ], 17 | }, 18 | ] satisfies Sidebar; 19 | 20 | export const sectionTitle = "Style Guide"; 21 | export const sectionHref = "/styleguide/"; 22 | -------------------------------------------------------------------------------- /styleguide/components.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: "组件" 3 | description: "可在 Deno 文档中使用的组件。" 4 | --- 5 | 6 | ## Logo 组件 7 | 8 | 大小受其包含元素限制 9 | 10 | ```tsx 11 | 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /styleguide/example-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 示例页面 3 | description: 这是一个示例页面 4 | openGraphLayout: /open_graph/examples.jsx 5 | --- 6 | 7 | # 示例页面 8 | -------------------------------------------------------------------------------- /styleguide/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "风格指南" 3 | description: "Deno 文档的风格和设计指南。" 4 | --- 5 | 6 | - [排版](/styleguide/typography) 7 | - [组件](/styleguide/components) 8 | -------------------------------------------------------------------------------- /styleguide/typography.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: "排版" 3 | description: "Deno 文档的排版指南。" 4 | --- 5 | 6 | Deno 文档网站中使用的排版样式示例。 7 | 8 | # 标题 1 9 | 10 | ## 标题 2 11 | 12 | ### 标题 3 13 | 14 | #### 标题 4 15 | 16 | ## 段落 17 | 18 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 19 | 20 | ## 链接语言 21 | 22 | - [标准内容链接](/styleguide) 23 | - [外部链接](https://deno.com) 24 | 25 | ### 上下文中的链接 26 | 27 | Lorem ipsum dolor sit amet, [标准内容链接](/styleguide) consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 28 | 29 | 当内联代码元素包含链接时,[`它们看起来像这样`](/styleguide)。 30 | 31 | ## 预格式化文本 32 | 33 | 我们可以使用 `内联代码元素`,也可以使用如下所示的代码块。 34 | 35 | ```ts 36 | const x = 1; 37 | ``` 38 | 39 | 代码块可用于显示代码示例,并且可以显示标题并使用给定语言的语法高亮。 40 | 41 | ```ts title="title.ts" 42 | const x = 1; 43 | const y = 2; 44 | ``` -------------------------------------------------------------------------------- /subhosting/api/images/org-id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/subhosting/api/images/org-id.png -------------------------------------------------------------------------------- /subhosting/index.md: -------------------------------------------------------------------------------- 1 | 您的输入为空,请提供需要翻译的内容。 2 | -------------------------------------------------------------------------------- /subhosting/manual/acceptable_use_policy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 可接受使用政策 3 | --- 4 | 5 | Deno Subhosting 服务包含的资源(CPU 6 | 时间、请求次数)受此可接受使用政策的约束。本文档可以大致估算我们认为是“可接受使用”的内容,以及我们不认为是可接受使用的内容。 7 | 8 | ### 可接受使用的示例 9 | 10 | - ✅ 服务器端渲染的网站 11 | - ✅ Jamstack 站点和应用程序 12 | - ✅ 单页应用程序 13 | - ✅ 查询数据库或外部 API 的 API 14 | - ✅ 个人博客 15 | - ✅ 公司网站 16 | - ✅ 电子商务网站 17 | 18 | ### 不可接受的使用 19 | 20 | - ❌ 加密货币挖矿 21 | - ❌ 高度 CPU 密集型负载(例如机器学习) 22 | - ❌ 为外部站点托管媒体 23 | - ❌ 爬虫 24 | - ❌ 代理或 VPN 25 | 26 | ## 指南 27 | 28 | 我们预计大多数项目都会在合理的使用限制范围内。如果您的项目使用情况显著偏离常态,我们将通知您。在采取任何行动以解决对我们基础设施的不合理负担之前,我们会在可能的情况下与您联系。 29 | -------------------------------------------------------------------------------- /subhosting/manual/pricing_and_limits.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 定价与限制 3 | --- 4 | 5 | ## 部署大小 6 | 7 | 每次部署中,所有源代码和资源的总和应小于 1GB。 8 | 9 | ## 部署频率 10 | 11 | 子托管用户每小时的最大部署次数为 60 次(免费层级)或 300 12 | 次(构建者层级)。企业计划中的组织可获得更高的限制。 13 | 14 | ## 每次请求的 CPU 时间 15 | 16 | - 50ms 或 200ms,取决于层级。 17 | - 每次请求的 CPU 时间限制是基于多次请求的平均值,并非严格按每次请求执行。 18 | - 不包括部署等待 I/O 的时间(例如,在发出 fetch() 请求时等待远程服务器的时间)。 19 | 20 | ## 阻塞事件循环 21 | 22 | 程序不应阻塞事件循环超过 1 秒。 23 | 24 | ## 可用内存 25 | 26 | 最大可用内存为 512MB。 27 | -------------------------------------------------------------------------------- /timeUtils.ts: -------------------------------------------------------------------------------- 1 | export function cliNow() { 2 | const timeOnly = new Date().toLocaleTimeString(); 3 | return `[${timeOnly}]`; 4 | } 5 | --------------------------------------------------------------------------------