eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 92 forks source link

False positive for unused vars used as decorators of properties #536

Closed LucaPeng closed 5 years ago

LucaPeng commented 5 years ago

What version of TypeScript are you using? 3.1.4

What version of typescript-eslint-parser are you using? 20.1.0

What code were you trying to parse?

import {
  action,
  observable,
  useStrict,
  runInAction,
  IObservableArray,
} from 'mobx';
import orderReadService from '@client/model/purchase/orderReadService';
import {
  BizPurchaseOrderTO,
  PageTO,
  BizQueryOrderConditionTO,
} from '@client/types/thrift/purchase';
import { PURCHASE_ORDER_TYPE_ENUM } from '@constants/order';

useStrict(true);
export default class ListModalStore {
  // order list
  @observable
  orderList: IObservableArray<BizPurchaseOrderTO> = observable([]);
  @observable
  orderListPageInfo: PageTO = { currentPage: 1, perPage: 10, total: '5' };
}

What did you expect to happen?

no eslint error for the 'observable' which is imported from mobx.

What happened?

[eslint] 'observable' is defined but never used.

This is happened for the 'observable' which is imported from mobx.

Primajin commented 5 years ago

It's not only decorators. I'm having the problem, that since 20.1.0 (including 20.1.1) all my proptypes in react are considered unused.

import { bool, number, string } from 'prop-types';
...
class MyClass extends PureComponent<Props, StateAttributes> {
  public static propTypes = {
    height: number.isRequired,
    leftIcon: bool,
    text: string,
    value: string.isRequired
  };
...

all the above are considered unused in > 20.1+ while fine in <= 20.0