Skip to content

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

@peterpeterparker

Description

@peterpeterparker

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[];

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions