Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition for rule '@typescript-eslint/no-angle-bracket-type-assertion' was not found @typescript-eslint/no-angle-bracket-type-assertion #863

Closed
tomitrescak opened this issue Aug 15, 2019 · 16 comments
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended

Comments

@tomitrescak
Copy link

Hi, with the latest version I am getting following warning:

Line 1:1:  Definition for rule '@typescript-eslint/no-angle-bracket-type-assertion' was not found  @typescript-eslint/no-angle-bracket-type-assertion
{
  "parser": "@typescript-eslint/parser",
  "plugins": ["react-hooks"],
  "rules": {
    "@typescript-eslint/indent": ["error", 2],
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/prefer-interface": "off",
    "@typescript-eslint/explicit-member-accessibility": "off",
    "@typescript-eslint/no-var-requires": "off",
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "error",
    "react/prop-types": "off",
    "no-undef": "off"
  },
  "extends": [
    "plugin:react/recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "prettier",
    "prettier/@typescript-eslint"
  ],
  "settings": {
    "react": {
      "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
    }
  }
}
// your repro code case

Expected Result

Actual Result

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin X.Y.Z
@typescript-eslint/parser X.Y.Z
TypeScript X.Y.Z
ESLint X.Y.Z
node X.Y.Z
npm X.Y.Z
@tomitrescak tomitrescak added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Aug 15, 2019
@bradzacher
Copy link
Member

The rule has been removed in 2.0.0 and replaced with another one.

Please read the 2.0.0 release notes: https://github.com/typescript-eslint/typescript-eslint/releases/tag/v2.0.0

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for team members to take a look labels Aug 15, 2019
@tomitrescak

This comment has been minimized.

@tomitrescak

This comment has been minimized.

@Emiliano-Bucci
Copy link

Emiliano-Bucci commented Aug 30, 2019

@bradzacher Hi! I'm still having the same warning:

Definition for rule '@typescript-eslint/no-angle-bracket-type-assertion' was not found  @typescript-eslint/no-angle-bracket-type-assertion

This is my current eslint configuration:

module.exports = {
  // Specifies the ESLint parser
  parser: "@typescript-eslint/parser",
  extends: [
    "eslint:recommended",
    // Recommended rules from the @typescript-eslint/eslint-plugin
    "plugin:@typescript-eslint/recommended",
    "plugin:react/recommended",
    // Disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
    "prettier/@typescript-eslint",
    // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors.
    // This should always be the last configuration in the extends array.
    "plugin:prettier/recommended"
  ],
  plugins: ["react-hooks"],
  parserOptions: {
    // Allows for the parsing of modern ECMAScript features
    ecmaVersion: 2018,
    // Allows for the use of imports
    sourceType: "module",
    ecmaFeatures: {
      // Allows for the parsing of JSX
      jsx: true
    }
  },
  env: {
    browser: true,
    node: true,
    es6: true,
    jest: true
  },
  rules: {
    "@typescript-eslint/no-unused-vars": [
      "error",
      {
        ignoreRestSiblings: true,
        argsIgnorePattern: "^_"
      }
    ],
    // Errors
    "react-hooks/rules-of-hooks": 2,
    // Warnings
    "react-hooks/exhaustive-deps": 1,
    // Allowed
    "no-console": ["error", { allow: ["warn", "error"] }],
    "@typescript-eslint/no-explicit-any": 0,
    "@typescript-eslint/no-var-requires": 0,
    "@typescript-eslint/no-non-null-assertion": 0,
    "@typescript-eslint/explicit-function-return-type": 0,
    "@typescript-eslint/explicit-member-accessibility": 0,
    "@typescript-eslint/no-empty-interface": 0,
    "@typescript-eslint/camelcase": 0,
    "@typescript-eslint/no-use-before-define": 0,
    "@typescript-eslint/consistent-type-assertions": 0,
    "react/prop-types": 0,
    "react/no-unescaped-entities": 0,
    "react/display-name": 0,
    /**
     *
     *  Temporary disabled; to be removed gradually.
     *
     **/
    "react/no-find-dom-node": 0
  },
  settings: {
    react: {
      // Tells eslint-plugin-react to automatically detect the version of React to use
      version: "detect"
    }
  }
};

and my package.json:

