Open papigers opened 7 years ago
It seems like I missed a parser flag.
When using import
and export
statements, sourceType
has to be set to "module"
in Espree.
I have to check if setting that value brings unwanted side-effects, but until then, you could do the change manually to keep using the extension: (https://github.com/Hirse/brackets-outline-list/blob/master/src/lexers/JSParser.js#L140)
It solved the error for the first, simpler files, but it still seems to have a problem with the other one, or, for what I've seen, jsx files.
I didn't check your second example before. Is that one of the files still having problems?
Yes, as well as other jsx files (maybe all, but I didn't check).
ok, so I've came across this file in my project, with which the extension has no proble:
import React from 'react';
import { DivIcon } from 'leaflet';
import { Marker, Popup } from 'react-leaflet';
import { sensorType } from 'constants/propTypes';
import * as STATE from 'constants/sensorStates';
import { translate as healthTranslate } from 'constants/health';
import prettifyConstant from 'utils/prettifyConstant';
import s from './SensorMarker.css';
export default class SensorMarker extends React.Component {
render() {
const { sensor, hideSensor, resetSensor } = this.props;
return (
<Marker
key={sensor.sensorName}
position={[sensor.location.lat, sensor.location.lng]}
icon={new DivIcon({
iconSize: [30, 30],
className: `${s.marker} ${sensor.active ? s.active : ''} ${sensor.sensorState === STATE.RESET || sensor.sensorState === STATE.INIT ? s.loading : ''} ${sensor.mobile ? s.mobile : s.satellite} ${s[healthTranslate[sensor.health].toLowerCase()]}`,
})}
ref={(marker) => {
this.marker = marker;
}}
>
<Popup>
<div>
<div className={s.header}>
<h3>{sensor.sensorName}</h3>
</div>
<div className={s.stats}>
<div>
<h4>Location:</h4>
<span>{` ${sensor.location.lng} Lng, ${sensor.location.lat} Lat, ${sensor.location.alt} Alt`}</span>
</div>
<div>
<h4>State:</h4>
<span>{prettifyConstant(STATE.translate[sensor.sensorState])}</span>
</div>
<div>
<h4>Health:</h4>
<span>{prettifyConstant(healthTranslate[sensor.health])}</span>
</div>
<div>
<h4>Health Info:</h4>
<span>{sensor.healthInfo}</span>
</div>
<div>
<h4>Comm Quality:</h4>
<span>{sensor.commQuality}</span>
</div>
<div>
<h4>Signal Quality:</h4>
<span>{sensor.signalQuality}</span>
</div>
<div>
<h4>GPS Quality:</h4>
<span>{sensor.gpsQuality}</span>
</div>
</div>
<div className={s.buttons}>
<button onClick={() => hideSensor(sensor.sensorName)}>Hide</button>
{sensor.sensorState !== STATE.ACTIVE && sensor.sensorState !== STATE.NOT_AVAILABLE ?
<button
onClick={() => {
if (this.marker) {
this.marker.leafletElement.closePopup();
}
resetSensor(sensor.sensorName);
}}
>
Restart
</button>
: null
}
</div>
</div>
</Popup>
</Marker>
);
}
}
SensorMarker.propTypes = {
sensor: sensorType.isRequired,
hideSensor: React.PropTypes.func.isRequired,
resetSensor: React.PropTypes.func.isRequired,
};
import React from 'react';
import { DivIcon } from 'leaflet';
import { Marker, Popup } from 'react-leaflet';
import { sensorType } from 'constants/propTypes';
import * as STATE from 'constants/sensorStates';
import { translate as healthTranslate } from 'constants/health';
import prettifyConstant from 'utils/prettifyConstant';
import s from './SensorMarker.css';
export default class SensorMarker extends React.Component {
render() {
const { sensor, hideSensor, resetSensor } = this.props;
return (
<Marker
key={sensor.sensorName}
position={[sensor.location.lat, sensor.location.lng]}
icon={new DivIcon({
iconSize: [30, 30],
className: `${s.marker} ${sensor.active ? s.active : ''} ${sensor.sensorState === STATE.RESET || sensor.sensorState === STATE.INIT ? s.loading : ''} ${sensor.mobile ? s.mobile : s.satellite} ${s[healthTranslate[sensor.health].toLowerCase()]}`,
})}
ref={(marker) => {
this.marker = marker;
}}
>
<Popup>
<div>
<div className={s.header}>
<h3>{sensor.sensorName}</h3>
</div>
<div className={s.stats}>
<div>
<h4>Location:</h4>
<span>{` ${sensor.location.lng} Lng, ${sensor.location.lat} Lat, ${sensor.location.alt} Alt`}</span>
</div>
<div>
<h4>State:</h4>
<span>{prettifyConstant(STATE.translate[sensor.sensorState])}</span>
</div>
<div>
<h4>Health:</h4>
<span>{prettifyConstant(healthTranslate[sensor.health])}</span>
</div>
<div>
<h4>Health Info:</h4>
<span>{sensor.healthInfo}</span>
</div>
<div>
<h4>Comm Quality:</h4>
<span>{sensor.commQuality}</span>
</div>
<div>
<h4>Signal Quality:</h4>
<span>{sensor.signalQuality}</span>
</div>
<div>
<h4>GPS Quality:</h4>
<span>{sensor.gpsQuality}</span>
</div>
</div>
<div className={s.buttons}>
<button onClick={() => hideSensor(sensor.sensorName)}>Hide</button>
{sensor.sensorState !== STATE.ACTIVE && sensor.sensorState !== STATE.NOT_AVAILABLE ?
<button
onClick={() => {
if (this.marker) {
this.marker.leafletElement.closePopup();
}
resetSensor(sensor.sensorName);
}}
>
Restart
</button>
: null
}
</div>
</div>
</Popup>
</Marker>
);
}
}
SensorMarker.propTypes = {
sensor: sensorType.isRequired,
hideSensor: React.PropTypes.func.isRequired,
resetSensor: React.PropTypes.func.isRequired,
};
After some checks, it seems that the error comes from class properties. For example:
rulerEnd = () => {
this.props.endRuler();
}
Any idea how this can be supported as well?
The Espree parser this extension is using doesn't support class properties and probably isn't going to as the are not in the standard yet. I guess the only way to support it would be to change to a different parser.
Hi, I'm writing a react project written with JSX and ES6, and I've got this error on every file I open, even the plain javascript files (without JSX). The error is in the title of this issue.
Here are some files for example:
and a more complex file:
Both with the same error, as most of the other files. Any idea how to fix this?