mirror of
https://github.com/denoland/std.git
synced 2024-11-21 12:40:03 +00:00
chore: enable no-console
lint rule (#5975)
This commit is contained in:
parent
75a50aecf7
commit
58dbbd6bd2
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
// deno-lint-ignore-file camelcase
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import {
|
||||
createGraph,
|
||||
@ -87,13 +87,13 @@ const ENTRYPOINTS: Record<Mod, string[]> = {
|
||||
collections: ["mod.ts"],
|
||||
crypto: ["mod.ts"],
|
||||
csv: ["mod.ts"],
|
||||
data_structures: ["mod.ts"],
|
||||
"data_structures": ["mod.ts"],
|
||||
datetime: ["mod.ts"],
|
||||
dotenv: ["mod.ts"],
|
||||
encoding: ["mod.ts"],
|
||||
expect: ["mod.ts"],
|
||||
fmt: ["bytes.ts", "colors.ts", "duration.ts", "printf.ts"],
|
||||
front_matter: ["mod.ts"],
|
||||
"front_matter": ["mod.ts"],
|
||||
fs: ["mod.ts"],
|
||||
html: ["mod.ts"],
|
||||
http: ["mod.ts"],
|
||||
@ -103,7 +103,7 @@ const ENTRYPOINTS: Record<Mod, string[]> = {
|
||||
json: ["mod.ts"],
|
||||
jsonc: ["mod.ts"],
|
||||
log: ["mod.ts"],
|
||||
media_types: ["mod.ts"],
|
||||
"media_types": ["mod.ts"],
|
||||
msgpack: ["mod.ts"],
|
||||
net: ["mod.ts"],
|
||||
path: ["mod.ts"],
|
||||
|
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
/**
|
||||
* Checks whether all deprecated tags have a message.
|
||||
|
@ -215,10 +215,10 @@ async function assertSnippetEvals(
|
||||
stderr: "piped",
|
||||
});
|
||||
const timeoutId = setTimeout(() => {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
`Snippet at ${document.location.filename}:${document.location.line} has been running for more than 10 seconds...`,
|
||||
`Snippet at ${document.location.filename}:${document.location.line} has been running for more than 10 seconds...\n${snippet}`,
|
||||
);
|
||||
console.warn(snippet);
|
||||
}, 10_000);
|
||||
try {
|
||||
const { success, stderr } = await command.output();
|
||||
@ -548,6 +548,7 @@ const lintStatus = await new Deno.Command(Deno.execPath(), {
|
||||
stderr: "inherit",
|
||||
}).output();
|
||||
if (!lintStatus.success) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
`%c[error] %c'deno doc --lint' failed`,
|
||||
"color: red",
|
||||
@ -568,6 +569,7 @@ for await (const _ of iter) {
|
||||
}
|
||||
if (diagnostics.length > 0) {
|
||||
for (const error of diagnostics) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
`%c[error] %c${error.message} %cat ${error.cause}`,
|
||||
"color: red",
|
||||
@ -576,6 +578,7 @@ if (diagnostics.length > 0) {
|
||||
);
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(`%c${diagnostics.length} errors found`, "color: red");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import denoJson from "../deno.json" with { type: "json" };
|
||||
|
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { walk } from "../fs/walk.ts";
|
||||
import { globToRegExp } from "../path/glob_to_regexp.ts";
|
||||
|
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { walk } from "../fs/walk.ts";
|
||||
|
@ -15,6 +15,7 @@ export async function discoverPackages() {
|
||||
}
|
||||
packages.sort();
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log("Discovered", packages.length, "packages.");
|
||||
return packages;
|
||||
}
|
||||
@ -59,5 +60,6 @@ async function discoverExports(pkg: string) {
|
||||
|
||||
if (import.meta.main) {
|
||||
const packages = await discoverPackages();
|
||||
// deno-lint-ignore no-console
|
||||
console.log(packages);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=git,deno --no-check
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { getReleasesMdFile, loadRepo, VersionFile } from "./repo.ts";
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run=git --no-check
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { createOctoKit, getGitHubRepository } from "./deps.ts";
|
||||
import { loadRepo, VersionFile } from "./repo.ts";
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run=git --no-check
|
||||
// deno-lint-ignore-file no-console
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { containsVersion, createOctoKit, getGitHubRepository } from "./deps.ts";
|
||||
import { getReleasesMdFile, loadRepo, VersionFile } from "./repo.ts";
|
||||
|
@ -65,6 +65,7 @@ export function delay(ms: number, options: DelayOptions = {}): Promise<void> {
|
||||
if (!(error instanceof ReferenceError)) {
|
||||
throw error;
|
||||
}
|
||||
// deno-lint-ignore no-console
|
||||
console.error("`persistent` option is only available in Deno");
|
||||
}
|
||||
}
|
||||
|
@ -298,6 +298,7 @@ function makeTables(
|
||||
}
|
||||
|
||||
export async function tables(version: string) {
|
||||
// deno-lint-ignore no-console
|
||||
console.info(`Generating tables for Unicode ${version}`);
|
||||
|
||||
const eawMap = await loadEastAsianWidths(version);
|
||||
|
1
crypto/testdata/digest_large_inputs.ts
vendored
1
crypto/testdata/digest_large_inputs.ts
vendored
@ -20,6 +20,7 @@ const largeDigest = encodeHex(
|
||||
);
|
||||
const heapBytesAfterLarge = memory.buffer.byteLength;
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(JSON.stringify({
|
||||
heapBytesInitial,
|
||||
smallDigest,
|
||||
|
1
crypto/testdata/digest_many_calls.ts
vendored
1
crypto/testdata/digest_many_calls.ts
vendored
@ -20,6 +20,7 @@ const heapBytesFinal = memory.buffer.byteLength;
|
||||
|
||||
const stateFinal = encodeHex(state);
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(JSON.stringify({
|
||||
heapBytesInitial,
|
||||
heapBytesFinal,
|
||||
|
@ -396,6 +396,8 @@ export class DateTimeFormatter {
|
||||
case "numeric": {
|
||||
value = /^\d{1,2}/.exec(string)?.[0] as string;
|
||||
if (part.hour12 && parseInt(value) > 12) {
|
||||
// TODO(iuioiua): Replace with throwing an error
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
`Trying to parse hour greater than 12, use 'H' instead of 'h'.`,
|
||||
);
|
||||
@ -405,6 +407,8 @@ export class DateTimeFormatter {
|
||||
case "2-digit": {
|
||||
value = /^\d{2}/.exec(string)?.[0] as string;
|
||||
if (part.hour12 && parseInt(value) > 12) {
|
||||
// TODO(iuioiua): Replace with throwing an error
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
`Trying to parse hour greater than 12, use 'HH' instead of 'hh'.`,
|
||||
);
|
||||
@ -412,6 +416,7 @@ export class DateTimeFormatter {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// TODO(iuioiua): Correct error type and message
|
||||
throw new Error(
|
||||
`ParserError: value "${part.value}" is not supported`,
|
||||
);
|
||||
|
@ -43,7 +43,8 @@
|
||||
"camelcase",
|
||||
"no-sync-fn-in-async-fn",
|
||||
"single-var-declarator",
|
||||
"verbatim-module-syntax"
|
||||
"verbatim-module-syntax",
|
||||
"no-console"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ import { loadSync } from "./mod.ts";
|
||||
|
||||
if (!(Deno.readTextFileSync instanceof Function)) {
|
||||
// Avoid errors that occur in deno deploy: https://github.com/denoland/deno_std/issues/1957
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
`Deno.readTextFileSync is not a function: No .env data was read.`,
|
||||
);
|
||||
|
@ -84,6 +84,7 @@ export function parse(text: string): Record<string, string> {
|
||||
?.groups as LineParseResult;
|
||||
|
||||
if (!RE_VALID_KEY.test(key)) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
`Ignored the key "${key}" as it is not a valid identifier: The key need to match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/.`,
|
||||
);
|
||||
|
@ -23,6 +23,7 @@ export function stringify(object: Record<string, string>): string {
|
||||
|
||||
let escapedValue = value ?? "";
|
||||
if (key.startsWith("#")) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
`key starts with a '#' indicates a comment and is ignored: '${key}'`,
|
||||
);
|
||||
|
1
dotenv/testdata/app_defaults.ts
vendored
1
dotenv/testdata/app_defaults.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { load } from "../mod.ts";
|
||||
const conf = await load();
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(JSON.stringify(conf, null, 2));
|
||||
|
1
dotenv/testdata/app_load.ts
vendored
1
dotenv/testdata/app_load.ts
vendored
@ -1,3 +1,4 @@
|
||||
import "../load.ts";
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(Deno.env.get("GREETING"));
|
||||
|
1
dotenv/testdata/app_load_child.ts
vendored
1
dotenv/testdata/app_load_child.ts
vendored
@ -1,4 +1,5 @@
|
||||
// test file for https://github.com/denoland/deno_std/issues/1957
|
||||
// This file is imported from ./app_load_parent.ts
|
||||
|
||||
// deno-lint-ignore no-console
|
||||
console.log(Deno.env.get("GREETING"));
|
||||
|
@ -226,13 +226,12 @@ for (const s of scenes) {
|
||||
|
||||
const command = new Deno.Command(Deno.execPath(), {
|
||||
args,
|
||||
stderr: "inherit",
|
||||
});
|
||||
const { stdout, stderr } = await command.output();
|
||||
const { stdout } = await command.output();
|
||||
assertStringIncludes(new TextDecoder().decode(stdout), s.output);
|
||||
if (stderr.length > 0) {
|
||||
console.log(new TextDecoder().decode(stderr));
|
||||
}
|
||||
} catch (err) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(err);
|
||||
await Deno.remove(testfolder, { recursive: true });
|
||||
throw err;
|
||||
|
1
fs/testdata/empty_dir.ts
vendored
1
fs/testdata/empty_dir.ts
vendored
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
import { emptyDir } from "../empty_dir.ts";
|
||||
|
||||
try {
|
||||
|
1
fs/testdata/empty_dir_sync.ts
vendored
1
fs/testdata/empty_dir_sync.ts
vendored
@ -1,3 +1,4 @@
|
||||
// deno-lint-ignore-file no-console
|
||||
import { emptyDirSync } from "../empty_dir.ts";
|
||||
|
||||
try {
|
||||
|
1
fs/testdata/expand_wildcard.js
vendored
1
fs/testdata/expand_wildcard.js
vendored
@ -2,5 +2,6 @@ import { expandGlob } from "../expand_glob.ts";
|
||||
|
||||
const glob = new URL("*", import.meta.url).pathname;
|
||||
for await (const { filename } of expandGlob(glob)) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(filename);
|
||||
}
|
||||
|
@ -365,6 +365,7 @@ function parseSetCookie(value: string): Cookie | null {
|
||||
case "max-age":
|
||||
cookie.maxAge = Number(value);
|
||||
if (cookie.maxAge < 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"Max-Age must be an integer superior or equal to 0. Cookie ignored.",
|
||||
);
|
||||
@ -396,6 +397,7 @@ function parseSetCookie(value: string): Cookie | null {
|
||||
if (cookie.name.startsWith("__Secure-")) {
|
||||
/** This requirement is mentioned in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie but not the RFC. */
|
||||
if (!cookie.secure) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"Cookies with names starting with `__Secure-` must be set with the secure flag. Cookie ignored.",
|
||||
);
|
||||
@ -404,18 +406,21 @@ function parseSetCookie(value: string): Cookie | null {
|
||||
}
|
||||
if (cookie.name.startsWith("__Host-")) {
|
||||
if (!cookie.secure) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"Cookies with names starting with `__Host-` must be set with the secure flag. Cookie ignored.",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
if (cookie.domain !== undefined) {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"Cookies with names starting with `__Host-` must not have a domain specified. Cookie ignored.",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
if (cookie.path !== "/") {
|
||||
// deno-lint-ignore no-console
|
||||
console.warn(
|
||||
"Cookies with names starting with `__Host-` must have path be `/`. Cookie has been ignored.",
|
||||
);
|
||||
|
@ -408,6 +408,7 @@ function serverLog(req: Request, status: number) {
|
||||
const url = new URL(req.url);
|
||||
const s = `${dateFmt} [${req.method}] ${url.pathname}${url.search} ${status}`;
|
||||
// using console.debug instead of console.log so chrome inspect users can hide request logs
|
||||
// deno-lint-ignore no-console
|
||||
console.debug(s);
|
||||
}
|
||||
|
||||
@ -760,6 +761,7 @@ async function createServeDirResponse(
|
||||
}
|
||||
|
||||
function logError(error: Error) {
|
||||
// deno-lint-ignore no-console
|
||||
console.error(`%c${error.message}`, "color: red");
|
||||
}
|
||||
|
||||
@ -802,12 +804,14 @@ function main() {
|
||||
}
|
||||
|
||||
if (serverArgs.version) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(`Deno File Server ${denoConfig.version}`);
|
||||
Deno.exit();
|
||||
}
|
||||
|
||||
if (keyFile || certFile) {
|
||||
if (keyFile === "" || certFile === "") {
|
||||
// deno-lint-ignore no-console
|
||||
console.log("--key and --cert are required for TLS");
|
||||
printUsage();
|
||||
Deno.exit(1);
|
||||
@ -849,6 +853,7 @@ function main() {
|
||||
if (networkAddress && !DENO_DEPLOYMENT_ID) {
|
||||
message += `\n- Network: ${protocol}://${networkAddress}:${port}`;
|
||||
}
|
||||
// deno-lint-ignore no-console
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
@ -874,6 +879,7 @@ function main() {
|
||||
}
|
||||
|
||||
function printUsage() {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(`Deno File Server ${denoConfig.version}
|
||||
Serves a local directory in HTTP.
|
||||
|
||||
|
1
http/testdata/file_server_as_library.ts
vendored
1
http/testdata/file_server_as_library.ts
vendored
@ -1,6 +1,7 @@
|
||||
import { serveFile } from "../file_server.ts";
|
||||
|
||||
Deno.serve(
|
||||
// deno-lint-ignore no-console
|
||||
{ port: 8000, onListen: () => console.log("Server running...") },
|
||||
(req) => {
|
||||
return serveFile(req, "./testdata/hello.html");
|
||||
|
@ -53,6 +53,7 @@ export class ConsoleHandler extends BaseHandler {
|
||||
}
|
||||
|
||||
log(msg: string) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(msg);
|
||||
}
|
||||
}
|
||||
|
@ -358,6 +358,7 @@ class AssertSnapshotContext {
|
||||
|
||||
const updated = this.getUpdatedCount();
|
||||
if (updated > 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c\n > ${updated} ${
|
||||
updated === 1 ? "snapshot" : "snapshots"
|
||||
@ -367,6 +368,7 @@ class AssertSnapshotContext {
|
||||
}
|
||||
const removed = removedSnapshotNames.length;
|
||||
if (removed > 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c\n > ${removed} ${
|
||||
removed === 1 ? "snapshot" : "snapshots"
|
||||
@ -374,6 +376,7 @@ class AssertSnapshotContext {
|
||||
"color: red; font-weight: bold;",
|
||||
);
|
||||
for (const snapshotName of removedSnapshotNames) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(`%c • ${snapshotName}`, "color: red;");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user