Can I setup the linter that's used inside the editor?

I’m testing Glitch with a project using React Native for Web.

I’m used to ESnext that we have for React Native by default and I was able to setup a Babel config, so a code like this compiles and works: :tada:

class Button extends React.PureComponent {

  onPress = () => { /* smth */ };
  
  render() { /* smth else */ }
 
}

but the linter in the editor :policeman:doesn’t like the line onPress = () => { /* smth */ };

I have .eslintrc file in the root dir. And I’ve tried adding eslint section to package.json :crossed_fingers:, but it didn’t help.

Can I setup the linter somehow? :thinking:

The code is here: https://glitch.com/edit/#!/calculator-with-react-native-web

The error:

1 Like

I’ve sent you a DM with a possible solution.

1 Like

Could you send me the solution as well? Thank you

Amanda

1 Like

Could I get that as well? Is there a way to turn off certain classes or instances of lint warnings? Thanks!

1 Like

I misunderstood the cause, so my possible solution didn’t end up helping sadly.

2 Likes

Having the same issue, My app compiles and runs correctly but linter doesn’t like the code

image

1 Like

Just adding my +1 and following in case a solution comes along! I’ve got a super simple React ES7 boilerplate going, builds fine but the editor error is an eyesore :see_no_evil:

1 Like

A solution came along :slight_smile: You can now change the default linting rules in a project by adding a .eslintrc.json file to the project (docs here: https://eslint.org/docs/user-guide/configuring)

5 Likes

Is this possible to set up for “basic” (glitch-hello-website) projects? When I add a .eslintrc.json to a basic project the editor no longer provides syntax/etc checking.

2 Likes

Yes, I’m having that problem. The bullet in the gutter was nice, but I tried to install babel/eslint and I’ve lost the bullet for syntax errors now. I seem to get the bullets for .json files but not for nodejs files. Any help would be great.

Peter

Hi there, could you share a bit more detail on what you’ve added to your project, ideally with a screengrab or a link to it so that we can check it out?

These dependencies are in package.json

“dependencies”: {
@babel/core”: “^7.20.5”,
@babel/eslint-parser”: “^7.19.1”,
@codemirror/lint”: “^6.1.0”,

I have this as my .eslintrc.json file

{
“parser”: “@babel/eslint”,
“env”: {
“browser”: true,
“node”: true
}

Yes, I’m very new to all this although I’ve been developing apps since at least the Dark Ages. I’m coming from an old Visual Studio background so I’m trying to replicate some of the stuff I found helpful. I have tried to find answers here and using a search engine to no avail.

Thanks

Peter

Ah ok thanks for sharing, I don’t believe we support actually setting the parser itself in the eslint config, although you can configure specific rules. We hope to provide more support for linting config at some point in future though!

Ah, ok. Then what did I do to break the bullet in the gutter on the editor? I’d be satisfied with getting my bullets back (and yes, there are usually a BUNCH of bullets when I’m coding).

(Surprised you are active so early in the morning although I guess you may be geographically located somewhere the sun is up already).

Peter

Hopefully if you remove the eslint config file and run refresh in your project terminal that’ll restore it!

Ok, I did as suggested and removed the .eslintrc.json file. Now my parsing errors are being shown. I see that @Gareth posted a link to the configuration documentation. What I am trying to enable is the experimental class syntax via those configuration parameters. My code runs just fine (experimental features or not) but the parser indicates an error. I further get that Glitch doesn’t support the new experimental features yet but this post dates back over four years and I hoped (expected?) that in those four years Glitch might have found some time for supporting newer features as they come along, or at least after a “cooling off period” to allow for newer stuff to be “fixed”.

Thanks for your attention.

Peter