I am trying to add a rule to my .eslintrc.json to disallow the any
type.
I added the rule ("@typescript-eslint/no-explicit-any": "error"
) to my setup:
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"airbnb-typescript",
"prettier"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module",
"project": ["./tsconfig.json", "cypress/tsconfig.json"]
},
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
"rules": {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
"import/prefer-default-export": "off",
"import/no-relative-parent-imports": "error",
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object"
],
"alphabetize": {
"order": "asc"
},
"newlines-between": "always"
}
],
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/semi": "warn",
"@typescript-eslint/no-explicit-any": "error",
"max-len": [
2,
{
"code": 150,
"ignorePattern": "^import .*"
}
]
}
}
But I am getting an error:
Failed to compile.
Rules with suggestions must set the `meta.hasSuggestions` property to `true`. `meta.docs.suggestion` is ignored by ESLint.
Occurred while lining <name of file>
Rule: "@typescript-eslint/no-explicit-any"
These are some of the used packages and their version:
"@types/react": "^17.0.45",
"@types/react-datepicker": "^4.4.1",
"@types/react-dom": "^17.0.17",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.25",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@typescript-eslint/typescript-estree": "^4.33.0",
"axe-core": "^4.4.2",
"cypress": "^9.6.1",
"cypress-axe": "^0.14.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0",
"jest-junit": "^13.2.0",
"prettier": "^2.6.2",
"prettier-eslint": "^13.0.0"
I saw another post on StackOverflow suggesting to use eslint-plugin-react-hooks for another error but cannot find anything similar for the rule I'm trying to apply. Also, some people mentioned issues with version 8+ of eslint but based on the packages I have it seems I have version: 7.32.0
Adding meta: {hasSuggestions: true}
doesn't work and gives me the same error as in this ticket
Any help will be greatly appreciated.