Coder Social home page Coder Social logo

Comments (14)

armano2 avatar armano2 commented on May 10, 2024 15

@aserra54 you are missing plugin https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin

"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],

or atleast

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "rules": {
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "error"
  }
}

and you should move jsx to ecmaFeatures see https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#eslintrcjson

from typescript-eslint.

SevInf avatar SevInf commented on May 10, 2024 4

For me, this snippet still reports errors on 1.0.0-rc.3:

import { ExecutionResult } from 'graphql/execution/execute';
import { UnknownObject } from '../ts-utils';

export type RigelDispatch = <DataType extends UnknownObject>(
    action: Action<DataType>
) => Promise<ExecutionResult<DataType>>;
error  'UnknownObject' is defined but never used  typescript/no-unused-vars

from typescript-eslint.

milesj avatar milesj commented on May 10, 2024 2

Tested with the new @typescript-eslint packages. All of them are fixed except one -- when referencing an imported namespace. For example, i18next here.

import i18next from 'i18next';

export interface Translator extends i18next.i18n {}

Seems to trigger on both rules.

/Users/Miles/Sites/boost/packages/core/src/types.ts
  8:8  warning  'debug' is defined but never used    no-unused-vars
  8:8  error    'debug' is defined but never used    @typescript-eslint/no-unused-vars
  9:8  warning  'i18next' is defined but never used  no-unused-vars
  9:8  error    'i18next' is defined but never used  @typescript-eslint/no-unused-vars

from typescript-eslint.

armano2 avatar armano2 commented on May 10, 2024 2

You have to install and use eslint plugin React

from typescript-eslint.

bradzacher avatar bradzacher commented on May 10, 2024 1

Hi @milesj, could you please try upgrading to 1.0.0-rc.3 and see if that works for these cases?

Also just a tip, when linking to files in your repo, instead of linking to master, link to a commit. The commit link's content won't change, but the link to master will change when you push.

from typescript-eslint.

j-f1 avatar j-f1 commented on May 10, 2024 1

(you can hit y to switch to a permalink for the current file)

from typescript-eslint.

milesj avatar milesj commented on May 10, 2024 1

I'll try the 1.0.0 version. typescript-eslint-parser has also been updated/deprecate, so I'll try that also.

from typescript-eslint.

milesj avatar milesj commented on May 10, 2024 1

Trying 1.0.0-rc3 and parser 22.0.0. It crashes on 2 repos with the following error:

TypeError: Cannot read property 'length' of undefined
    at TSInterfaceDeclaration (/Users/Miles/Sites/boost/node_modules/eslint-plugin-typescript/lib/rules/no-empty-interface.js:33:48)
    at listeners.(anonymous function).forEach.listener (/Users/Miles/Sites/boost/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/Miles/Sites/boost/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/Miles/Sites/boost/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/Miles/Sites/boost/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/Miles/Sites/boost/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/Miles/Sites/boost/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
    at nodeQueue.forEach.traversalInfo (/Users/Miles/Sites/boost/node_modules/eslint/lib/linter.js:750:28)
    at Array.forEach (<anonymous>)

The line in no-empty-interfaces is the following, which is different than this repo. Seems like an AST/tree mismatch.

                const heritage = node.heritage.length;

                if (node.body.body.length === 0 && heritage < 2) {

Also noticed that the eslint-plugin-typescript has typescript-eslint-parser as a dependency, which it probably shouldn't? Or at minimum should be a peer. It also has a peer dependency on ~3.1.1, which will be annoying to maintain/consume, ^3.1.0 is much easier.

from typescript-eslint.

armano2 avatar armano2 commented on May 10, 2024

This is expected, there was a lot of changes in parser, and its not compatible with plugin, you have to wait for new release

from typescript-eslint.

armano2 avatar armano2 commented on May 10, 2024

Please read #73

from typescript-eslint.

milesj avatar milesj commented on May 10, 2024

Yup, assumed that was the problem. Will report back in a week.

from typescript-eslint.

aserra54 avatar aserra54 commented on May 10, 2024

Not sure if I should piggy-back off of this issue, but another false negative I'm seeing is in interface declarations, e.g.

import { Foo, Bar } from 'qux';

export class Baz implements Foo {
  public bar: Bar;
}

Both Foo and Bar get tagged as being unused. Sample here:

https://github.com/aserra54/typescript-eslint-parser-no-unused-vars

from typescript-eslint.

SimenB avatar SimenB commented on May 10, 2024

I'm getting false positives on React components.

// react.tsx
import * as React from 'react';
import { Heading2 } from 'some-place';

export const Comp: React.FunctionComponent = () => (
  <Heading2>Some content</Heading2>
);
/Users/simen/repos/monorepo/react.tsx
  2:10  warning  'Heading2' is defined but never used  @typescript-eslint/no-unused-vars

✖ 1 problem (0 errors, 1 warning)

config:

{
  "extends": ["plugin:@typescript-eslint/recommended"],
  "plugins": ["@typescript-eslint"]
}

(this creates a couple of more errors for rules I've turned off)

from typescript-eslint.

SimenB avatar SimenB commented on May 10, 2024

Ah! Fair enough 🙂 I've forgotten all about that plugin, gonna be awesome to be able to use it again 😅

from typescript-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.