Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

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

Closed
LucaPeng opened this issue Oct 31, 2018 · 1 comment · Fixed by #540
Closed

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

LucaPeng opened this issue Oct 31, 2018 · 1 comment · Fixed by #540
Labels

Comments

@LucaPeng
Copy link

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
Copy link

Primajin commented Nov 12, 2018

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

mysticatea added a commit that referenced this issue Nov 13, 2018
* Update: add proper scope analysis (fixes #535)

* add computed-properties-in-type fixture

* add computed-properties-in-interface fixture

* add function-overload fixture

* add method-overload fixture

* add class-properties fixture

* add decorators fixture

* update visitor-keys

* add declare-global fixture

* fix typo

* add test for typeof in array destructuring

* add namespace fixture

* add declare-module fixture

* fix crash

* add declare-function.ts fixture

* add abstract-class fixture

* add typeof-in-call-signature fixture

* add test for #416

* add test for #435

* add test for #437

* add test for #443

* add test for #459

* add test for #466

* add test for #471

* add test for #487

* add test for #535

* add test for #536

* add test for #476

* fix test to use `expect()`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants