Blazing fast linter for JavaScript and TypeScript written in Rust

Overview

deno_lint

Discord Chat

A Rust crate for writing fast JavaScript and TypeScript linters.

This crate powers deno lint, but is not Deno specific and can be used to write linters for Node as well.

Supports recommended set of rules from ESLint and @typescript-eslint out of the box with no config.

See the roadmap


Supported rules

Visit https://lint.deno.land for the list of available rules.

Performance

Blazing fast, see comparison with ESLint:

[
  {
    "name": "deno_lint",
    "totalMs": 105.3750100000002,
    "runsCount": 5,
    "measuredRunsAvgMs": 21.07500200000004,
    "measuredRunsMs": [
      24.79783199999997,
      19.563640000000078,
      20.759051999999883,
      19.99068000000011,
      20.26380600000016
    ]
  },
  {
    "name": "eslint",
    "totalMs": 11845.073306000002,
    "runsCount": 5,
    "measuredRunsAvgMs": 2369.0146612000003,
    "measuredRunsMs": [
      2686.1039550000005,
      2281.501061,
      2298.6185210000003,
      2279.5962849999996,
      2299.2534840000008
    ]
  }
]

Benchmarks are run during CI on Ubuntu, using the same set of rules for both linters. Test subject is oak server consisting of about 50 files. See ./benchmarks/ directory for more info.

Node.js bindings

If you want to use deno_lint with Node, please refer to @node-rs/deno-lint package which provides programmatic API as well as Webpack loader for deno_lint.

Example

examples/dlint/main.rs provides a minimal standalone binary demonstrating how deno_lint can be used as a crate.

# Build standalone binary
$ cargo build --example dlint

$ ./target/debug/examples/dlint --help

dlint

USAGE:
    dlint <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    help     Prints this message or the help of the given subcommand(s)
    rules
    run

$ ./target/debug/examples/dlint run ../deno/std/http/server.ts ../deno/std/http/file_server.ts
(no-empty) Empty block statement
  --> ../deno/std/http/server.ts:93:14
   |
93 |       } catch {}
   |               ^^
   |
(no-empty) Empty block statement
   --> ../deno/std/http/server.ts:111:44
    |
111 |     while ((await body.read(buf)) !== null) {}
    |                                             ^^
    |
(no-empty) Empty block statement
   --> ../deno/std/http/server.ts:120:41
    |
120 |   constructor(public listener: Listener) {}
    |                                          ^^
    |
