prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.39k stars 255 forks source link

Cannot read config file /node_modules/eslint-config-prettier/react.js #191

Closed VladCherniavsky closed 3 years ago

VladCherniavsky commented 3 years ago

Hello all

I constantly see this error in react-native app with eslint and prettier Cannot read config file /node_modules/eslint-config-prettier/react.js Error: "prettier/react" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21 Referenced from: /Users/uladzislau_charniaus/Projects/rcl_native/.eslintrc.json

What is going wrong here ?

.eslintrc
{
  "extends": [
    "airbnb",
    "airbnb/hooks",
    "plugin:@typescript-eslint/recommended",
    "prettier",
    "prettier/react",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended"
  ],
  "plugins": ["@typescript-eslint", "react", "prettier"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 2018,
    "sourceType": "module",
    "project": "./tsconfig.json"
  },
  "rules": {
    "import/no-unresolved": 0,
    "react/jsx-filename-extension": [1, {
      "extensions": [
        ".ts",
        ".tsx"
      ]
    }],
    "prettier/prettier": [
      "error",
      {
        "singleQuote": true,
        "trailingComma": "all",
        "arrowParens": "avoid",
        "endOfLine": "auto"
      }
    ],
    "no-use-before-define": "off",
    "@typescript-eslint/no-use-before-define": ["error"],
    "import/extensions": ["error", "never"],
    "react/prop-types": 0,
    "no-shadow": "off",
    "@typescript-eslint/no-shadow": ["error"]
  }
}

package.json
{
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-navigation/bottom-tabs": "5.11.2",
    "@react-navigation/native": "~5.8.10",
    "@react-navigation/stack": "~5.12.8",
    "axios": "^0.21.1",
    "cheerio": "^1.0.0-rc.9",
    "expo": "~41.0.1",
    "expo-asset": "~8.3.1",
    "expo-constants": "~10.1.3",
    "expo-font": "~9.1.0",
    "expo-linking": "~2.2.3",
    "expo-splash-screen": "~0.10.2",
    "expo-status-bar": "~1.0.4",
    "expo-web-browser": "~9.1.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-reanimated": "~2.1.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.0.0",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@types/react": "~16.9.35",
    "@types/react-native": "~0.63.2",
    "@typescript-eslint/eslint-plugin": "^4.24.0",
    "@typescript-eslint/parser": "^4.24.0",
    "eslint": "^7.2.0",
    "eslint-config-airbnb": "18.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.21.5",
    "eslint-plugin-react-hooks": "^1.7.0",
    "jest-expo": "~41.0.0",
    "prettier": "^2.3.0",
    "typescript": "~4.0.0"
  },
  "private": true
}
lydell commented 3 years ago

Hi! What part of the error message are you having trouble with?

VladCherniavsky commented 3 years ago

Hi! What part of the error message are you having trouble with?

This one Cannot read config file /node_modules/eslint-config-prettier/react.js

lydell commented 3 years ago

Thanks! What about this part?

"prettier/react" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21

VladCherniavsky commented 3 years ago

Thanks! What about this part?

"prettier/react" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21

I thought that this piece of information may come in handy when in comes to detecting what is wrong here

lydell commented 3 years ago

Nice! Have you tried doing the things described at that link?

VladCherniavsky commented 3 years ago

Nice! Have you tried doing the things described at that link?

Link says to add some-other-config-you-use instead of couple of packages. I find it not clear what other config I have to add

lydell commented 3 years ago

some-other-config-you-use refers to the other configs you have in "extends" besides "prettier".

lydell commented 3 years ago

So, anyway, this should work:

  "extends": [
    "airbnb",
    "airbnb/hooks",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended"
  ],

Do you have suggestions on how to improve the error message and changelog? I’m not sure how to make it more clear.

lydell commented 3 years ago

Closing because no response.

rushikeshtonape commented 1 year ago

thanks @lydell for this solution. I had a same error and now it has solved.

wakapaks180 commented 1 year ago

Hi I am new to this, I have this error, don't know how to fix this one :(

Error: Command failed: eslint --fix src/xxx/xxxx.tsx

