1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00

wip after merge

This commit is contained in:
Bartek Iwańczuk 2024-12-21 02:38:23 +01:00
parent d3e41a770a
commit fcfd4c09b5
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
3 changed files with 4 additions and 67 deletions

8
Cargo.lock generated
View file

@ -1491,14 +1491,8 @@ dependencies = [
[[package]]
name = "deno_config"
<<<<<<< HEAD
version = "0.39.3"
source = "git+https://github.com/denoland/deno_config.git?branch=deno_lint_rules#13f6ff94ce36896b29c2a84386e2173bb18a036d"
=======
version = "0.41.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afa3beb6b9e0604cfe0380d30f88c5b758d44e228d5a5fc42ae637ccfb7d089"
>>>>>>> main
source = "git+https://github.com/denoland/deno_config.git?branch=deno_lint_rules#10812e7b44ba3721b73048ea7117db541e3aa256"
dependencies = [
"anyhow",
"deno_package_json",

View file

@ -7,7 +7,7 @@ import {
compileSelector,
parseSelector,
splitSelectors,
} from "ext:cli/lint/selector.js";
} from "ext:cli/lint/40_lint_selector.js";
const {
op_lint_get_rule,
@ -16,7 +16,6 @@ const {
op_lint_create_serialized_ast,
} = core.ops;
// Keep in sync with Rust
// These types are expected to be present on every node. Note that this
// isn't set in stone. We could revise this at a future point.
@ -187,7 +186,6 @@ function findPropOffset(buf, offset, search) {
return -1;
}
const INTERNAL_CTX = Symbol("ctx");
const INTERNAL_OFFSET = Symbol("offset");
@ -311,60 +309,6 @@ function toJsValue(ctx, offset) {
return node;
}
<<<<<<< HEAD
const INTERNAL_CTX = Symbol("ctx");
const INTERNAL_OFFSET = Symbol("offset");
class Node {
[INTERNAL_CTX];
[INTERNAL_OFFSET];
/**
* @param {AstContext} ctx
* @param {number} offset
*/
constructor(ctx, offset) {
this[INTERNAL_CTX] = ctx;
this[INTERNAL_OFFSET] = offset;
}
/**
* @param {*} _
* @param {*} options
* @returns {string}
*/
[Symbol.for("Deno.customInspect")](_, options) {
const json = toJsValue(this[INTERNAL_CTX], this[INTERNAL_OFFSET]);
return Deno.inspect(json, options);
}
}
/** @type {Set<number>} */
const appliedGetters = new Set();
/**
* @param {AstContext} ctx
*/
function setNodeGetters(ctx) {
if (appliedGetters.size === ctx.strByProp.length) return;
for (let i = 0; i < ctx.strByProp.length; i++) {
const id = ctx.strByProp[i];
if (id === 0 || appliedGetters.has(i)) continue;
appliedGetters.add(i);
const name = getString(ctx.strTable, id);
Object.defineProperty(Node.prototype, name, {
get() {
return readValue(this[INTERNAL_CTX], this[INTERNAL_OFFSET], i);
},
});
}
}
/**
* Read a specific property from a node
* @param {AstContext} ctx
@ -417,7 +361,6 @@ function readValue(ctx, offset, search) {
}
throw new Error(`Unknown prop kind: ${kind}`);
>>>>>>> main
}
const DECODER = new TextDecoder();

View file

@ -32,7 +32,7 @@ use crate::args::DenoSubcommand;
use crate::args::Flags;
use crate::args::LintFlags;
use crate::factory::CliFactory;
use crate::tools::lint::swc::serialize_ast_bin;
use crate::tools::lint::serialize_ast_to_buffer;
#[derive(Debug)]
pub enum PluginRunnerRequest {
@ -407,7 +407,7 @@ pub async fn run_rules_for_ast(
pub fn serialize_ast(parsed_source: ParsedSource) -> Result<Vec<u8>, AnyError> {
let start = std::time::Instant::now();
let r = serialize_ast_bin(&parsed_source);
let r = serialize_ast_to_buffer(&parsed_source);
log::info!(
"serialize custom ast took {:?}",
std::time::Instant::now() - start