openzim / node-libzim

Libzim binding for Node.js: read/write ZIM files in Javascript
https://www.npmjs.com/package/@openzim/libzim
GNU General Public License v3.0
27 stars 11 forks source link

TSlint to ESlint #102

Closed Rishabhg71 closed 1 year ago

Rishabhg71 commented 1 year ago

closes #89 I have added an eslint and eslintignore but there are some things with which I am not sure how to proceed with After adding an eslint file I am giving a lot of linting errors

/home/rg/Desktop/projects/node-libzim/bundle-libzim.js
   1:1  error  Definition for rule 'jsdoc/newline-after-description' was not found  jsdoc/newline-after-description
   7:1  error  Unsafe member access .sync on an `any` value                         @typescript-eslint/no-unsafe-member-access
   7:1  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  18:5  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  19:5  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  23:5  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  24:5  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  26:5  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
/home/rg/Desktop/projects/node-libzim/dev/hackPackageVersion.js
  1:1   error  Definition for rule 'jsdoc/newline-after-description' was not found                                       jsdoc/newline-after-description
  3:7   error  Unsafe assignment of an `any` value                                                                       @typescript-eslint/no-unsafe-assignment
  4:1   error  Unsafe member access .version on an `any` value                                                           @typescript-eslint/no-unsafe-member-access
  4:15  error  Operands of '+' operation must either be both strings or both numbers. Consider using a template literal  @typescript-eslint/restrict-plus-operands
  4:15  error  Operands of '+' operation with any is possible only with string, number, bigint or any                    @typescript-eslint/restrict-plus-operands
  4:15  error  Unsafe member access .version on an `any` value                                                           @typescript-eslint/no-unsafe-member-access
/home/rg/Desktop/projects/node-libzim/download-libzim.js
   1:1   error  Definition for rule 'jsdoc/newline-after-description' was not found  jsdoc/newline-after-description
   3:7   error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
   4:7   error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
   9:1   error  Unsafe member access .sync on an `any` value                         @typescript-eslint/no-unsafe-member-access
   9:1   error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  14:54  error  Expected '===' and instead saw '=='                                  eqeqeq
  14:74  error  Expected '===' and instead saw '=='                                  eqeqeq
  26:13  error  Expected '!==' and instead saw '!='                                  eqeqeq
  28:26  error  Expected '===' and instead saw '=='                                  eqeqeq
  47:19  error  Empty block statement                                                no-empty
  49:5   error  Unsafe member access .catch on an `any` value                        @typescript-eslint/no-unsafe-member-access
  49:5   error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  49:5   error  Unsafe member access .then on an `any` value                         @typescript-eslint/no-unsafe-member-access
  49:5   error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  49:5   error  Unsafe member access .then on an `any` value                         @typescript-eslint/no-unsafe-member-access
  49:5   error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  49:5   error  Unsafe member access .then on an `any` value                         @typescript-eslint/no-unsafe-member-access
  49:5   error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  57:17  error  Unsafe member access .on on an `any` value                           @typescript-eslint/no-unsafe-member-access
  57:17  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  57:17  error  Unsafe member access .on on an `any` value                           @typescript-eslint/no-unsafe-member-access
  57:17  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  57:17  error  Unsafe member access .data on an `any` value                         @typescript-eslint/no-unsafe-member-access
  57:17  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
  66:13  error  Unsafe return of an `any` typed value                                @typescript-eslint/no-unsafe-return
  66:20  error  Unsafe call of an `any` typed value                                  @typescript-eslint/no-unsafe-call
/home/rg/Desktop/projects/node-libzim/src/index.d.ts
  1:1  error  Definition for rule 'jsdoc/newline-after-description' was not found  jsdoc/newline-after-description
/home/rg/Desktop/projects/node-libzim/src/index.js
   1:1  error  Definition for rule 'jsdoc/newline-after-description' was not found  jsdoc/newline-after-description
   4:7  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  21:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  22:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  23:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  24:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  25:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  26:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  27:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  28:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  29:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  30:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  31:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  32:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
  33:3  error  Unsafe assignment of an `any` value                                  @typescript-eslint/no-unsafe-assignment
/home/rg/Desktop/projects/node-libzim/test/makeLargeZim.ts
   1:1   error    Definition for rule 'jsdoc/newline-after-description' was not found                                                                                                 jsdoc/newline-after-description
   3:10  warning  'faker' is defined but never used                                                                                                                                   @typescript-eslint/no-unused-vars
   4:40  warning  'Blob' is defined but never used                                                                                                                                    @typescript-eslint/no-unused-vars
   5:7   error    Unsafe assignment of an `any` value                                                                                                                                 @typescript-eslint/no-unsafe-assignment
   5:19  error    Require statement not part of import statement                                                                                                                      @typescript-eslint/no-var-requires
  14:1   error    Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises
  30:18  error    Unsafe call of an `any` typed value                                                                                                                                 @typescript-eslint/no-unsafe-call
  33:27  error    Invalid type "any" of template literal expression                                                                                                                   @typescript-eslint/restrict-template-expressions
  36:33  error    Invalid type "any" of template literal expression                                                                                                                   @typescript-eslint/restrict-template-expressions
  68:5   error    Unexpected `await` of a non-Promise (non-"Thenable") value                                                                                                          @typescript-eslint/await-thenable
/home/rg/Desktop/projects/node-libzim/test/zim.test.ts
    1:1   error    Definition for rule 'jsdoc/newline-after-description' was not found  jsdoc/newline-after-description
    3:8   warning  'path' is defined but never used                                     @typescript-eslint/no-unused-vars
    5:10  warning  'faker' is defined but never used                                    @typescript-eslint/no-unused-vars
   12:3   warning  'FileItem' is defined but never used                                 @typescript-eslint/no-unused-vars
   14:3   warning  'FileProvider' is defined but never used                             @typescript-eslint/no-unused-vars
  138:7   error    Unexpected `await` of a non-Promise (non-"Thenable") value           @typescript-eslint/await-thenable
  236:7   error    Unexpected `await` of a non-Promise (non-"Thenable") value           @typescript-eslint/await-thenable
  241:38  error    Expected '===' and instead saw '=='                                  eqeqeq
  325:12  error    Unsafe member access .title on an `any` value                        @typescript-eslint/no-unsafe-member-access
:heavy_multiplication_x: 75 problems (69 errors, 6 warnings)

To resolve some of the errors either I convert these files to .TS or ignore these options in.JS files like Unsafe call of an "any" typed value only way is convert to TS or JS (ignore)

FledgeXu commented 1 year ago

You should write .eslintrc.json by hand instead of using tslint-to-eslint-config. For some reason, tslint-to-eslint-config recognizes this project as a Typescript project. And using prettier is a good idea, IMO.

Rishabhg71 commented 1 year ago

Yup prettier seems good but isn't this project in typescript? Only few files are in js

FledgeXu commented 1 year ago

@RG7279805 I don't know😂. There are 3 typescript files and 4 javascript files, so I guess it's a javascript project? And two of typescript files are in the test and eslint will ignore them by default.

Rishabhg71 commented 1 year ago

@kelson42 Sorry i was busy with some other things nonetheless you can do a review now and let me know if i messed up something

kelson42 commented 1 year ago

@RG7279805 Thank you @FledgeXu You seem competenter than I'm. Does it looks good to you?

kelson42 commented 1 year ago

@RG7279805 https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review ? Can you please reply in the discussions?

Rishabhg71 commented 1 year ago

My bad @kelson42, I thought I did comment after making changes Thank you for the "pull request review" link i may have to learn more about GitHub