Oops! Something went wrong! :(

ESLint: 8.39.0

Error: Cannot read config file: node_modules/eslint-config-prettier/@typescript-eslint.js
Error: "prettier/@typescript-eslint" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21

.eslintrc.js

module.exports = {
  parser: '@typescript-eslint/parser', // Specifies the ESLint parser
  plugins: ['react-hooks'],
  extends: [
    'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
    'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
    'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
    'plugin:prettier/recommended' // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  ],
  parserOptions: {
    ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
    sourceType: 'module' // Allows for the use of imports
  },
  settings: {
    react: {
      version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use
    }
  },
  rules: {
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/consistent-type-assertions': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/member-delimiter-style': 'off',
    'react/prop-types': 'off',
    '@typescript-eslint/no-empty-interface': 'off',
    'react/display-name': 'off',
    '@typescript-eslint/ban-ts-ignore': 'off',
    '@typescript-eslint/ban-ts-comment': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/ban-types': 'off',
    '@typescript-eslint/no-var-requires': 'off',
    '@typescript-eslint/no-unused-vars': ['error'],
    'no-unused-vars': 'off',
    'no-console': 'off',
    semi: 'off'
  },
  settings: {
    react: {
      version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use
    }
  }
}

package.json

{
  "dependencies": {
    "@apollo/client": "^3.7.13",
    "@apollo/react-hooks": "^4.0.0",
    "@bugsnag/js": "^7.20.2",
    "@bugsnag/plugin-react": "^7.19.0",
    "@chakra-ui/icons": "^2.0.19",
    "@chakra-ui/react": "^2.6.0",
    "@emotion/css": "^11.10.8",
    "@emotion/react": "^11.10.8",
    "@emotion/styled": "^11.10.8",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^14.0.0",
    "@testing-library/user-event": "^14.4.3",
    "@types/axios": "^0.14.0",
    "@types/node": "^18.16.3",
    "@types/react": "^18.2.0",
    "@types/react-dom": "^18.2.1",
    "@types/react-table": "^7.7.14",
    "@types/styled-system": "^5.1.16",
    "axios": "^1.4.0",
    "cross-fetch": "3.1.5",
    "date-fns": "2.30.0",
    "enzyme": "^3.11.0",
    "faker": "^6.6.6",
    "formik": "^2.2.9",
    "framer-motion": "^10.12.5",
    "graphql": "16.6.0",
    "jwt-decode": "^3.1.2",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "msw": "1.2.1",
    "react": "^18.2.0",
    "react-dates": "^21.8.0",
    "react-dom": "^18.2.0",
    "react-feather": "^2.0.10",
    "react-flexbox-grid": "^2.1.2",
    "react-helmet": "^6.1.0",
    "react-intersection-observer": "^9.4.3",
    "react-router-dom": "^6.11.0",
    "react-scripts": "5.0.1",
    "react-table": "^7.8.0",
    "recoil": "^0.7.7",
    "recoil-persist": "^4.2.0",
    "styled-system": "^5.1.5",
    "typescript": "^5.0.4",
    "use-react-router-breadcrumbs": "^4.0.1",
    "yup": "^1.1.1"
  },
  "devDependencies": {
    "@apollo/react-components": "^4.0.0",
    "@apollo/react-hoc": "^4.0.0",
    "@babel/preset-typescript": "^7.21.5",
    "@cypress/code-coverage": "3.10.4",
    "@cypress/instrument-cra": "^1.4.0",
    "@graphql-codegen/cli": "^3.3.1",
    "@graphql-codegen/typescript": "^3.0.4",
    "@graphql-codegen/typescript-operations": "^3.0.4",
    "@graphql-codegen/typescript-react-apollo": "^3.3.7",
    "@semantic-release/changelog": "^6.0.3",
    "@semantic-release/commit-analyzer": "^9.0.2",
    "@semantic-release/git": "^10.0.1",
    "@semantic-release/npm": "^10.0.3",
    "@semantic-release/release-notes-generator": "^11.0.1",
    "@testing-library/react-hooks": "^8.0.1",
    "@types/chai": "^4.3.5",
    "@types/enzyme": "^3.10.13",
    "@types/faker": "^6.6.8",
    "@types/jest": "^29.5.1",
    "@types/lodash": "^4.14.194",
    "@types/react-dates": "^21.8.3",
    "@types/react-helmet": "^6.1.6",
    "@types/react-router-dom": "^5.3.3",
    "@types/yup": "^0.29.14",
    "@typescript-eslint/eslint-plugin": "^5.59.2",
    "@typescript-eslint/parser": "^5.59.2",
    "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
    "babel-jest": "29.5.0",
    "babel-plugin-istanbul": "6.1.1",
    "chai": "^4.3.7",
    "cypress": "12.11.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "husky": "^8.0.3",
    "jest": "29.5.0",
    "lint-staged": "^13.2.2",
    "nyc": "^15.1.0",
    "prettier": "^2.8.8",
    "semantic-release": "^21.0.2",
    "ts-jest": "29.1.0"
  },
}
lydell commented 1 year ago

@wakapaks180 This has nothing to do with this (old, closed) issue, but here goes anyway. What the error message is trying to tell you is to remove the 'prettier/@typescript-eslint', line.

wakapaks180 commented 1 year ago

I tried to remove that one, but I am having this error, there are lots of error but I only have to show below image.

Screen Shot 2023-05-03 at 8 40 53 PM

Ahm I wanna ask if that is an eslint error ? sorry for asking, I am a newbie on this one.

This is a typescript project, we want to run this project on our end because the previous developer is no longer to be found.

lydell commented 1 year ago

That’s a TypeScript error. This is not the place to ask for help.

wakapaks180 commented 1 year ago

thank you for the response sir.