Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint no-unused-var for generated JS and TS types #573

Open
peterpeterparker opened this issue Sep 10, 2024 · 0 comments
Open

eslint no-unused-var for generated JS and TS types #573

peterpeterparker opened this issue Sep 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@peterpeterparker
Copy link
Member

Is your feature request related to a problem? Please describe.

Given that most JS and TS projects use ESLint for code validation, I suggest adding two exceptions (// eslint-disable-next-line @typescript-eslint/no-unused-vars) to the generated types by default; otherwise, they may cause developers' linters to fail.

JS:

export const idlFactory = ({ IDL }) => {
  const Hello = IDL.Record({ 'world' : IDL.Text });
  return IDL.Service({
    'yolo' : IDL.Func([Hello], [IDL.Text], ['query']),
  });
};
export const init = ({ IDL }) => { return []; }; // ---> ESLint: 'IDL' is defined but never used.(@typescript-eslint/no-unused-vars)

TS:

import type { Principal } from '@dfinity/principal'; // ---> ESLint: 'Principal' is defined but never used.(@typescript-eslint/no-unused-vars)
import type { ActorMethod } from '@dfinity/agent';
import type { IDL } from '@dfinity/candid';

export interface Hello { 'world' : string }
export interface _SERVICE {
  'yolo' : ActorMethod<[Hello], string>,
}
export declare const idlFactory: IDL.InterfaceFactory;
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@peterpeterparker peterpeterparker added the enhancement New feature or request label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant