1

I am working on a teams app. I have my tab in react and typescript. (if you are not aware of teams app, the tab can be considered as a individual react app)

I am initiating linting with help of es lint and prettier.

I am able to run my script and get the issues. In fact I have resolved all of them.

When I start debugging my teams application, I get this error:

`ERROR in [eslint] Cannot find module 'node:fs' Require stack:

  • /Users/teams_app/tabs/node_modules/synckit/lib/index.cjs
  • /Users/teams_app/tabs/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js
  • /Users/teams_app/tabs/node_modules/@eslint/eslintrc/dist/eslintrc.cjs Occurred while linting /Users/teams_app/tabs/src/components/tabs/wish-tab/Wish.tsx:1 Rule: "prettier/prettier"`

Here's my eslintrc.json

{
  "env": {
    "browser": true,
    "es2021": true,
    "jest": true
  },
  "extends": [
    "react-app",
    "react-app/jest",
    "airbnb",
    "airbnb-typescript",
    "plugin:import/typescript",
    "plugin:prettier/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module",
    "project": "./tsconfig.json"
  },
  "plugins": ["react", "@typescript-eslint", "prettier"],
  "rules": {
    //my rules here
  }
}

Here's the list of dev dependencies

"devDependencies": {
    "@types/node": "^20.4.2",
    "@types/react": "^16.14.6",
    "@types/react-dom": "^16.9.12",
    "@types/react-router-dom": "^5.1.7",
    "cross-env": "^7.0.3",
    "env-cmd": "^10.1.0",
    "eslint": "^8.45.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-airbnb-typescript": "^17.1.0",
    "eslint-import-resolver-typescript": "^2.7.1",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "typescript": "^4.1.2"
  },

This is my folder structure folder structure image But on everyfile I get this error - seems like it is not taking the path correctly path error image

I tried downgrading "eslint-import-resolver-typescript" to "^2.7.1", and installing the latest node version. I am using 18.16.1 I upgraded the "@types/node" to "^20.4.2",

I am expecting it to run with out any error

2
  • "@types/node": "^12.0.0", doesn't match the version of Node you are using. It's ancient. Commented Jul 18, 2023 at 14:13
  • Updated "@types/node": "^20.4.2" but I get the same error. I have added few more details on the path error which might be a possible hint Commented Jul 19, 2023 at 10:15

1 Answer 1

1

I'm getting this same issue and it seems like it's caused by this line in my eslintrc: "plugin:prettier/recommended",. Mine is a fresh install of ViteJS with airbnb's eslint and prettier. I'm not sure why the plugin wasn't working, but it mentions it's best when it's the only plugin. Luckily I didn't need it, read below.

This line is for the plugin that applies Prettier rules in eslint, so you'll see the red squiggly lines when something isn't right. I don't want eslint to remind me that I need to format it myself. https://github.com/prettier/eslint-plugin-prettier

I want to use the config prettier, that is a pre-defined set of rules for prettier. these are the rules that my format command will use. https://github.com/prettier/eslint-config-prettier

I changed this to just "prettier" in the extends object in my eslintrc which turns off some ESLint rules that conflict with Prettier. I also removed prettier from the plugins array in my eslintrc

extends: ['prettier']

plugins: ['react-refresh', '@typescript-eslint']

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.