eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
`prefer-spread` flagging `Array#concat(…)` for non-iterable objects
After upgrading to 27.0.0
, I'm finding that the prefer-spread
rule is raising ERROR_ARRAY_CONCAT
errors when a concat
method exists on non-iterable objects.
Specifically, this I've witnessed this occurring when chaining an ApolloLink for the ApolloClient. The ApolloLink object defines a static concat
method.
const client = new ApolloClient({
link: authLink.concat(httpLink), //<-- Raises `Array#concat(…)` error
cache: new InMemoryCache({}),
});
In this case, authLink is of type ApolloLink, which has the following type definition:
export declare class ApolloLink {
static empty(): ApolloLink;
static from(links: (ApolloLink | RequestHandler)[]): ApolloLink;
static split(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | RequestHandler): ApolloLink;
static execute(link: ApolloLink, operation: GraphQLRequest): Observable<FetchResult>;
static concat(first: ApolloLink | RequestHandler, second: ApolloLink | RequestHandler): ApolloLink;
constructor(request?: RequestHandler);
split(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | RequestHandler): ApolloLink;
concat(next: ApolloLink | RequestHandler): ApolloLink;
request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
protected onError(error: any, observer?: ZenObservable.Observer<FetchResult>): false | void;
setOnError(fn: ApolloLink["onError"]): this;
}