A
A
AltaiR2020-08-24 16:38:01
JavaScript
AltaiR, 2020-08-24 16:38:01

How to properly configure ESLint for CRA?

Hello. I'm trying to properly connect eslint-config-airbnb to a react app created with Create React App . Following the instructions , I created a .env file and added EXTEND_ESLINT=true. Next, I created a .eslintrc.json file and added there:

{
  "env": {
    "browser": true,
    "es6": true
  },
  "extends": [
    "react-app",
    "airbnb",
    "plugin:jsx-a11y/recommended",
    "prettier",
    "prettier/react"
  ],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "plugins": ["react", "jsx-a11y", "prettier"],
  "rules": {
    "prettier/prettier": "error",
    "no-unused-vars": "warn",
    "react/jsx-filename-extension": [
      "warn",
      {
        "extensions": [".js"]
      }
    ],
    "no-console": [
      "warn",
      {
        "allow": ["warn", "error", "info"]
      }
    ],
    "no-shadow": "off",
    "react/state-in-constructor": [2, "never"],
    "max-len": [
      "warn",
      {
        "code": 100,
        "tabWidth": 2,
        "comments": 100,
        "ignoreComments": false,
        "ignoreTrailingComments": true,
        "ignoreUrls": true,
        "ignoreStrings": true,
        "ignoreTemplateLiterals": true,
        "ignoreRegExpLiterals": true
      }
    ]
  }
}


And in .stylelintrc.json:
{
  "singleQuote": true
}


Everything seems to be working great. But when I create new folders / files in projects and import them into components, the following error occurs: 5f43c219768d7383823043.png

Only deleting the node_modules folder and the command npm install. And I also noticed that this is only when you first write the import code in the component and only then create the file itself. And in reverse order, everything is fine.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question