GithubHelp home page GithubHelp logo

no-unused-vars for jsx about babel-eslint HOT 11 CLOSED

babel avatar babel commented on August 11, 2024
no-unused-vars for jsx

from babel-eslint.

Comments (11)

frankychung avatar frankychung commented on August 11, 2024 15

I also had issues with this after eslint 0.17. It seems we should install eslint-plugin-react as explained in eslint/eslint#2147.
With the following:

$ npm -g ls eslint eslint-plugin-react babel-eslint
/usr/local/lib
├── [email protected]
├── [email protected]
└── [email protected]

And adding the following to my .eslintrc

{
  ...
  "plugins": [
    "react"
  ],
  ...
  "rules": {
    ...
    "react/jsx-uses-vars": 1
  }
}

I no longer get the false warning

from babel-eslint.

garthk avatar garthk commented on August 11, 2024 5

Working .eslintrc from the subdirectory containing my JSX:

{
  "rules": {
    "no-extra-parens": 0,
    "react/jsx-uses-vars": 1
  },
  "ecmaFeatures": {
    "jsx": true,
  },
  "env": {
    "node": false,
    "browser": true,
    "es6": true,
  },
  "parser": "babel-eslint",
  "plugins": [
      "eslint-plugin-react"
  ]
}

@sebmck, if you keep getting hassled about JSX e.g. #74, might be worth including some extra notes in the README.

from babel-eslint.

gaearon avatar gaearon commented on August 11, 2024

+1, I also have this.

from babel-eslint.

sebmck avatar sebmck commented on August 11, 2024

Most of these are easy fixes my laptop shit itself so I won't be able to
fix these for a couple of hours while I get a charger...

On Saturday, 28 February 2015, Dan Abramov [email protected] wrote:

+1, I also have this.

Reply to this email directly or view it on GitHub
#5 (comment).

Sebastian McKenzie

from babel-eslint.

sebmck avatar sebmck commented on August 11, 2024

Fixed as of 1.0.8, thanks!

from babel-eslint.

esnunes avatar esnunes commented on August 11, 2024

sorry but version 1.0.8 of what package? I'm using eslint version 0.17.1 and babel-eslint 2.0.2, I'm facing the same problem. My .eslintrc file looks like this:

{
  "parser": "babel-eslint",

  "env": {
    "browser": true,
    "node": true,
  },

  "rules": {
    "quotes": [2, "single", "avoid-escape"],
    "comma-dangle": [2, "always-multiline"],
    "strict": [2, "never"],
    "new-cap": [2, { "capIsNewExceptions": ["Router", "Schema"] }],
    "camelcase": [0],
    "consistent-return": [0]
  }
}

from babel-eslint.

cesarandreu avatar cesarandreu commented on August 11, 2024

I think I'm having this problem as well.

.eslintrc

{
  "parser": "babel-eslint",
  "rules": {
    "strict": false,
    "no-console": false,
    "no-multiple-empty-lines": false
  },
  "env": {
    "mocha": true,
    "browser": true,
    "node": true
  }
}

problem-example.jsx

var Foo = require('./Foo.jsx')
module.exports = <Foo></Foo>

Sublime Text console

SublimeLinter: eslint output:
<text>: line 1, col 4, Error - Foo is defined but never used (no-unused-vars)
<text>: line 2, col 18, Error - 'Foo' is not defined. (no-undef)

terminal

$ npm ls -g babel-eslint eslint
/Users/cesarandreu/.nvm/versions/io.js/v1.6.1/lib
├── [email protected]
└── [email protected]

As part of the Sublime Text console output it also shows it's using the correct eslint binary.

from babel-eslint.

justin808 avatar justin808 commented on August 11, 2024

I've got a similar config and I'm seeing the issue of all the JSX used vars show as not used.

Main difference is [email protected].

➜  ~/github/react-starter-kit (master u=) npm -g ls eslint eslint-plugin-react babel-eslint
/usr/local/lib
├── [email protected]
├── [email protected]
├── [email protected]
└─┬ [email protected] (git://github.com/feross/standard#4a2d51eb527bec1a987af9dae57ec8d1d61decaa)
  ├── [email protected]  (git://github.com/eslint/eslint.git#06927eeacba776c29a40bc0a191f9d9fc9575ba6)
  └── [email protected]

from babel-eslint.

leongaban avatar leongaban commented on August 11, 2024

Hi all, I'm still getting this error, would anyone mind a look here? https://stackoverflow.com/questions/45085584/how-to-remove-eslint-parsing-error-on-es6-export-statement?noredirect=1#comment77144342_45085584

npm v3.10.10 node v6.11.0 eslint v4.2.0

from babel-eslint.

leongaban avatar leongaban commented on August 11, 2024

A figured it out, it was the last comment here : #6

from babel-eslint.

hzoo avatar hzoo commented on August 11, 2024

https://github.com/babel/babel-eslint#known-issues

from babel-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.