{
  "name": "cx-ui",
  "version": "1.0.13",
  "private": true,
  "scripts": {},
  "dependencies": {
    "@types/amcharts": "3.21.4",
    "@webcomponents/custom-elements": "1.2.4",
    "amcharts3": "3.21.15",
    "antd": "3.22.1",
    "apollo": "2.15.0",
    "apollo-cache-inmemory": "1.6.2",
    "apollo-client": "2.6.3",
    "apollo-link": "1.2.12",
    "apollo-link-batch-http": "1.2.12",
    "apollo-link-context": "1.0.18",
    "apollo-link-error": "1.1.11",
    "apollo-link-http": "1.5.15",
    "apollo-link-logger": "1.2.3",
    "apollo-utilities": "1.3.2",
    "boxen": "4.1.0",
    "clarity-icons": "0.10.28",
    "classnames": "2.2.6",
    "glamor": "2.20.40",
    "glamorous": "5.0.0",
    "graphql": "14.5.3",
    "graphql-tag": "2.10.1",
    "hls.js": "0.12.4",
    "hoist-non-react-statics": "3.3.0",
    "intersection-observer": "0.7.0",
    "locale2": "2.3.1",
    "lodash-es": "4.17.15",
    "lodash.debounce": "4.0.8",
    "lodash.groupby": "4.6.0",
    "lodash.memoize": "4.1.2",
    "lodash.throttle": "4.1.1",
    "mediaelement": "4.2.12",
    "moment": "2.24.0",
    "normalize.css": "8.0.1",
    "prop-types": "15.7.2",
    "query-string": "6.8.2",
    "raf": "3.4.1",
    "react": "16.9.0",
    "react-apollo": "2.5.8",
    "react-copy-to-clipboard": "5.0.1",
    "react-dates": "20.3.0",
    "react-dom": "16.9.0",
    "react-dotdotdot": "1.3.1",
    "react-dropzone": "10.1.7",
    "react-helmet": "5.2.1",
    "react-intl": "3.1.11",
    "react-media": "1.9.2",
    "react-number-format": "4.2.0",
    "react-redux": "7.1.1",
    "react-router-dom": "5.0.1",
    "react-s3-uploader": "4.8.0",
    "react-scripts": "3.0.1",
    "react-select": "3.0.4",
    "react-switch": "5.0.1",
    "react-table": "6.10.0",
    "react-test-renderer": "16.9.0",
    "recharts": "1.7.1",
    "recompose": "0.30.0",
    "redux": "4.0.4",
    "redux-thunk": "2.3.0",
    "reselect": "4.0.0",
    "shortid": "2.2.14",
    "smoothscroll-polyfill": "0.4.4",
    "ts-import-plugin": "1.6.1",
    "unstated": "2.1.1",
    "uuid": "3.3.3",
    "validator": "11.1.0"
  },
  "devDependencies": {
    "@amcharts/amcharts3-react": "3.1.0",
    "@amcharts/amcharts4": "4.5.15",
    "@sentry/browser": "5.6.2",
    "@storybook/addon-actions": "5.2.0-beta.9",
    "@storybook/addon-docs": "5.2.0-beta.9",
    "@storybook/addon-links": "5.2.0-beta.9",
    "@storybook/addons": "5.2.0-beta.9",
    "@storybook/react": "5.2.0-beta.9",
    "@testing-library/jest-dom": "4.1.0",
    "@testing-library/react": "9.1.3",
    "@types/classnames": "2.2.9",
    "@types/expect-puppeteer": "3.3.1",
    "@types/graphql": "14.5.0",
    "@types/hls.js": "0.12.4",
    "@types/hoist-non-react-statics": "3.3.1",
    "@types/isomorphic-fetch": "0.0.35",
    "@types/jest": "24.0.18",
    "@types/jest-environment-puppeteer": "4.3.1",
    "@types/lodash": "4.14.137",
    "@types/lodash-es": "4.17.3",
    "@types/lodash.debounce": "4.0.6",
    "@types/lodash.groupby": "4.6.6",
    "@types/lodash.memoize": "4.1.6",
    "@types/lodash.throttle": "4.1.6",
    "@types/node": "12.7.2",
    "@types/prop-types": "15.7.1",
    "@types/puppeteer": "1.19.1",
    "@types/react": "16.9.2",
    "@types/react-dates": "17.1.5",
    "@types/react-dom": "16.9.0",
    "@types/react-helmet": "5.0.9",
    "@types/react-intl": "3.0.0",
    "@types/react-redux": "7.1.2",
    "@types/react-router-dom": "4.3.5",
    "@types/react-select": "3.0.4",
    "@types/react-table": "6.8.5",
    "@types/react-test-renderer": "16.9.0",
    "@types/recharts": "1.1.21",
    "@types/recompose": "0.30.7",
    "@types/shortid": "0.0.29",
    "@types/smoothscroll-polyfill": "0.3.1",
    "@types/uuid": "3.4.5",
    "@types/validator": "10.11.3",
    "@types/webpack-env": "1.14.0",
    "@typescript-eslint/eslint-plugin": "2.0.0",
    "@typescript-eslint/parser": "2.0.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-plugin-glamorous-displayname": "2.2.0",
    "babel-plugin-import": "1.12.0",
    "chalk": "2.4.2",
    "check-dependencies": "1.1.0",
    "docz": "1.2.0",
    "docz-plugin-css": "0.11.0",
    "enhanced-resolve": "4.1.0",
    "eslint-config-prettier": "6.1.0",
    "eslint-plugin-prettier": "3.1.0",
    "eslint-plugin-react": "7.14.3",
    "eslint-plugin-react-hooks": "2.0.1",
    "husky": "3.0.4",
    "hygen": "4.0.9",
    "isomorphic-fetch": "2.2.1",
    "lint-staged": "9.2.4",
    "npm-run-all": "4.1.5",
    "prettier": "1.18.2",
    "react-app-rewire-hot-loader": "2.0.1",
    "react-hot-loader": "4.12.11",
    "redux-mock-store": "1.5.3",
    "source-map-explorer": "2.0.1",
    "svg-react-loader": "0.4.6",
    "ts-jest": "24.0.2",
    "ts-node": "8.3.0",
    "typescript": "3.4.5"
    },
  }
}