(ban-untagged-todo) TODO should be tagged with (@username) or (#issue)
 --> ../deno/std/http/file_server.ts:5:0
  |
5 | // TODO Stream responses instead of reading them into memory.
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
(ban-untagged-todo) TODO should be tagged with (@username) or (#issue)
 --> ../deno/std/http/file_server.ts:6:0
  |
6 | // TODO Add tests like these:
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
(ban-untagged-todo) TODO should be tagged with (@username) or (#issue)
   --> ../deno/std/http/file_server.ts:137:0
    |
137 | // TODO: simplify this after deno.stat and deno.readDir are fixed
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
(no-empty) Empty block statement
   --> ../deno/std/http/file_server.ts:155:16
    |
155 |     } catch (e) {}
    |                 ^^
    |
Found 7 problems

For more concrete implementation visit deno

Developing

Make sure to have latest stable version of Rust installed (1.56.0).

// check version
$ rustc --version
rustc 1.56.0 (09c42c458 2021-10-18)

// build all targets
$ cargo build --all-targets

// test it
$ cargo test

Generating flamegraph (Linux)

Prerequisites:

$ RUSTFLAGS='-g' cargo build --release --all-targets # build target
$ sudo perf record --call-graph dwarf ./target/release/examples/dlint benchmarks/oak/**.ts # create performance profile
$ perf script | stackcollapse-perf | c++filt | flamegraph > flame.svg # generate flamegraph

You can use rust-unmangle or rustfilt instead of c++filt.

These commands can take a few minutes to run.

Contributing

Submitting a Pull Request

Before submitting, please make sure the following is done:

  1. That there is a related issue and it is referenced in the PR text.
  2. There are tests that cover the changes.
  3. Ensure cargo test passes.
  4. Format your code with deno run --allow-run tools/format.ts
  5. Make sure deno run --allow-run tools/lint.ts passes.
Comments
  • add Camelcase rule

    add Camelcase rule

    ~~work in progress~~

    In this PR, I implemented the camelcase rule. https://eslint.org/docs/rules/camelcase Besides I ported all the tests from ESLint, and they are all passed.

    Closes #301

    opened by magurotuna 37
  • ESLint recommended rules

    ESLint recommended rules

    Tracking issue for rules from eslint:recommended set.

    • [x] constructor-super
    • [x] for-direction
    • [x] getter-return
    • [x] no-async-promise-executor
    • [x] no-case-declarations
    • [x] no-class-assign (broken, needs scope analysis)
    • [x] no-compare-neg-zero
    • [x] no-cond-assign
    • [x] no-const-assign (broken, needs scope analysis)
    • [x] no-constant-condition
    • [x] no-control-regex (easy)
    • [x] no-debugger
    • [x] no-delete-var
    • [x] no-dupe-args
    • [x] no-dupe-class-members
    • [x] no-dupe-else-if
    • [x] no-dupe-keys
    • [x] no-duplicate-case
    • [x] no-empty
    • [x] no-empty-character-class
    • [x] no-empty-pattern
    • [x] no-ex-assign (broken, needs scope analysis)
    • [x] no-extra-boolean-cast
    • [x] no-extra-semi
    • [x] no-fallthrough (hard, needs code path analysis)
    • [x] no-func-assign (broken, needs scope analysis)
    • [x] no-global-assign (hard, needs scope analysis)
    • [x] no-import-assign (hard, needs scope analysis)
    • [x] no-inner-declarations
    • [x] no-invalid-regexp(easy hard, need to port additional lib)
    • [x] no-irregular-whitespace (easy)
    • [ ] no-misleading-character-class (easy)
    • [x] no-mixed-spaces-and-tabs
    • [x] no-new-symbol
    • [x] no-obj-calls
    • [x] no-octal
    • [x] no-prototype-builtins
    • [x] no-redeclare (hard, needs scope analysis)
    • [x] no-regex-spaces
    • [x] no-self-assign
    • [x] no-setter-return
    • [x] no-shadow-restriced-names
    • [x] no-sparse-arrays
    • [x] no-this-before-super
    • [x] no-undef (hard, needs scope analysis)
    • [x] no-unexpected-multiline (easy)
    • [x] no-unreachable (hard, needs code path analysis)
    • [x] no-unsafe-finally
    • [x] no-unsafe-negation
    • [x] no-unused-labels
    • [x] no-unused-vars (hard, needs scope analysis)
    • [x] no-useless-escape (easy) (https://github.com/denoland/deno_lint/issues/48#issuecomment-666285937)
    • [x] no-with
    • [x] require-yield
    • [x] use-isnan
    • [x] valid-typeof
    epic 
    opened by bartlomieju 19
  • getter-return and infinite loops

    getter-return and infinite loops

    The following code produces "Getter requires a return deno-lint(getter-return)" despite the return statement. I wonder if it's possible for the linter to recognize that the only way out of the loop and out of the function is through the return?

    I would have just ignored the linter and not opened an issue except that the linter clearly recognizes that the last line when uncommented is redundant since uncommenting it silences deno-lint(getter-return), but produces a deno-lint(no-unreachable) error instead.

    get root(): this {
            // deno-lint-ignore no-this-alias
            let primary = this;
            while (true) {
                if (primary.parent !== undefined) {
                    primary = primary.parent;
                } else {
                    return primary;
                }
            }
            //return this;
        }
    

    deno 1.4.0 v8 8.7.75 typescript 4.0.2 VS Code extension 2.3.1

    I'm fine with a "Won't Fix" on this BTW.

    opened by callionica 14
  • Feature Request: Webpack Loader for Deno Lint

    Feature Request: Webpack Loader for Deno Lint

    I think it would be great if we have a webpack loader for deno lint, and would be configurable to break the build whenever it encounters a lint error

    example webpack configuration:

    {
                        test: /\.(ts|js)$/,
                        enforce: "pre",
                        loader: "deno-lint-loader",
                        options: {
                            emitErrors: true,
                            failOnHint: true
                        }
                    }
    
    request 
    opened by jetfontanilla 14
  • Errors reported twice by dlint.

    Errors reported twice by dlint.

    Lint Name

    All, or at least most.

    Code Snippet

    for(var x;;);
    

    Expected Result

    error[no-inner-declarations]: Move variable declaration to module root
     --> C:\...\test-script.js:1:5
      |
    1 | for(var x;;);
      |     ^^^^^
      |
      = help: Move the declaration up into the correct scope
    Found 1 problem
    

    Actual Result

    error[no-inner-declarations]: Move variable declaration to module root
     --> C:\...\test-script.js:1:5
      |
    1 | for(var x;;);
      |     ^^^^^
      |
      = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to module root
     --> C:\...\test-script.js:1:5
      |
    1 | for(var x;;);
      |     ^^^^^
      |
      = help: Move the declaration up into the correct scope
    Found 2 problems
    

    Additional Info

    This happens for almost all errors reported.

    It's strange that this has not be noticed before. Perhaps this is unique to the Windows executable?

    Just in case it helps to see more examples, I've added an additional, much larger, output from a module that is constrained to ES3 which produces a variety of linting errors (in part because it's been coded for easy transformation to ES2015+ as soon as we can get rid of a very old host-side JS runtime in production).

    Version

    dlint 0.6.0

    Additional Results

    C:\...\build\code>cls & dlint run --config=C:\...\build\$DenoLintRules.json C:\...\business\code\libweb\src\util\GeneralUtil.js
    
    error[no-inner-declarations]: Move variable declaration to function root
      --> C:\...\src\util\GeneralUtil.js:90:9
       |
    90 |     for(var xa=0; xa<fncs.length; ++xa) {
       |         ^^^^^^^^
       |
       = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
      --> C:\...\src\util\GeneralUtil.js:90:9
       |
    90 |     for(var xa=0; xa<fncs.length; ++xa) {
       |         ^^^^^^^^
       |
       = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
      --> C:\...\src\util\GeneralUtil.js:99:17
       |
    99 |             for(var xa=0,len=fncs.length; xa<len; ++xa) { fncs[xa].apply(null,args); }
       |                 ^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
      --> C:\...\src\util\GeneralUtil.js:99:17
       |
    99 |             for(var xa=0,len=fncs.length; xa<len; ++xa) { fncs[xa].apply(null,args); }
       |                 ^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:189:17
        |
    189 |             for(var xa=0,len=cmpfncs.length; xa<len && cmpres==0; ++xa) { cmpres=cmpfncs[xa](onercd,tworcd); }
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:189:17
        |
    189 |             for(var xa=0,len=cmpfncs.length; xa<len && cmpres==0; ++xa) { cmpres=cmpfncs[xa](onercd,tworcd); }
        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-extra-semi]: Unnecessary semicolon.
       --> C:\...\src\util\GeneralUtil.js:230:10
        |
    230 |         };
        |          ^
        |
        = help: Remove the extra (and unnecessary) semi-colon
    error[no-extra-semi]: Unnecessary semicolon.
       --> C:\...\src\util\GeneralUtil.js:230:10
        |
    230 |         };
        |          ^
        |
        = help: Remove the extra (and unnecessary) semi-colon
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:252:9
        |
    252 |     for(var key in obj) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:252:9
        |
    252 |     for(var key in obj) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
       --> C:\...\src\util\GeneralUtil.js:253:13
        |
    253 |         if(!obj.hasOwnProperty(key)) { continue; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^
        |
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
       --> C:\...\src\util\GeneralUtil.js:253:13
        |
    253 |         if(!obj.hasOwnProperty(key)) { continue; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^
        |
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:254:9
        |
    254 |         var val=obj[key];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:254:9
        |
    254 |         var val=obj[key];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:299:9
        |
    299 |     for(var dft of argsArray(arguments,1)) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:299:9
        |
    299 |     for(var dft of argsArray(arguments,1)) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:328:9
        |
    328 |         var args=argsArray(arguments,2);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:328:9
        |
    328 |         var args=argsArray(arguments,2);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:344:13
        |
    344 |         for(var xa=0, len=arr.length; xa<len; ++xa) {
        |             ^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:344:13
        |
    344 |         for(var xa=0, len=arr.length; xa<len; ++xa) {
        |             ^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:417:21
        |
    417 |     if(exctyps) for(var xa=0,len=exctyps.length; xa<len; ++xa) {
        |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:417:21
        |
    417 |     if(exctyps) for(var xa=0,len=exctyps.length; xa<len; ++xa) {
        |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:489:9
        |
    489 |     for(var xa=1,len=arguments.length; xa<len; ++xa ) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:489:9
        |
    489 |     for(var xa=1,len=arguments.length; xa<len; ++xa ) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:515:9
        |
    515 |     for(var xa=1,len=arguments.length; xa<len; ++xa) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:515:9
        |
    515 |     for(var xa=1,len=arguments.length; xa<len; ++xa) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:517:13
        |
    517 |         for(var keys=Object.keys(src), xb=0; xb<keys.length; xb++) { var key=keys[xb]; tgt[key]=src[key]; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:517:70
        |
    517 |         for(var keys=Object.keys(src), xb=0; xb<keys.length; xb++) { var key=keys[xb]; tgt[key]=src[key]; }
        |                                                                      ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:517:13
        |
    517 |         for(var keys=Object.keys(src), xb=0; xb<keys.length; xb++) { var key=keys[xb]; tgt[key]=src[key]; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:517:70
        |
    517 |         for(var keys=Object.keys(src), xb=0; xb<keys.length; xb++) { var key=keys[xb]; tgt[key]=src[key]; }
        |                                                                      ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:565:9
        |
    565 |     for(var xa=1,len=arguments.length; xa<len; ++xa ) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:565:9
        |
    565 |     for(var xa=1,len=arguments.length; xa<len; ++xa ) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-extra-semi]: Unnecessary semicolon.
       --> C:\...\src\util\GeneralUtil.js:634:10
        |
    634 |         };
        |          ^
        |
        = help: Remove the extra (and unnecessary) semi-colon
    error[no-extra-semi]: Unnecessary semicolon.
       --> C:\...\src\util\GeneralUtil.js:634:10
        |
    634 |         };
        |          ^
        |
        = help: Remove the extra (and unnecessary) semi-colon
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:640:9
        |
    640 |         var stgval=localStorage.getItem(stgnam);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:640:9
        |
    640 |         var stgval=localStorage.getItem(stgnam);
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-empty]: Empty block statement
       --> C:\...\src\util\GeneralUtil.js:642:75
        |
    642 |             try { curval=JSON.parse(stgval).value || curval; } catch(err) {}                                            // ignore error, leaving current value unchanged
        |                                                                           ^^
        |
        = help: Add code or comment to the empty block
    error[no-empty]: Empty block statement
       --> C:\...\src\util\GeneralUtil.js:642:75
        |
    642 |             try { curval=JSON.parse(stgval).value || curval; } catch(err) {}                                            // ignore error, leaving current value unchanged
        |                                                                           ^^
        |
        = help: Add code or comment to the empty block
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:646:9
        |
    646 |         var inival=curval;
        |         ^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:646:9
        |
    646 |         var inival=curval;
        |         ^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:780:9
        |
    780 |     for(var xa=0,len=pths.length; xa<len; ++xa) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:780:9
        |
    780 |     for(var xa=0,len=pths.length; xa<len; ++xa) {
        |         ^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:781:9
        |
    781 |         var pth=pths[xa];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:781:9
        |
    781 |         var pth=pths[xa];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:782:9
        |
    782 |         var spl=pth.lastIndexOf("/");
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:782:9
        |
    782 |         var spl=pth.lastIndexOf("/");
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:783:9
        |
    783 |         var par,lea;
        |         ^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:783:9
        |
    783 |         var par,lea;
        |         ^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:839:9
        |
    839 |         var args=argsArray(arguments,1);                                                                                // include `fnc` which will become the current count
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:839:9
        |
    839 |         var args=argsArray(arguments,1);                                                                                // include `fnc` which will become the current count
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:842:13
        |
    842 |             var lmt=cnt;
        |             ^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:842:13
        |
    842 |             var lmt=cnt;
        |             ^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:845:13
        |
    845 |         for(var xa=0; cnt(xa); ++xa) {
        |             ^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:845:13
        |
    845 |         for(var xa=0; cnt(xa); ++xa) {
        |             ^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:986:9
        |
    986 |     for(var key in obj) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:986:9
        |
    986 |     for(var key in obj) {
        |         ^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
       --> C:\...\src\util\GeneralUtil.js:987:13
        |
    987 |         if(!obj.hasOwnProperty(key)) { continue; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^
        |
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
       --> C:\...\src\util\GeneralUtil.js:987:13
        |
    987 |         if(!obj.hasOwnProperty(key)) { continue; }
        |             ^^^^^^^^^^^^^^^^^^^^^^^
        |
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:988:9
        |
    988 |         var val=obj[key];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:988:9
        |
    988 |         var val=obj[key];
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:998:13
        |
    998 |         for(var xa=0,len=srcobj.length; xa<len; ++xa) {
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:998:13
        |
    998 |         for(var xa=0,len=srcobj.length; xa<len; ++xa) {
        |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:999:13
        |
    999 |             var srcval=srcobj[xa];
        |             ^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
       --> C:\...\src\util\GeneralUtil.js:999:13
        |
    999 |             var srcval=srcobj[xa];
        |             ^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1016:13
         |
    1016 |         for(var key in srcobj) {
         |             ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1016:13
         |
    1016 |         for(var key in srcobj) {
         |             ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1017:17
         |
    1017 |             if(!srcobj.hasOwnProperty(key)) { continue; }
         |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1017:17
         |
    1017 |             if(!srcobj.hasOwnProperty(key)) { continue; }
         |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1018:13
         |
    1018 |             var srcval=srcobj[key];
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-redeclare]: Redeclaration is not allowed
        --> C:\...\src\util\GeneralUtil.js:1018:17
         |
    1018 |             var srcval=srcobj[key];
         |                 ^^^^^^
         |
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1018:13
         |
    1018 |             var srcval=srcobj[key];
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-redeclare]: Redeclaration is not allowed
        --> C:\...\src\util\GeneralUtil.js:1018:17
         |
    1018 |             var srcval=srcobj[key];
         |                 ^^^^^^
         |
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1040:9
         |
    1040 |     for(var key in obj) {
         |         ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1040:9
         |
    1040 |     for(var key in obj) {
         |         ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1041:13
         |
    1041 |         if(!obj.hasOwnProperty(key)) { continue; }
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1041:13
         |
    1041 |         if(!obj.hasOwnProperty(key)) { continue; }
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1042:9
         |
    1042 |         var val=obj[key];
         |         ^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1042:9
         |
    1042 |         var val=obj[key];
         |         ^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1054:9
         |
    1054 |     for(var key in obj) {
         |         ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1054:9
         |
    1054 |     for(var key in obj) {
         |         ^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1055:13
         |
    1055 |         if(!obj.hasOwnProperty(key)) { continue; }
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-prototype-builtins]: Access to Object.prototype.hasOwnProperty is not allowed from target object
        --> C:\...\src\util\GeneralUtil.js:1055:13
         |
    1055 |         if(!obj.hasOwnProperty(key)) { continue; }
         |             ^^^^^^^^^^^^^^^^^^^^^^^
         |
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1056:9
         |
    1056 |         var val     = obj[key];
         |         ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    error[no-inner-declarations]: Move variable declaration to function root
        --> C:\...\src\util\GeneralUtil.js:1056:9
         |
    1056 |         var val     = obj[key];
         |         ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: Move the declaration up into the correct scope
    Found 84 problems
    
    C:\...\build\code>
    
    bug 
    opened by lawrence-dol 12
  • Changes to LintRule

    Changes to LintRule

    • Add LintRule::lint_program(&self, context: &mut Context, program: &swc_ecmascript::ast::Program) in favor of LintRule::lint_module - prerequisite for #366

    • Rules should implement Visit trait directly on the struct implementing LintRule instead of creating additional visitor for each rule

    opened by bartlomieju 12
  • feat: proof of concept for plugin system

    feat: proof of concept for plugin system

    Ref #159

    • [x] add deno_core as dev dependency
    • [ ] accept some flag (--plugins) that collects path to JS files containing JS visitors
    • [x] create JsRuntime and execute visitor code in global scope (this is hacky, but way simpler to implement than using modules)
    • [x] obtain JSON AST from Rust
    • [ ] load provided plugin files
    • [ ] for each loaded plugin file run its visitor and collect diagnostics (let's say that we expect plugin files to have default export which is a subclass of Visitor)
    • [x] return diagnostics to Rust for further processing
    opened by littledivy 11
  • Question: Why does deno not use `get_recommended_rules`?

    Question: Why does deno not use `get_recommended_rules`?

    deno_lint provides get_recommended_rules function as public, so that users of deno_lint can get information about available implemented rules. However, this function seems not to be used by deno, and deno has its own get_rules function.

    Is this a temporary measure until deno_lint implements all of the recommended rules? In other words, once deno_lint has the all recommended rules implemented, deno will use get_recommended_rules instead of get_rules? I'm curious about the reason why deno is not using get_recommended_rules now.

    opened by magurotuna 11
  • typescript-eslint recommended rules

    typescript-eslint recommended rules

    Tracking issues for recommended rules of typescript-eslint

    https://github.com/typescript-eslint/typescript-eslint/blob/v3.1.0/packages/eslint-plugin/src/configs/recommended.ts

    • [x] adjacent-overload-signatures (easy)
    • [x] ban-ts-comment
    • [x] ban-types
    • [x] explicit-module-boundary-types (easy)
    • [x] no-array-constructor
    • [x] no-empty-function (needs to be fixed, false positives for constructors)
    • [x] no-empty-interface
    • [x] no-explicit-any
    • [x] no-extra-non-null-assertion
    • [x] no-extra-semi (easy)
    • [x] no-inferrable-types (easy)
    • [x] no-misused-new
    • [x] no-namespace
    • [x] no-non-null-asserted-optional-chain
    • [x] no-non-null-assertion
    • [x] no-this-alias
    • [x] no-unused-vars (hard, needs scope analysis)
    • [x] no-var-requires
    • [x] prefer-as-const
    • [x] prefer-namespace-keyword
    • [x] triple-slash-reference
    epic 
    opened by bartlomieju 11
  • Unused import triggers no-unused-vars rule

    Unused import triggers no-unused-vars rule

    Lint Name

    no-unused-vars

    Code Snippet

    import { anything } from './file.ts';
    

    Expected Result

    Warning related to unused import

    Actual Result

    no-unused-vars warning

    Additional Info

    To be specific, renaming... certainly works, but isn't as simple as the warning suggests

    Version

    deno 1.11.0 (release, x86_64-unknown-linux-gnu) v8 9.1.269.35 typescript 4.3.2

    bug 
    opened by somebody1234 10
  • Add new lint that bans `private` modifiers

    Add new lint that bans `private` modifiers

    TypeScript 4.3 supports private class fields with #, aligning with the ECMAScript proposal. The hash prefix (#) will work in both TypeScript and JavaScript, while private modifier doesn't once transpiled to JS - the private keyword is finally eliminated while being converted to JS. playground So basically we should prefer # to private for more strictness unless there is any particular reason. It would be great if deno_lint has a new lint rule to help migrate from private to #.

    One concern is that this new rule is kind of controversial if it's enabled by default. Perhaps we should implement it without turning on by default at first to see if it works well for the internals of Deno.

    opened by magurotuna 10
  • Feature Request: Maximum Cyclomatic Complexity

    Feature Request: Maximum Cyclomatic Complexity

    Summary

    In order to improve code readability and reduce the likelihood of (practically) untestable and/or unreachable conditions, it would be nice to enforce a maximum upper bound on the Cyclomatic Complexity of any given function

    From the equivalent ESLint rule:

    This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20)

    Details

    • Suggested rule name: complexity or cyclomatic-complexity
    • Suggested default value: 20 (same as ESLint)
    opened by wgehring-ml 0
  • prefer-primordials: add check for `Promise.all`

    prefer-primordials: add check for `Promise.all`

    https://github.com/denoland/deno/pull/16326

    This PR has introduced SafePromiseAll which is a safe version of Promise.all. It would be nice if prefer-primordials could check for this.

    Also, in my opinion, it would be much better if PromisePrototypeThen (and other similar stuff) could be checked by the linter. My rudimentary idea is that we have the linter check for all .then(...) and warn them. Obviously this approach would produce lots of false positives, i.e. the linter would warn the call .then(...) even if this then method is not for Promise. That said, I believe false positives are much better than false negatives in this case. When false positives occur we can suppress them, saying "hey linter, trust me, this is a false positive." However, when it comes to false negatives, we can never notice that there is problematic code that's prone to pollution from malicious users.

    opened by magurotuna 0
  • Lint for unversioned npm specifiers

    Lint for unversioned npm specifiers

    Doing something like import chalk from "npm:chalk" is nice for quick hacking, but shouldn't be used in real apps. I think maybe this lint might be best done in the cli though because it involves resolving import maps in some cases.

    suggestion 
    opened by dsherret 0
  • Feature Request: Syntax for ignore-directives should allow for an explanation

    Feature Request: Syntax for ignore-directives should allow for an explanation

    Summary

    When a programmer bypasses a configured linting rule, they should be able to document why they made an exception. This can improve code clarity, and should encourage future programmers only to ignore a rule when there's a clear reason for doing so.

    Syntax

    It could use a dash preceded by a space:

    // deno-lint-ignore no-explicit-any - We don't want to restrict the value's type
    type Dict = Record<string, any>;
    

    Two dashes might be clearer, and easier to distinguish from rules when parsing.

    // deno-lint-ignore no-explicit-any -- We don't want to restrict the value's type
    type Dict = Record<string, any>;
    
    opened by binyamin 1
  • Suggestion: syntactically deny direct `eval`

    Suggestion: syntactically deny direct `eval`

    Direct eval occurs when the global eval function is directly called as eval(...); that is reassigning it, obtaining it from the result of a larger expression such as a ternary operation, or used as a property (a.eval(s)), may not invoke direct eval. (I don't know whether ((eval)(s)) is direct eval.)

    See my comment here: https://github.com/denoland/deno/commit/2d3df94d6164b945e0184043b00078fe43229f7a

    Furthermore, see discussion here: https://github.com/denoland/deno_lint/pull/1063#issuecomment-1207337749

    Denying the expression eval(s) for Deno's internal code is all that should be necessary to prevent the bug, especially as it sounds quite unreasonable that it couldn't be renamed, or that eval would be assigned something other than the original eval.

    opened by Phosra 0
  • Rule suggestion: Require locks for remote imports

    Rule suggestion: Require locks for remote imports

    Deno already has support for integrity checking via lock files. It would be nice to be able to enforce that these are always used for remote imports that might have changed.

    opened by stabai 0
Releases(0.35.0)
A modular and blazing fast runtime security framework for the IoT, powered by eBPF.

Pulsar is a security tool for monitoring the activity of Linux devices at runtime, powered by eBPF. The Pulsar core modules use eBPF probes to collect

Exein.io 319 Jul 8, 2023
Command palette-style Git client for blazing-fast commits.

?? About Commit Commit is the world's simplest Git client. Open it with a keyboard shortcut, write your commit, and you're done! Commit will automatic

Miguel Piedrafita 190 Aug 18, 2023
Extremely fast JavaScript minifier, available for Rust and Node.js

minify-js Extremely fast JavaScript minifier, written in Rust. Goals Fully written in Rust for maximum compatibility with Rust programs and derivative

Wilson Lin 78 Jul 13, 2023
A bundler (mainly for TypeScript projects) made in Rust

TSAR A bundler (mainly for TypeScript projects) made in Rust. Also my first Rust Project! What does TSAR stand for Like phar (PHP Archive) or JAR (Jav

null 2 Mar 19, 2022
A library for generating TypeScript definitions from rust code.

Tsify is a library for generating TypeScript definitions from rust code. Using this with wasm-bindgen will automatically output the types to .d.

Madono Haru 60 Dec 30, 2022
An n-tuple pendulum simulator in Rust + WebAssembly (and JavaScript)

An n-tuple pendulum simulator in Rust + WebAssembly (and JavaScript) Remaking this n-tuple pendulum simulator moving the math to Rust ?? and WebAssemb

Travis Taylor 27 Feb 19, 2022
Adapter plugin to use Ruff in dprint's CLI and with JavaScript via Wasm

dprint-plugin-ruff Adapter for Ruff for use as a formatting plugin in dprint. Formats .py and .pyi files. Note: For formatting .ipynb files, use the J

null 3 Nov 28, 2023
🎓 My journey from JavaScript to Rust

Rusty Days My journey from JavaScript to Rust I'm a web3 dev looking for higher performance. Enticed that Rust was voted the most loved programming la

Dawson Botsford 19 Apr 17, 2022
Fast, compact and all-around subdomain enumeration tool written in Rust

Fast, compact and all-around subdomain enumeration tool written in Rust, which uses dns bruteforce, internet search and recursive http content search.

foreseon 16 Dec 10, 2022
Fast file explorer written with Tauri and React.

Fast File Explorer This is a fast file explorer written in Rust. After testing on my C drive, this file explorer was able to find a file in 280ms. In

Sam 455 Jul 4, 2023
A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

tmux-thumbs A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints. Usage Press ( prefix + Space

Ferran Basora 598 Jan 2, 2023
A fast, multi-threaded line counting utility written in Rust.

xloc A fast, multi-threaded line counting utility written in Rust. What is xloc A drop in replacement for bash's wc -l. Your project has x lines of co

null 1 Nov 15, 2021
Byte is a blazingly fast🚀 Discord Bot with a user-friendly design using twilight written in rust🦀.

Byte Byte is a blazingly fast?? Discord Bot with a user-friendly design using twilight written in rust??. How To Run There is a public version of the

TakoTheDev 3 Nov 15, 2023
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Jerel Unruh 70 Dec 13, 2022
⚡️ Fast MagicString port driven by Rust and N-API

magic-string-rs 100% API compatible (port) MagicString by Rich-Harris implementation for Node and modern browsers, also, for rust, of course. Installa

Hana 35 Nov 21, 2022
Czkawka is a simple, fast and easy to use app to remove unnecessary files from your computer.

Multi functional app to find duplicates, empty folders, similar images etc.

Rafał Mikrut 9.2k Jan 4, 2023
Fast, initializable, and thread safe static variables

tagged_cell Fast, initializable, and thread safe static variables Overview Borrows the excellent ZST based tagging implementation (linked below) to gu

David Schwarz 8 Nov 10, 2022
Simple and fast git helper functions

Simple and fast git helper functions

LongYinan 126 Dec 11, 2022