Using prettier with eslint, esLint error remove ; from before (

Viewed 192

My react typescript prettier and eslint config as below. It mostly works fine just for one case

Eslint error: Unnecessary semicolon.

enter image description here

Note: semicolumn is enforced by prettier but in the below config it is set to false.

Config Files:

.prettierrc

{
  "trailingComma": "es5",
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "printWidth": 100,
  "bracketSpacing": true
}

.eslintrc.json

{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": [
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended"
    // "plugin:prettier/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "plugins": ["react", "@typescript-eslint", "react-hooks"],
  "rules": {
    "semi": [2, "never"],
    // "no-extra-semi": "error",
    "react/react-in-jsx-scope": "off",
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn",
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [".ts", ".tsx"]
      }
    ]
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

I have some async code like

;(async() => {
// some code 
}
)()

There may be prettier and eslint config conflict. not sure how to resolved them.

0 Answers
Related