Comments (20)
I'm getting that error for all classes
from babel-eslint.
specifically classes are "defined but never used" warning is coming up
from babel-eslint.
+1 Got the same errors regarding "defined but never used"
from babel-eslint.
Also having this problem. I have a module that exports a class (export default class SomeClass
) and a utility module that individually exports named functions (export function someHelper...
). It doesn't like either one.
from babel-eslint.
This seems to dupe #8.
from babel-eslint.
Can you please verify that this issue still exists on 3.0.1?
from babel-eslint.
I'm still seeing this with babel-eslint
@3.0.1.
However, when using eslint-plugin-react
with babel-eslint
, I don't have these issues any longer.
from babel-eslint.
Confirmed still seeing this issue with [email protected]
and [email protected]
.
from babel-eslint.
I am also seeing this issue with [email protected]
and [email protected]
. Looks like this also came up before with eslint but was fixed there: eslint/eslint#1534
from babel-eslint.
Similar to @cemckinley, I'm seeing this with [email protected]
and [email protected]
.
'use strict';
import React from 'react';
import Router from 'react-router';
import CreateSpace from 'apps/CreateSpace';
import MySpaces from 'apps/MySpaces';
import SpaceDirectory from 'apps/SpaceDirectory';
const { Route, NotFoundRoute, DefaultRoute, Link, RouteHandler } = Router;
if (__DEV__) {
require('../scss/dev.scss');
}
const App = React.createClass({
render() {
return (
<RouteHandler />
);
}
});
const NotFound = React.createClass({
render() {
const divstyle = {
textAlign: 'center',
paddingTop: '35px'
};
const imgstyle = {
width: '25%'
};
return (
<div style={divstyle}>
<img style={imgstyle} src="/images/sadpanda.svg" alt="The panda is sad because it couldn't find the page you wanted" />
<h2>Page Not Found</h2>
<p>Oops, we couldn't find that page.</p>
</div>
);
}
});
const route_base_path = __DEV__ ? '/' : '/canvasspaces';
const routes = (
<Route name="app" path={route_base_path} handler={App}>
<Route name="create_space" handler={CreateSpace} />
<Route name="my_spaces" handler={MySpaces} />
<Route name="space_directory" handler={SpaceDirectory} />
<DefaultRoute handler={MySpaces} />
<NotFoundRoute handler={NotFound}/>
</Route>
);
Router.run(routes, Router.HistoryLocation, (Handler) => {
React.render(<Handler/>, document.getElementById('CanvasSpacesApp'));
});
export default App;
9:8 error Route is defined but never used no-unused-vars
9:15 error NotFoundRoute is defined but never used no-unused-vars
9:30 error DefaultRoute is defined but never used no-unused-vars
9:44 error Link is defined but never used no-unused-vars
9:50 error RouteHandler is defined but never used no-unused-vars
55:44 error Handler is defined but never used no-unused-vars
✖ 6 problems (6 errors, 0 warnings)
My .eslintrc
file:
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"globals": {
"__DEV__": true
},
"rules": {
"quotes": [2, "single"],
"eol-last": [1],
"no-mixed-requires": [0],
"no-underscore-dangle": [0],
"camelcase": [0]
}
}
from babel-eslint.
However, when using eslint-plugin-react with babel-eslint, I don't have these issues any longer.
eh? is that a solution? I stopped noticing the errors when I included the react-plugin, but haven't worked on anything this week.
from babel-eslint.
Yup, it's the solution. Use the eslint-plugin-react rules if you're using JSX. It can't really be fixed on the babel-eslint
side.
from babel-eslint.
It seems the eslint react plugin fixes this error, but it exists outside of react projects.
Something as simple as
class Item {
constructor() {
this.id = 0;
}
}
Will produce this error, it doesn't have to extend a React component. Pulling in the eslint react plugin to solve the issue when I'm not using react seems like a lazy work around.
from babel-eslint.
Can you reproduce with the regular parser, maybe an eslint issue. But, if you export the class it should be fixed.
from babel-eslint.
I'm running into this issue with a regular ES6 class.
from babel-eslint.
Yes, me too. I am using the class only in the ReactDOM.render() method. I wonder if this bug was reintroduced in the last upgrade. For the time being I had to disable the "no-unused-vars" rule.
from babel-eslint.
Can one of you please open a new bug with an example and the according eslintrc file. Thanks.
from babel-eslint.
Hi, sorry for not answering before, I will do it :)
from babel-eslint.
I investigated the bug and it seems to be an eslint issue. I still have the same problem if I use:
parserOptions: { "ecmaVersion": 6, "sourceType": "module", "ecmaFeatures": { "jsx": true } },
instead of:
parser: 'babel-eslint',
from babel-eslint.
In case it can help someone, my issue was resolved here: eslint/eslint#6303
from babel-eslint.
Related Issues (20)
- Latest Babel + flow generates "is not defined" errors on star imports HOT 3
- npm WARN [email protected] requires a peer of @babel/core@>=7.2.0 but none is installed HOT 3
- Disabling eslint on file does not work HOT 2
- Using decorator syntax doesn't pass eslint HOT 7
- There are no release notes for 10.1.0 HOT 2
- Imports from sibling directory not parsed using babel config HOT 2
- 11.0.0-beta.2 - Private method is not defined. (eslintno-undef) HOT 7
- eslint returns with parsing error unexpected token HOT 4
- How to use babel-eslint in a non-node JS environment (such as client environment, browser) HOT 6
- Breaking change in Node 13.13 HOT 2
- Typescript: parsing error when using "readonly" in interface HOT 2
- Expected indentation is forced for comments as well HOT 1
- Question: `11.0.0-beta2` Not installing all babel plugins (top level await) HOT 1
- no-unused-vars false positive with typescript types HOT 2
- Feature idea: have a way for eslint-plugin-prettier to share an AST with eslint HOT 4
- Missing 'ImportExpression' in visitorKeys HOT 4
- `RegExpLiteral` is not converted to `Literal` in an edge case HOT 2
- Template-literal rule attempting to run on nullish coalescing operations, and then crashing eslint HOT 1
- Error on 'extends' operator on generic type HOT 1
- works for me HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-eslint.