profile
viewpoint
Akshat Agarwal humancalico Delhi, India Rust, JS/TS Developer

akshgpt7/youtube-deno 11

A Deno client library of the YouTube Data API.

daemon1024/DenoIndiaBot 2

Official Bot for Deno India Community on Telegram

humancalico/cargo 1

The Rust package manager

humancalico/clap 1

A full featured, fast Command Line Argument Parser for Rust

humancalico/deno 1

Personal fork to work on the Deno runtime

humancalico/deno-ftp 1

An FTP Client for Deno

humancalico/nushell 1

A modern shell written in Rust

humancalico/rigit 1

A [WIP] toy VCS in Rust

issue commentdenoland/deno_lint

ESLint recommended rules

working on no-misleading-character-class

bartlomieju

comment created time in 2 days

Pull request review commenttokio-rs/tracing

`Value` implementation for `Option<T> where T: Value

 pub trait Visit {      /// Visit a value implementing `fmt::Debug`.     fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug);++    /// Visit an Option+    fn record_option(&mut self, field: &Field, value: Option<&(dyn Value + 'static)>) {+        if let Some(inner_value) = value {+            self.record_debug(field, &inner_value)

Is this right inner_value.record(field, self)?

humancalico

comment created time in 2 days

startedtherealansh/dotfiles

started time in 4 days

push eventhumancalico/fcc-node

Akshat Agarwal

commit sha 046ee30fb6f574afed5856b374c668159db144cd

add author

view details

push time in 4 days

create barnchhumancalico/fcc-node

branch : gomix

created branch time in 4 days

created repositoryhumancalico/fcc-node

created time in 4 days

issue commentdenoland/deno_lint

LintDiagnostic should implement "Serialize" trait

@souldzin Are you still working on it? Can I pick it up?

bartlomieju

comment created time in 5 days

push eventhumancalico/tracing

Eliza Weisman

commit sha afe04fd402d868f54cb2343a85586f8dfe3a1cd1

fix lifetime mismatch Signed-off-by: Eliza Weisman <eliza@buoyant.io>

view details

Akshat Agarwal

commit sha eefcfc028cb54ccc8bb7cc7c58f87a68459d6cd8

Merge pull request #1 from tokio-rs/eliza/humancalico/option fix lifetime mismatch

view details

push time in 5 days

PR merged humancalico/tracing

fix lifetime mismatch

This should fix the lifetime error. The problem is that the current implementation of record_option requires the value inside the option to be valid for the 'static lifetime, but when borrowed from a self reference with an arbitrary lifetime, this is not the case.

+3 -3

0 comment

1 changed file

hawkw

pr closed time in 5 days

push eventhumancalico/humancalico.github.io

Akshat Agarwal

commit sha e59bda9e535833840146af29935d7f1e15c5b67f

new message

view details

push time in 7 days

created tagakshgpt7/youtube-deno

tagv0.1.2

A Deno client library of the YouTube Data API.

created time in 7 days

release akshgpt7/youtube-deno

v0.1.2

released time in 7 days

starteddenoland/deno_registry2

started time in 7 days

PR opened tokio-rs/tracing

[WIP] Value` implementation for `Option<T> where T: Value

Closes #824 Current roadblock: Lifetime error

error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
   --> tracing-core/src/field.rs:457:41
    |
457 |         visitor.record_option(key, self.as_ref().map(|v| v as &dyn Value))
    |                                         ^^^^^^
    |
+19 -0

0 comment

1 changed file

pr created time in 8 days

create barnchhumancalico/tracing

branch : option

created branch time in 8 days

fork humancalico/tracing

Application level tracing for Rust.

https://tracing.rs

fork in 8 days

startedfish-shell/fish-shell

started time in 8 days

startedvividvilla/ezhil

started time in 9 days

startedathul/archie

started time in 9 days

push eventhumancalico/humancalico.github.io

Akshat Agarwal

commit sha 5e52e840bd993ce163bc0ea3a842b5825972d5c3

remove README.md

view details

push time in 10 days

push eventhumancalico/humancalico.github.io

Akshat Agarwal

commit sha de393c69034d6c13b0c49ec36c8df52808b62e5b

add index.html

view details

push time in 10 days

create barnchhumancalico/humancalico.github.io

branch : master

created branch time in 10 days

created repositoryhumancalico/humancalico.github.io

created time in 10 days

push eventhumancalico/humancalico

Akshat Agarwal

commit sha 079cda18e54d55a14eed7086585647d925d90023

Update README.md

view details

push time in 10 days

push eventhumancalico/youtube-deno

Akshat Agarwal

commit sha c2d8737c3e5b2a1009d8e4a95472ec158083ac81

add ignore directive for no-explicit-any in schema.ts

view details

push time in 12 days

push eventhumancalico/youtube-deno

Akshat Agarwal

commit sha 3d2c3b7ea11b2a1a705ba19af5f20c88c790cded

add ignore directive for no-explicit-any in schema.ts

view details

push time in 12 days

push eventhumancalico/easy_rust

Akshat Agarwal

commit sha 4f438f8d7cd24e02ebf04f82b6b115c80359123f

fix small typo

view details

Dhghomon

commit sha b86d019b42e5dc30d3bb011e6da8a84b8e57682c

Merge pull request #46 from humancalico/patch-1 fix small typo

view details

push time in 12 days

create barnchhumancalico/youtube-deno

branch : patch

created branch time in 12 days

fork humancalico/youtube-deno

A Deno client library of the YouTube Data API.

fork in 12 days

PR opened Dhghomon/easy_rust

fix small typo
+1 -1

0 comment

1 changed file

pr created time in 12 days

push eventhumancalico/easy_rust

Akshat Agarwal

commit sha 4f438f8d7cd24e02ebf04f82b6b115c80359123f

fix small typo

view details

push time in 12 days

issue commenttokio-rs/tracing

core: consider `Value` implementation for `Option<T> where T: Value`

@Pothulapati I am

hawkw

comment created time in 12 days

startedqkniep/regexpp-rs

started time in 16 days

issue openedakshgpt7/youtube-deno

setup GitHub Actions

created time in 16 days

PR opened daemon1024/DenoIndiaBot

setup github workflow
+23 -0

0 comment

1 changed file

pr created time in 18 days

push eventhumancalico/DenoIndiaBot

Akshat Agarwal

commit sha 3abdb03f455ad204fe34f3f5ec8c3e2f554b1cc6

add lint for ci

view details

push time in 18 days

push eventhumancalico/DenoIndiaBot

daemon1024

commit sha 64255ffdc89af9be1bda738adb5930fafc63da98

use best-practices

view details

Akshat Agarwal

commit sha de401a044f7e453a723ac0ae40ea5d8d0024336d

setup github workflow

view details

Akshat Agarwal

commit sha a4ff896e7ea8f54bf8d2b12bf1228bc5aea18068

remove tests from ci

view details

push time in 18 days

create barnchhumancalico/DenoIndiaBot

branch : ci

created branch time in 18 days

starteddaemon1024/DenoIndiaBot

started time in 18 days

fork humancalico/DenoIndiaBot

Official Bot for Deno India Community on Telegram

fork in 18 days

startedregexident/cargo-modules

started time in 19 days

issue commenttokio-rs/tracing

core: consider `Value` implementation for `Option<T> where T: Value`

I'll try to work on this

hawkw

comment created time in 20 days

issue commentdenoland/deno_lint

typescript-eslint recommended rules

@bartlomieju It seems no-inferrable-types is done. It's not updated in your comment

bartlomieju

comment created time in 20 days

startedbrotzeit/rustic

started time in 20 days

create barnchhumancalico/deno_lint

branch : upgrade

created branch time in 20 days

issue commentdenoland/deno

fmt: add config flag

bartlomieju

comment created time in 22 days

issue commentdenoland/deno

Deno doc output missing

@SyrupThinker Can you also add 'Closes #4755' in your PR?

davidcallanan

comment created time in 22 days

startedjozefg/learn-tt

started time in 22 days

startedWICG/import-maps

started time in 23 days

pull request commentdenoland/deno_lint

add no-constant-condition rule

Done @bartlomieju

humancalico

comment created time in 24 days

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 17c0398dc36fd6d8217c2f486205658cf465070f

remove dbg!()

view details

push time in 24 days

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 7d399b01969839a3ec2c95f3c0f4fbb1bd459718

address some issues

view details

push time in 24 days

Pull request review commentdenoland/deno_lint

add no-constant-condition rule

+// Copyright 2020 the Deno authors. All rights reserved. MIT license.+use super::Context;+use super::LintRule;+use crate::swc_common::Span;+use crate::swc_common::Spanned;+use crate::swc_ecma_ast;+use crate::swc_ecma_ast::Expr;+use crate::swc_ecma_ast::Lit;+use crate::swc_ecma_ast::Module;+use std::sync::Arc;+use swc_ecma_visit::{Node, Visit};++pub struct NoConstantCondition;++impl LintRule for NoConstantCondition {+  fn new() -> Box<Self> {+    Box::new(NoConstantCondition)+  }++  fn code(&self) -> &'static str {+    "no-constant-condition"+  }++  fn lint_module(&self, context: Arc<Context>, module: &Module) {+    let mut visitor = NoConstantConditionVisitor::new(context);+    visitor.visit_module(module, module);+  }+}++struct NoConstantConditionVisitor {+  context: Arc<Context>,+}++impl NoConstantConditionVisitor {+  pub fn new(context: Arc<Context>) -> Self {+    Self { context }+  }++  fn add_diagnostic(&self, span: Span) {+    self.context.add_diagnostic(+      span,+      "no-constant-condition",+      "Use of a constant expressions as conditions is not allowed.",+    );+  }++  fn check_short_circuit(+    &self,+    expr: &Expr,+    operator: swc_ecma_ast::BinaryOp,+  ) -> bool {+    match expr {+      Expr::Lit(lit) => match lit {+        Lit::Bool(boolean) => {+          (operator == swc_ecma_ast::BinaryOp::LogicalOr && boolean.value)+            || (operator == swc_ecma_ast::BinaryOp::LogicalAnd+              && !boolean.value)+        }+        _ => false,+      },+      Expr::Unary(unary) => {+        operator == swc_ecma_ast::BinaryOp::LogicalAnd+          && unary.op == swc_ecma_ast::UnaryOp::Void+      }+      Expr::Bin(bin)+        if bin.op == swc_ecma_ast::BinaryOp::LogicalAnd+          || bin.op == swc_ecma_ast::BinaryOp::LogicalOr =>+      {+        self.check_short_circuit(&bin.left, bin.op)+          || self.check_short_circuit(&bin.right, bin.op)+      }+      _ => false,+    }+  }++  fn is_constant(+    &self,+    node: &Expr,+    parent_node: Option<&Expr>,+    in_boolean_position: bool,+  ) -> bool {+    match node {+      Expr::Lit(_) | Expr::Arrow(_) | Expr::Fn(_) | Expr::Object(_) => true,+      Expr::Tpl(tpl) => {+        (in_boolean_position+          && tpl.quasis.iter().any(|quasi| match &quasi.cooked {+            Some(str) => !str.is_empty(),+            None => false,+          }))+          || tpl.exprs.iter().all(|expr| {+            self.is_constant(expr, parent_node, in_boolean_position)+          })+      }+      // TODO(humancalico) confirm in_boolean_position here+      Expr::Paren(paren) => self.is_constant(&paren.expr, Some(node), false),+      Expr::Array(arr) => match parent_node {+        Some(Expr::Bin(bin)) => {+          if bin.op == swc_ecma_ast::BinaryOp::Add {+            arr.elems.iter().all(|element| {+              self.is_constant(+                &element.as_ref().unwrap().expr,+                parent_node,+                false,+              )+            })+          } else {+            true+          }+        }+        _ => true,+      },+      Expr::Unary(unary) => {+        if unary.op == swc_ecma_ast::UnaryOp::Void {+          true+        } else {+          (unary.op == swc_ecma_ast::UnaryOp::TypeOf && in_boolean_position)+            || self.is_constant(&unary.arg, Some(node), true)+        }+      }+      Expr::Bin(bin) => {+        // This is for LogicalExpression+        if bin.op == swc_ecma_ast::BinaryOp::LogicalOr+          || bin.op == swc_ecma_ast::BinaryOp::LogicalAnd+        {+          let is_left_constant =+            self.is_constant(&bin.left, Some(node), in_boolean_position);+          let is_right_constant =+            self.is_constant(&bin.right, Some(node), in_boolean_position);+          let is_left_short_circuit =+            is_left_constant && self.check_short_circuit(&bin.left, bin.op);+          let is_right_short_circuit =+            is_right_constant && self.check_short_circuit(&bin.right, bin.op);+          (is_left_constant && is_right_constant)+          // TODO(humancalico) add more condiitons here from https://github.com/eslint/eslint/blob/f4d7b9e1a599346b2f21ff9de003b311b51411e6/lib/rules/no-constant-condition.js#L135-L146+            || is_left_short_circuit+            || is_right_short_circuit+        }+        // These are fo regular BinaryExpression+        else if bin.op != swc_ecma_ast::BinaryOp::In {+          self.is_constant(&bin.left, Some(node), false)+            && self.is_constant(&bin.right, Some(node), false)+        } else {+          false+        }+      }+      Expr::Assign(assign) => {+        assign.op == swc_ecma_ast::AssignOp::Assign+          && self.is_constant(&assign.right, Some(node), in_boolean_position)+      }+      Expr::Seq(seq) => self.is_constant(+        &seq.exprs[seq.exprs.len() - 1],+        Some(node),+        in_boolean_position,+      ),+      _ => false,+    }+  }++  fn report(&self, condition: &Expr) {+    if self.is_constant(condition, None, true) {+      let span = condition.span();+      self.add_diagnostic(span);+    } else {+    }+  }+}++impl Visit for NoConstantConditionVisitor {+  fn visit_cond_expr(+    &mut self,+    cond_expr: &swc_ecma_ast::CondExpr,+    _parent: &dyn Node,+  ) {+    self.report(&cond_expr.test)+  }+  fn visit_if_stmt(+    &mut self,+    if_stmt: &swc_ecma_ast::IfStmt,+    _parent: &dyn Node,+  ) {+    self.report(&if_stmt.test)+  }+  fn visit_while_stmt(+    &mut self,+    while_stmt: &swc_ecma_ast::WhileStmt,+    __parent: &dyn Node,+  ) {+    self.report(&while_stmt.test)+  }+  fn visit_do_while_stmt(+    &mut self,+    do_while_stmt: &swc_ecma_ast::DoWhileStmt,+    __parent: &dyn Node,+  ) {+    self.report(&do_while_stmt.test)+  }+  fn visit_for_stmt(+    &mut self,+    for_stmt: &swc_ecma_ast::ForStmt,+    __parent: &dyn Node,+  ) {+    if let Some(cond) = for_stmt.test.as_ref() {+      self.report(cond)+    } else {+    }+  }+}++#[cfg(test)]+mod tests {+  use super::*;+  use crate::test_util::*;++  #[test]+  fn no_constant_condition_all_tests() {+    assert_lint_ok::<NoConstantCondition>(r#"if(a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a == 0);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a = f());"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(1, a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('every' in []);"#);+    assert_lint_ok::<NoConstantCondition>("if (`\\\n${a}`) {}");+    assert_lint_ok::<NoConstantCondition>(r#"if (`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`${foo()}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`${a === 'b' && b==='a'}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`foo${a}` === 'fooa');"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (tag`a`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (tag`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(~!a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(a = b);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;x < 10;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;`${a}`;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"do{ }while(x)"#);+    assert_lint_ok::<NoConstantCondition>(r#"q > 0 ? 1 : 2;"#);+    assert_lint_ok::<NoConstantCondition>(r#"`${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"`foo${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"tag`a` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"tag`${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(x += 3) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(tag`a`) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(tag`${a}`) {}"#);+    assert_lint_ok::<NoConstantCondition>("while(`\\\n${a}`) {}");++    // typeof conditions+    assert_lint_ok::<NoConstantCondition>(r#"if(typeof x === 'undefined'){}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if(`${typeof x}` === 'undefined'){}"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if(a === 'str' && typeof b){}"#);+    assert_lint_ok::<NoConstantCondition>("typeof a == typeof b");+    assert_lint_ok::<NoConstantCondition>(+      "typeof 'a' === 'string'|| typeof b === 'string'",+    );+    assert_lint_ok::<NoConstantCondition>(+      "`${typeof 'a'}` === 'string'|| `${typeof b}` === 'string'",+    );++    // void conditions+    assert_lint_ok::<NoConstantCondition>(r#"if (a || void a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (void a || a);"#);++    // TODO(humancalico) can be uncommented after adding more conditions https://github.com/eslint/eslint/blob/f4d7b9e1a599346b2f21ff9de003b311b51411e6/lib/rules/no-constant-condition.js#L135-L146+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' && abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' || abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' || abc==='str2' && pqr === 5){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(typeof abc === 'string' && abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(false || abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(typeof 'str' && abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(abc==='str' || false || def ==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && abc==='str' || def ==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && typeof abc==='string'){}"#);++    // string literals+    assert_lint_ok::<NoConstantCondition>(r#"if('str' || a){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if('str1' && a){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a && 'str'){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if('str' || abc==='str'){}"#);++    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || 'bar') === 'baz') {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || 'bar') !== 'baz') {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 'bar') == 'baz') {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 'bar') != 'baz') {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) > 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) < 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) >= 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) <= 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((key || 'k') in obj) {}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || {}) instanceof obj) {}"#,+    );++    assert_lint_ok::<NoConstantCondition>(r#"if ('' + [y] === '' + [ty]) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('a' === '' + [ty]) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('' + [y, m, d] === 'a') {}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if ('' + [y, 'm'] === '' + [ty, 'tm']) {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ('' + [y, 'm'] === '' + ['ty']) {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ([,] in++        ($2))+         ;+         else+          ;"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if ([...x]+'' === 'y'){}"#);++    // TODO(humancalico) add a configuration option for { checkLoops: false } https://eslint.org/docs/rules/no-constant-condition#checkloops+    // assert_lint_ok::<NoConstantCondition>(r#"while(true);"#);+    // assert_lint_ok::<NoConstantCondition>(r#"for(;true;);"#);+    // assert_lint_ok::<NoConstantCondition>(r#"do{}while(true)"#);++    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){while(true){yield 'foo';}}"#,);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){for(;true;){yield 'foo';}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){do{yield 'foo';}while(true)}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){while (true) { while(true) {yield;}}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {for (; yield; ) {}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {for (; ; yield) {}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {while (true) {function* foo() {yield;}yield;}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() { for (let x = yield; x < 10; x++) {yield;}yield;}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() { for (let x = yield; ; x++) { yield; }}"#);++    assert_lint_err::<NoConstantCondition>(r#"for(;true;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;``;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;`foo`;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;`foo${bar}`;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(true)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(t = -2)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(``)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(`foo`)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(`foo${bar}`)"#, 10);++    assert_lint_err::<NoConstantCondition>(r#"true ? 1 : 2;"#, 0);+    // FIXME(humancalico) Is it supposed to be on column 4+    assert_lint_err::<NoConstantCondition>(r#"q = 0 ? 1 : 2;"#, 4);+    assert_lint_err::<NoConstantCondition>(r#"(q = 0) ? 1 : 2;"#, 0);+    assert_lint_err::<NoConstantCondition>(r#"`` ? 1 : 2;"#, 0);+    assert_lint_err::<NoConstantCondition>(r#"`foo` ? 1 : 2;"#, 0);+    assert_lint_err::<NoConstantCondition>(r#"`foo${bar}` ? 1 : 2;"#, 0);+    assert_lint_err::<NoConstantCondition>(r#"if(-2);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(true);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if({});"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(0 < 1);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(0 || 1);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(a, 1);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`foo`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(``);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`\\\n`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`${'bar'}`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`${'bar' + `foo`}`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`foo${false || true}`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`foo${bar}`);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`${bar}foo`);"#, 3);++    assert_lint_err::<NoConstantCondition>(r#"while([]);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(~!0);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(x = 1);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(function(){});"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(true);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(() => {});"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(`foo`);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(``);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(`${'foo'}`);"#, 6);+    assert_lint_err::<NoConstantCondition>(r#"while(`${'foo' + 'bar'}`);"#, 6);++    // typeof conditions+    assert_lint_err::<NoConstantCondition>(r#"if(typeof x){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`${typeof x}`){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(`${''}${typeof x}`){}"#, 3);+    assert_lint_err::<NoConstantCondition>(+      r#"if(typeof 'abc' === 'string'){}"#,+      3,+    );+    assert_lint_err::<NoConstantCondition>(r#"if(a = typeof b){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(a, typeof b){}"#, 3);+    assert_lint_err::<NoConstantCondition>(+      r#"if(typeof 'a' == 'string' || typeof 'b' == 'string'){}"#,+      3,+    );+    assert_lint_err::<NoConstantCondition>(r#"while(typeof x){}"#, 6);++    // void conditions+    assert_lint_err::<NoConstantCondition>(r#"if(1 || void x);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(void x);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(y = void x);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(x, void x);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(void x === void y);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(void x && a);"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(a && void x);"#, 3);++    assert_lint_err::<NoConstantCondition>(r#"if(false && abc==='str'){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(true || abc==='str'){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if(abc==='str' || true){}"#, 3);+    assert_lint_err::<NoConstantCondition>(+      r#"if(abc==='str' || true || def ==='str'){}"#,+      3,+    );+    assert_lint_err::<NoConstantCondition>(r#"if(false || true){}"#, 3);+    assert_lint_err::<NoConstantCondition>(+      r#"if(typeof abc==='str' || true){}"#,+      3,+    );++    // string literals+    assert_lint_err::<NoConstantCondition>(r#"if('str1' || 'str2'){}"#, 3);+    assert_lint_err::<NoConstantCondition>(r#"if('str1' && 'str2'){}"#, 3);+    // TODO(humancalico) make these test pass+    // assert_lint_err::<NoConstantCondition>(r#"if(abc==='str' || 'str'){}"#, 3);+    // assert_lint_err::<NoConstantCondition>(r#"if(a || 'str'){}"#, 3);++    // assert_lint_err::<NoConstantCondition>(r#"function* foo(){while(true){} yield 'foo';}"#, );+    // assert_lint_err::<NoConstantCondition>(r#"function* foo(){while(true){if (true) {yield 'foo';}}}"#, );

These should work once this condition is added

humancalico

comment created time in 24 days

Pull request review commentdenoland/deno_lint

add no-constant-condition rule

+// Copyright 2020 the Deno authors. All rights reserved. MIT license.+use super::Context;+use super::LintRule;+use crate::swc_common::Span;+use crate::swc_common::Spanned;+use crate::swc_ecma_ast;+use crate::swc_ecma_ast::Expr;+use crate::swc_ecma_ast::Lit;+use crate::swc_ecma_ast::Module;+use std::sync::Arc;+use swc_ecma_visit::{Node, Visit};++pub struct NoConstantCondition;++impl LintRule for NoConstantCondition {+  fn new() -> Box<Self> {+    Box::new(NoConstantCondition)+  }++  fn code(&self) -> &'static str {+    "no-constant-condition"+  }++  fn lint_module(&self, context: Arc<Context>, module: &Module) {+    let mut visitor = NoConstantConditionVisitor::new(context);+    visitor.visit_module(module, module);+  }+}++struct NoConstantConditionVisitor {+  context: Arc<Context>,+}++impl NoConstantConditionVisitor {+  pub fn new(context: Arc<Context>) -> Self {+    Self { context }+  }++  fn add_diagnostic(&self, span: Span) {+    self.context.add_diagnostic(+      span,+      "no-constant-condition",+      "Use of a constant expressions as conditions is not allowed.",+    );+  }++  fn check_short_circuit(+    &self,+    expr: &Expr,+    operator: swc_ecma_ast::BinaryOp,+  ) -> bool {+    match expr {+      Expr::Lit(lit) => match lit {+        Lit::Bool(boolean) => {+          (operator == swc_ecma_ast::BinaryOp::LogicalOr && boolean.value)+            || (operator == swc_ecma_ast::BinaryOp::LogicalAnd+              && !boolean.value)+        }+        _ => false,+      },+      Expr::Unary(unary) => {+        operator == swc_ecma_ast::BinaryOp::LogicalAnd+          && unary.op == swc_ecma_ast::UnaryOp::Void+      }+      Expr::Bin(bin)+        if bin.op == swc_ecma_ast::BinaryOp::LogicalAnd+          || bin.op == swc_ecma_ast::BinaryOp::LogicalOr =>+      {+        self.check_short_circuit(&bin.left, bin.op)+          || self.check_short_circuit(&bin.right, bin.op)+      }+      _ => false,+    }+  }++  fn is_constant(+    &self,+    node: &Expr,+    parent_node: Option<&Expr>,+    in_boolean_position: bool,+  ) -> bool {+    match node {+      Expr::Lit(_) | Expr::Arrow(_) | Expr::Fn(_) | Expr::Object(_) => true,+      Expr::Tpl(tpl) => {+        (in_boolean_position+          && tpl.quasis.iter().any(|quasi| match &quasi.cooked {+            Some(str) => !str.is_empty(),+            None => false,+          }))+          || tpl.exprs.iter().all(|expr| {+            self.is_constant(expr, parent_node, in_boolean_position)+          })+      }+      // TODO(humancalico) confirm in_boolean_position here+      Expr::Paren(paren) => self.is_constant(&paren.expr, Some(node), false),+      Expr::Array(arr) => match parent_node {+        Some(Expr::Bin(bin)) => {+          if bin.op == swc_ecma_ast::BinaryOp::Add {+            arr.elems.iter().all(|element| {+              self.is_constant(+                &element.as_ref().unwrap().expr,+                parent_node,+                false,+              )+            })+          } else {+            true+          }+        }+        _ => true,+      },+      Expr::Unary(unary) => {+        if unary.op == swc_ecma_ast::UnaryOp::Void {+          true+        } else {+          (unary.op == swc_ecma_ast::UnaryOp::TypeOf && in_boolean_position)+            || self.is_constant(&unary.arg, Some(node), true)+        }+      }+      Expr::Bin(bin) => {+        // This is for LogicalExpression+        if bin.op == swc_ecma_ast::BinaryOp::LogicalOr+          || bin.op == swc_ecma_ast::BinaryOp::LogicalAnd+        {+          let is_left_constant =+            self.is_constant(&bin.left, Some(node), in_boolean_position);+          let is_right_constant =+            self.is_constant(&bin.right, Some(node), in_boolean_position);+          let is_left_short_circuit =+            is_left_constant && self.check_short_circuit(&bin.left, bin.op);+          let is_right_short_circuit =+            is_right_constant && self.check_short_circuit(&bin.right, bin.op);+          (is_left_constant && is_right_constant)+          // TODO(humancalico) add more condiitons here from https://github.com/eslint/eslint/blob/f4d7b9e1a599346b2f21ff9de003b311b51411e6/lib/rules/no-constant-condition.js#L135-L146+            || is_left_short_circuit+            || is_right_short_circuit+        }+        // These are fo regular BinaryExpression+        else if bin.op != swc_ecma_ast::BinaryOp::In {+          self.is_constant(&bin.left, Some(node), false)+            && self.is_constant(&bin.right, Some(node), false)+        } else {+          false+        }+      }+      Expr::Assign(assign) => {+        assign.op == swc_ecma_ast::AssignOp::Assign+          && self.is_constant(&assign.right, Some(node), in_boolean_position)+      }+      Expr::Seq(seq) => self.is_constant(+        &seq.exprs[seq.exprs.len() - 1],+        Some(node),+        in_boolean_position,+      ),+      _ => false,+    }+  }++  fn report(&self, condition: &Expr) {+    if self.is_constant(condition, None, true) {+      let span = condition.span();+      self.add_diagnostic(span);+    } else {+    }+  }+}++impl Visit for NoConstantConditionVisitor {+  fn visit_cond_expr(+    &mut self,+    cond_expr: &swc_ecma_ast::CondExpr,+    _parent: &dyn Node,+  ) {+    self.report(&cond_expr.test)+  }+  fn visit_if_stmt(+    &mut self,+    if_stmt: &swc_ecma_ast::IfStmt,+    _parent: &dyn Node,+  ) {+    self.report(&if_stmt.test)+  }+  fn visit_while_stmt(+    &mut self,+    while_stmt: &swc_ecma_ast::WhileStmt,+    __parent: &dyn Node,+  ) {+    self.report(&while_stmt.test)+  }+  fn visit_do_while_stmt(+    &mut self,+    do_while_stmt: &swc_ecma_ast::DoWhileStmt,+    __parent: &dyn Node,+  ) {+    self.report(&do_while_stmt.test)+  }+  fn visit_for_stmt(+    &mut self,+    for_stmt: &swc_ecma_ast::ForStmt,+    __parent: &dyn Node,+  ) {+    if let Some(cond) = for_stmt.test.as_ref() {+      self.report(cond)+    } else {+    }+  }+}++#[cfg(test)]+mod tests {+  use super::*;+  use crate::test_util::*;++  #[test]+  fn no_constant_condition_all_tests() {+    assert_lint_ok::<NoConstantCondition>(r#"if(a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a == 0);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a = f());"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(1, a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('every' in []);"#);+    assert_lint_ok::<NoConstantCondition>("if (`\\\n${a}`) {}");+    assert_lint_ok::<NoConstantCondition>(r#"if (`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`${foo()}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`${a === 'b' && b==='a'}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (`foo${a}` === 'fooa');"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (tag`a`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (tag`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(~!a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(a = b);"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(`${a}`);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;x < 10;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"for(;`${a}`;);"#);+    assert_lint_ok::<NoConstantCondition>(r#"do{ }while(x)"#);+    assert_lint_ok::<NoConstantCondition>(r#"q > 0 ? 1 : 2;"#);+    assert_lint_ok::<NoConstantCondition>(r#"`${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"`foo${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"tag`a` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"tag`${a}` === a ? 1 : 2"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(x += 3) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(tag`a`) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"while(tag`${a}`) {}"#);+    assert_lint_ok::<NoConstantCondition>("while(`\\\n${a}`) {}");++    // typeof conditions+    assert_lint_ok::<NoConstantCondition>(r#"if(typeof x === 'undefined'){}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if(`${typeof x}` === 'undefined'){}"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if(a === 'str' && typeof b){}"#);+    assert_lint_ok::<NoConstantCondition>("typeof a == typeof b");+    assert_lint_ok::<NoConstantCondition>(+      "typeof 'a' === 'string'|| typeof b === 'string'",+    );+    assert_lint_ok::<NoConstantCondition>(+      "`${typeof 'a'}` === 'string'|| `${typeof b}` === 'string'",+    );++    // void conditions+    assert_lint_ok::<NoConstantCondition>(r#"if (a || void a);"#);+    assert_lint_ok::<NoConstantCondition>(r#"if (void a || a);"#);++    // TODO(humancalico) can be uncommented after adding more conditions https://github.com/eslint/eslint/blob/f4d7b9e1a599346b2f21ff9de003b311b51411e6/lib/rules/no-constant-condition.js#L135-L146+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' && abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' || abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(xyz === 'str1' || abc==='str2' && pqr === 5){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(typeof abc === 'string' && abc==='str2'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(false || abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(typeof 'str' && abc==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(abc==='str' || false || def ==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && abc==='str' || def ==='str'){}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"if(true && typeof abc==='string'){}"#);++    // string literals+    assert_lint_ok::<NoConstantCondition>(r#"if('str' || a){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if('str1' && a){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if(a && 'str'){}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if('str' || abc==='str'){}"#);++    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || 'bar') === 'baz') {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || 'bar') !== 'baz') {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 'bar') == 'baz') {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 'bar') != 'baz') {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) > 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) < 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) >= 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((foo || 233) <= 666) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ((key || 'k') in obj) {}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if ((foo || {}) instanceof obj) {}"#,+    );++    assert_lint_ok::<NoConstantCondition>(r#"if ('' + [y] === '' + [ty]) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('a' === '' + [ty]) {}"#);+    assert_lint_ok::<NoConstantCondition>(r#"if ('' + [y, m, d] === 'a') {}"#);+    assert_lint_ok::<NoConstantCondition>(+      r#"if ('' + [y, 'm'] === '' + [ty, 'tm']) {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ('' + [y, 'm'] === '' + ['ty']) {}"#,+    );+    assert_lint_ok::<NoConstantCondition>(+      r#"if ([,] in++        ($2))+         ;+         else+          ;"#,+    );+    assert_lint_ok::<NoConstantCondition>(r#"if ([...x]+'' === 'y'){}"#);++    // TODO(humancalico) add a configuration option for { checkLoops: false } https://eslint.org/docs/rules/no-constant-condition#checkloops+    // assert_lint_ok::<NoConstantCondition>(r#"while(true);"#);+    // assert_lint_ok::<NoConstantCondition>(r#"for(;true;);"#);+    // assert_lint_ok::<NoConstantCondition>(r#"do{}while(true)"#);++    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){while(true){yield 'foo';}}"#,);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){for(;true;){yield 'foo';}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){do{yield 'foo';}while(true)}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo(){while (true) { while(true) {yield;}}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {for (; yield; ) {}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {for (; ; yield) {}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() {while (true) {function* foo() {yield;}yield;}}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() { for (let x = yield; x < 10; x++) {yield;}yield;}"#);+    // assert_lint_ok::<NoConstantCondition>(r#"function* foo() { for (let x = yield; ; x++) { yield; }}"#);++    assert_lint_err::<NoConstantCondition>(r#"for(;true;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;``;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;`foo`;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"for(;`foo${bar}`;);"#, 5);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(true)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(t = -2)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(``)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(`foo`)"#, 10);+    assert_lint_err::<NoConstantCondition>(r#"do{}while(`foo${bar}`)"#, 10);++    assert_lint_err::<NoConstantCondition>(r#"true ? 1 : 2;"#, 0);+    // FIXME(humancalico) Is it supposed to be on column 4+    assert_lint_err::<NoConstantCondition>(r#"q = 0 ? 1 : 2;"#, 4);

Just checked it on https://eslint.org/demo and it to be correct. I'll remove the FIXME tag.

humancalico

comment created time in 24 days

Pull request review commentdenoland/deno_lint

add no-constant-condition rule

+// Copyright 2020 the Deno authors. All rights reserved. MIT license.+use super::Context;+use super::LintRule;+use crate::swc_common::Span;+use crate::swc_common::Spanned;+use crate::swc_ecma_ast;+use crate::swc_ecma_ast::Expr;+use crate::swc_ecma_ast::Lit;+use crate::swc_ecma_ast::Module;+use std::sync::Arc;+use swc_ecma_visit::{Node, Visit};++pub struct NoConstantCondition;++impl LintRule for NoConstantCondition {+  fn new() -> Box<Self> {+    Box::new(NoConstantCondition)+  }++  fn code(&self) -> &'static str {+    "no-constant-condition"+  }++  fn lint_module(&self, context: Arc<Context>, module: &Module) {+    let mut visitor = NoConstantConditionVisitor::new(context);+    visitor.visit_module(module, module);+  }+}++struct NoConstantConditionVisitor {+  context: Arc<Context>,+}++impl NoConstantConditionVisitor {+  pub fn new(context: Arc<Context>) -> Self {+    Self { context }+  }++  fn add_diagnostic(&self, span: Span) {+    self.context.add_diagnostic(+      span,+      "no-constant-condition",+      "Use of a constant expressions as conditions is not allowed.",+    );+  }++  fn check_short_circuit(+    &self,+    expr: &Expr,+    operator: swc_ecma_ast::BinaryOp,+  ) -> bool {+    match expr {+      Expr::Lit(lit) => match lit {+        Lit::Bool(boolean) => {+          (operator == swc_ecma_ast::BinaryOp::LogicalOr && boolean.value)+            || (operator == swc_ecma_ast::BinaryOp::LogicalAnd+              && !boolean.value)+        }+        _ => false,+      },+      Expr::Unary(unary) => {+        operator == swc_ecma_ast::BinaryOp::LogicalAnd+          && unary.op == swc_ecma_ast::UnaryOp::Void+      }+      Expr::Bin(bin)+        if bin.op == swc_ecma_ast::BinaryOp::LogicalAnd+          || bin.op == swc_ecma_ast::BinaryOp::LogicalOr =>+      {+        self.check_short_circuit(&bin.left, bin.op)+          || self.check_short_circuit(&bin.right, bin.op)+      }+      _ => false,+    }+  }++  fn is_constant(+    &self,+    node: &Expr,+    parent_node: Option<&Expr>,+    in_boolean_position: bool,+  ) -> bool {+    match node {+      Expr::Lit(_) | Expr::Arrow(_) | Expr::Fn(_) | Expr::Object(_) => true,+      Expr::Tpl(tpl) => {+        (in_boolean_position+          && tpl.quasis.iter().any(|quasi| match &quasi.cooked {+            Some(str) => !str.is_empty(),+            None => false,+          }))+          || tpl.exprs.iter().all(|expr| {+            self.is_constant(expr, parent_node, in_boolean_position)+          })+      }+      // TODO(humancalico) confirm in_boolean_position here

There is no Expression for Paren in the original eslint implementation and I was not sure what in_boolean_position does (it says false if checking branch of a condition. true in all other cases) so I am not sure if it'll be false here.

humancalico

comment created time in 24 days

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 3a5b380acdebdf5372cc1dcc647c7dc8a2f69c97

run clippy

view details

push time in 25 days

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 4bb425772b6fe2e0c90f9d41b61b516a92df6286

change Context to Arc<Context>

view details

push time in 25 days

push eventhumancalico/deno_lint

Yusuke Tanaka

commit sha 0bbe975f5b1f9606dc0592d4530ed661b6308682

Add no-control-regex rule (#219)

view details

Bartek Iwańczuk

commit sha ad6259ae5ef4bd55c2cde2788049d86fb7e89ef8

fix benchmarks (#224)

view details

Bartek Iwańczuk

commit sha 6f2902af569e91b0be486bce747386b742fd9a9d

perf: remove unnecessary module clones (#226)

view details

Bartek Iwańczuk

commit sha ee96e55ed40ee7d19a30feba61f2068c6c0e3e94

perf: use Arc<Context>, perform single scope analysis (#223)

view details

Luca Casonato

commit sha 0780509462c646d7e1d9baffb628254167115588

docs: add how to generate flamegraph (#227)

view details

Bartek Iwańczuk

commit sha 4295151bc12c3dc83b194aac473d5ff011856cc9

chore: add debug logging with basic timers (#229)

view details

Akshat Agarwal

commit sha 3c4ab684050836a81bd4f96fcfedcb4a4661bc25

wip

view details

Akshat Agarwal

commit sha 2d4e5a6880e7c103861657ec54742312696f2c7d

bin expr error

view details

Akshat Agarwal

commit sha ed8887c4010db4bf90112edbb4cfd42ba012145f

semicolon

view details

Akshat Agarwal

commit sha c97644e5337bdca776bd3d6fad226ffa9e89444c

add short circuit check

view details

Akshat Agarwal

commit sha bf5ab1d3c2326c736e0dd99a8983c0abbf86545a

constant check todo

view details

Akshat Agarwal

commit sha dee2edbf09eb411e339cb100e4e0deead8500237

pattern matching err

view details

Akshat Agarwal

commit sha cdfec75cd8b9951b985cf324b93c87db6bce4bdc

wip

view details

Akshat Agarwal

commit sha c0a933b1546d0ad70cb38202d58800b3adbbff24

wip

view details

Akshat Agarwal

commit sha 71b272c78f06e7636bc45d7a376c335a9e4e4a7c

short circuit bug

view details

Akshat Agarwal

commit sha 74ee0a4c7201f6a839a2c74ed1100ca41d6b65ac

almost done :\

view details

Akshat Agarwal

commit sha 033c93b11683724cc261b24e3f32ae1bb7171f11

almost done 2.0

view details

Akshat Agarwal

commit sha ef4b8d1d68ad302f64fa34c83c034e92bff3d9d2

add rule no_constant_condition

view details

push time in 25 days

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 9ad63fd4e864ce1e92ddcab60e327c24d37375ea

almost done 2.0

view details

push time in 25 days

startedsindresorhus/refined-github

started time in 25 days

startedalacritty/alacritty

started time in 25 days

startedruma/ruma

started time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha c0ed21b00d471d3d7b739aae0e32fb9458b63ebd

almost done :\

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha ac645b984b776d9f49404d1b2e35720fb323482b

wip

view details

Akshat Agarwal

commit sha cd15c97446d9292ebc5978bdb311df9f50769333

short circuit bug

view details

push time in a month

push eventhumancalico/servo

JavaScript Joe

commit sha a5e88d8ee5c857e55d719ff0a131c2205c9455c1

Update README.md

view details

Fernando Jiménez Moreno

commit sha 8882713ce6cdeb40a650813f844c2fd7b3efa29e

[Layout 2020] Adapt layout viewer to new box and fragment tree structs

view details

Kunal Mohan

commit sha 71401e0855c24e4cf86a754171f0162ae08d8e55

Implement GPUSwapChain and GPUCanvasContext and interface with Webrender

view details

Kunal Mohan

commit sha 2c95df73a4d74b24db451e5ff1d3ccc5ced10fe2

Add WebGPU to Layout-2020

view details

bors-servo

commit sha 6b0d9afd6fdc28356ad44af0104ddd25a7b6438d

Auto merge of #26913 - humancalico:master, r=jdm support Pop!_OS 20.04 for mach bootstrap

view details

dependabot-preview[bot]

commit sha ee352dfe653be9b31594fd83d97bc2628ba658bc

build(deps): bump futures-util from 0.3.4 to 0.3.5 Bumps [futures-util](https://github.com/rust-lang/futures-rs) from 0.3.4 to 0.3.5. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.4...0.3.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

view details

dependabot-preview[bot]

commit sha 52ffb213f35e08fe650cdf90a8554e01ce6a2e0e

build(deps): bump num_cpus from 1.10.1 to 1.13.0 Bumps [num_cpus](https://github.com/seanmonstar/num_cpus) from 1.10.1 to 1.13.0. - [Release notes](https://github.com/seanmonstar/num_cpus/releases) - [Changelog](https://github.com/seanmonstar/num_cpus/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/num_cpus/compare/v1.10.1...v1.13.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

view details

Martin Robinson

commit sha 4a3995bb375d43d53666a348ec0c08065784f6ea

Add DocumentAnimationSet and AnimationSetKey This will be used in order to hold animations for pseudo elements in the DocumentAnimationSet. Also no longer store the OpaqueNode in the animation and transition data structures. This is already part of the DocumentAnimationSet key.

view details

dependabot-preview[bot]

commit sha 7fb450aeea95da7e56bcbe752c684a54a117186c

build(deps): bump chrono from 0.4.9 to 0.4.11 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.9 to 0.4.11. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/master/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.9...v0.4.11) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

view details

dependabot-preview[bot]

commit sha fe2f23e79e9985513db7fb988858a94fec7de508

build(deps): bump siphasher from 0.3.1 to 0.3.3 Bumps [siphasher](https://github.com/jedisct1/rust-siphash) from 0.3.1 to 0.3.3. - [Release notes](https://github.com/jedisct1/rust-siphash/releases) - [Commits](https://github.com/jedisct1/rust-siphash/compare/0.3.1...0.3.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

view details

Josh Matthews

commit sha 757371f4f08aca089659fa6774e74bb90b511363

Make clicking on an element request focus for focusable elements.

view details

Josh Matthews

commit sha d55424e88f732c663d1ec988a3fbe98d6c9a89e5

Update document focus when element focusability changes.

view details

bors-servo

commit sha f31d345c814e1626cb5007e9b25e28c267853b14

Auto merge of #26902 - jdm:focus-fixes, r=nox Focus correctness improvements These changes improve the behaviour of focus in Hubs rooms, and are expected to improve web compat around other dynamic pages that receive keyboard events as well. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #26901 and fix #26900. - [x] There are tests for these changes

view details

Anthony Ramine

commit sha b66dd66403f990db1a287ea70841194aa388a519

Rename contents to context in AbsolutelyPositionedBox

view details

Anthony Ramine

commit sha b53959d23d54e3a30a4c9d01ab2eb5b605d2579c

Move IndependentFormattingContext::as_replaced to IndependentFormattingContextContents

view details

Anthony Ramine

commit sha d0a1066d2d4fee2ac307bb4ec11ac843a76a26f7

Remove PositioningContext::create_and_layout_positioned It has only one call site.

view details

Anthony Ramine

commit sha 07d8c28d4aa8c2834bba0759321ae1363ba43d54

Make outer_inline and outer_inline_and_percentages free functions They now take a closure that will compute the content sizes on demand.

view details

Anthony Ramine

commit sha db80b8e3c15006c54ba2d2a9c919ca7f87ba2b35

Make IndependentFormattingContext an enum

view details

bors-servo

commit sha 24cc72ba85fdec01ecc135313b09ae78d7b9b5f8

Auto merge of #26852 - servo:layout-2020-independent-kind, r=SimonSapin Some more boring stuff to change how we compute content sizes

view details

bors-servo

commit sha abc3ed40c9daf8c7a68d82a2d5fb40ad632eb27f

Auto merge of #26872 - kunalmohan:gpu-canvas-context, r=kvark,jdm Implement GPUSwapChain and GPUCanvasContext and interface with Webrender <!-- Please describe your changes on the following line: --> r?@kvark --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

view details

push time in a month

starteddaemon1024/1024sh

started time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 6361a69680b32c8f06a295a704f731523b306f18

wip

view details

push time in a month

startedjlevy/the-art-of-command-line

started time in a month

startedbeakerbrowser/beaker

started time in a month

push eventhumancalico/humancalico

Akshat Agarwal

commit sha d5650cbdb7a74fd628f36e3730a0e18ceae15d97

Update README.md

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 5bd901a24cdd00bf82fa3b6e6aada5fd7cd491c4

pattern matching err

view details

push time in a month

startedaaryanporwal/uprighthelper

started time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha a55d139a722b5dfe06f2472ffad9c4b333733d8a

constant check todo

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 5ca775b202ea13fe9a42b3af353361dd70bef63d

add short circuit check

view details

push time in a month

push eventhumancalico/humancalico

Akshat Agarwal

commit sha 4417dc6b2948258d7b9130164c32f99a0c6cb9ff

Update README.md

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 3398244032a041bb179336b294f43587f8b349eb

semicolon

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha fb831ee3ab67f85a7dbb2934e61d2fc8b2039016

bin expr error

view details

push time in a month

push eventhumancalico/deno_lint

Akshat Agarwal

commit sha 53a04fc6c97641307548c78397d28978f56856e4

wip

view details

push time in a month

create barnchhumancalico/deno_lint

branch : no-constant-condition

created branch time in a month

fork humancalico/deno_lint

Blazing fast linter for JavaScript and TypeScript written in Rust

fork in a month

create barnchhumancalico/humancalico

branch : master

created branch time in a month

created repositoryhumancalico/humancalico

created time in a month

push eventhumancalico/vatican

Akshat Agarwal

commit sha cd98e52a3ed89dfd063641aaa3e71eec74b5289d

Create README.md

view details

push time in a month

push eventhumancalico/vatican

Akshat Agarwal

commit sha 7c9e4d29b5bbdd0b86411acf04cf9f80f4742a35

not found in scope error

view details

push time in a month

push eventhumancalico/vatican

Akshat Agarwal

commit sha 1fa98746926a9a027924211ea985aa2b0bc21251

some parsing

view details

push time in a month

create barnchhumancalico/vatican

branch : parser

created branch time in a month

create barnchhumancalico/vatican

branch : master

created branch time in a month

created repositoryhumancalico/vatican

smol compiler written in Rust

created time in a month

startedRichardLitt/meta-knowledge

started time in a month

startedtherealansh/iiit_sonepat_app

started time in 2 months

startedgit-tips/tips

started time in 2 months

PR opened anshtyagi23/demo

demo
+2 -0

0 comment

2 changed files

pr created time in 2 months

create barnchhumancalico/demo

branch : new-feature

created branch time in 2 months

push eventhumancalico/demo

Akshat

commit sha b19affbc3bdd3fe18d860b24f16eb21ce832e98d

add

view details

push time in 2 months

startedmre/idiomatic-rust

started time in 2 months

more