Any clues on how could be throwing the error/how to silence the warning?

Thanks! :)

@bradzacher
Copy link
Member

You must have a config or something somewhere which still has it configured.
ESLint doesn't throw those errors unless you've got it configured.

You can use the --debug cli flag to help inspect which config files are being loaded.
You can also use the --print-config cli flag to help figure out the resolved config for a file.

@tomitrescak
Copy link
Author

It’s the React-Scripts that only supports v1 and enforces it’s own config.

@Emiliano-Bucci
Copy link

@tomitrescak Thanks for the clarification. Do you know if is possible to configure react-scripts in order to not enforce it's own config? Or to make eslint config prioritize? Thanks

@sywesk
Copy link

sywesk commented Sep 2, 2019

@Emiliano-Bucci in your package.json, remove this part:

  "eslintConfig": {
    "extends": "react-app"
  },

@Emiliano-Bucci
Copy link

@sywesk Yep, initially i did that; then i update to latest react-scripts (3.1.1) and that solved completely the issue; thanks anyway! :)

@sywesk
Copy link

sywesk commented Sep 2, 2019

@Emiliano-Bucci strange, i'm on 3.1.1 and have the issue. Seems you've been lucky :D
I did revert the version of typescript-eslint though.

@tomitrescak
Copy link
Author

@Emiliano-Bucci it is indeed strange it work for you as the culprit line is still there even in 3.1.1:

https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/index.js#L81

But I'm glad it still work for you ;) All and all, CRA supports currently v1 only.

@justinobney
Copy link

"@typescript-eslint/no-angle-bracket-type-assertion": "off" solved this for me.

I am using create-react-app with craco to override my eslint rules via what I have defined in my package.json.

craco config:

const pkg = require('./package.json');
...
eslint: {
  configure: eslintConfig => {
    eslintConfig.rules = pkg.eslintConfig.rules;
    return eslintConfig;
  },
},
...

package.json:

...
"eslintConfig": {
  "extends": "react-app",
  "rules": {
    "no-use-before-define": 0,
    "react/jsx-uses-react": 1,
    "react/jsx-no-bind": 0,
    "react-hooks/exhaustive-deps": [
      "warn",
      {
        "additionalHooks": "useAsync"
      }
    ],
    "no-restricted-syntax": [
      "error",
      {
        "selector": "CallExpression[callee.object.name='console']",
        "message": "Use of console prohibited. Use a logger instead. (See logger.ts)"
      }
    ],
    "@typescript-eslint/no-angle-bracket-type-assertion": "off"
  }
},
...

@arielvol
Copy link

I solved this issue this way:

  1. Delete the node_modules

  2. update the Package.Json line of React-scripts to this: ""react-scripts": "3.1.2""

  3. run npm i

This should work

@corysimmons
Copy link

Can confirm, "react-scripts": "^3.1.2" fixed it for me.

@markpradhan
Copy link

If you are using eslint-config-react-app (using the config without create-react-app), updating it to ^5.0.2 will fix the issue.

@davidecarpini
Copy link

davidecarpini commented Oct 28, 2019

I found that using yarn instead of npm led me to this error.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

9 participants