Why doesn't my ESLint profile work with React Native?


Sonny

Using VSCode, I created a React Native app using expo-cli. I want to use ESLint and Prettier to improve code quality.
I want ESLint in the "Problems" tab to print out errors, for example if I have this line var asd = 1;in App.js , ESLint will print out Unexpected var, use let or const instead.
the settings I have an ESLint config file, I coded the error on purpose to test if ESLint is working , but I don't see any errors.
ESLint for VSCode has been installed with version 1.9.1 and the structure of my project is included in the link .

Here is my App.js code that would like to generate errors in 2 places:

import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
    </View>
  );
}

var asd = 1; // this should show error

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

const zzz = StyleSheet.create({
  // this should show error based on react-native/no-unused-styles rule in eslint config
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

Here is my .eslintrc.json file:

{
  "extends": [
    "airbnb",
    "prettier",
    "plugin:node/recommended",
    "plugin:react/recommended"
  ],
  "plugins": ["prettier", "react", "react-native"],
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "react-native/react-native": true
  },
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "prettier/prettier": "warn",
    "no-unused-vars": "warn",
    "no-console": "off",
    "func-names": "off",
    "no-process-exit": "off",
    "no-alert": "warn",
    "object-shorthand": "off",
    "class-methods-use-this": "off",
    "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
    "react-native/no-unused-styles": "error"
  },
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [".js", ".ios.js", ".android.js"]
      }
    }
  }
}
Sonny

I parserOptionswasn't detailed enough in the config file. I need to update it like this:

"parserOptions": {
  "ecmaVersion": 6,
  "sourceType": "module",
  "ecmaFeatures": {
      "jsx": true
  }
},

This is an idiot question. Sorry to bother anyone.

Related


Why doesn't my ESLint profile work with React Native?

Sonny Using VSCode, I created a React Native app using expo-cli. I want to use ESLint and Prettier to improve code quality. I want ESLint in the "Problems" tab to print out the error, for example if I have this line var asd = 1;in App.js then ESLint will print

Why doesn't my ESLint profile work with React Native?

Sonny Using VSCode, I created a React Native app using expo-cli. I want to use ESLint and Prettier to improve code quality. I want ESLint in the "Problems" tab to print out the error, for example if I have this line var asd = 1;in App.js then ESLint will print

Why doesn't my ESLint profile work with React Native?

Sonny Using VSCode, I created a React Native app using expo-cli. I want to use ESLint and Prettier to improve code quality. I want ESLint in the "Problems" tab to print out errors, for example if I have this line var asd = 1;in App.js , ESLint will print out U

Why doesn't my ESLint profile work with React Native?

Sonny Using VSCode, I created a React Native app using expo-cli. I want to use ESLint and Prettier to improve code quality. I want ESLint in the "Problems" tab to print out errors, for example if I have this line var asd = 1;in App.js , ESLint will print out U

Why doesn't my href link to my Facebook profile work?

Chloe Hammond I've built a portfolio site and the href link to Facebook is the only social media link that doesn't work. Like other social media links it doesn't seem to work after copying and pasting my profile link. I also had this problem on another website

Why doesn't my href link to my Facebook profile work?

Chloe Hammond I've built a portfolio site and the href link to Facebook is the only social media link that doesn't work. Like other social media links it doesn't seem to work after copying and pasting my profile link. I also had this problem on another website

Why import doesn't work in react native?

weird random I'm trying to import the second file into the project's App.js. I get the error "The development server returned a response error code: 500". Basically saying "Cannot resolve 'MainFile' from 'App.js'. Why is this so? I believe it's correct, but fo

Why import doesn't work in react native?

weird random I'm trying to import the second file into the project's App.js. I get the error "The development server returned a response error code: 500". Basically saying "Cannot resolve 'MainFile' from 'App.js'. Why is this so? I believe it's correct, but fo

Why doesn't my ~/.bash_profile work?

Antonio K I am using Linux Mint. My login shell ( cat /etc/passwd | grep myUserName) is bash. After starting the graphical desktop environment and running a terminal emulator from it, I can see that it .bash_profile's not source (the environment variable set i

Why doesn't my ~/.bash_profile work?

Antonio K I am using Linux Mint. My login shell ( cat /etc/passwd | grep myUserName) is bash. After starting the graphical desktop environment and running a terminal emulator from it, I can see that it .bash_profile's not source (the environment variable set i

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

this.setState doesn't work in my React native project

User 5553868 In a React Native app I'm developing, this.setState doesn't work and doesn't update the value in the constructor. But this.state({}) is working. but when i use it it is resetting the constructor anyone please point out what is wrong with this code

this.setState doesn't work in my React native project

User 5553868 In a React Native app I'm developing, this.setState doesn't work and doesn't update the value in the constructor. But this.state({}) is working. but when i use it it is resetting the constructor anyone please point out what is wrong with this code

Routing doesn't work on load on my react native app

username I'm working on a React native project with a login system using Firebase. The login system works normally. I also managed to capture the current user id from Firebase. I tried setting "stay logged in" with the asyncStorage system and current user id.

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

Routing doesn't work on load on my react native app

username I'm working on a React native project with a login system using Firebase. The login system works normally. I also managed to capture the current user id from Firebase. I tried setting "stay logged in" with the asyncStorage system and current user id.

Why doesn't adding the path to ".profile" work?

Edwin I am using Lubuntu 12.04. I'm having trouble setting a path variable for my application. I'm trying to set a path variable in a .profile file, but after I add the path when I echo $PATH, it doesn't show my addition. This is the line I add at the end of .

Why doesn't adding the path to ".profile" work?

Edwin I am using Lubuntu 12.04. I'm having trouble setting a path variable for my application. I'm trying to set a path variable in a .profile file, but after I add the path when I echo $PATH, it doesn't show my addition. This is the line I add at the end of .

Why command to clean doesn't work in Gradle React native project?

sujata shinde: I'm trying to clean the Gradle files after cd .\androidbut it's not working. See the commands below. D:\ReactNativeVS\demo\android>./gradlew clean I get the following error: '. ' is not recognized as an internal or external command, operable pr