Javascript: Configuration for rule "import/no-cycle" is invalid

Created on 9 Nov 2020  Â·  9Comments  Â·  Source: airbnb/javascript

Oops! Something went wrong! :(

ESLint: 7.0.0

Error: .eslintrc » eslint-config-airbnb » /node_modules/eslint-config-airbnb-base/index.js » /node_modules/eslint-config-airbnb-base/rules/imports.js:
Configuration for rule "import/no-cycle" is invalid:
Value "∞" should be integer.

My package json devDependency.

    "@babel/core": "7.9.6",
    "@babel/runtime": "7.9.6",
    "@react-native-community/eslint-config": "0.0.5",
    "@testing-library/jest-native": "3.1.0",
    "@testing-library/react-native": "5.0.3",
    "babel-eslint": "10.1.0",
    "babel-jest": "24.8.0",
    "babel-plugin-inline-import": "3.0.0",
    "eslint": "7.0.0",
    "eslint-config-airbnb": "18.1.0",
    "eslint-config-prettier": "6.10.0",
    "eslint-import-resolver-react-native": "0.2.0",
    "eslint-plugin-import": "2.20.1",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-prettier": "3.1.2",
    "eslint-plugin-react": "7.19.0",

This has started occurring from today only. It was working last week.

Most helpful comment

eslint-config-airbnb-base has a

  "peerDependencies": {
    "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
    "eslint-plugin-import": "^2.22.1"
  },

so update your eslint-plugin-import to ^2.22.1 version, which supports "∞" symbol.

It works for me.

All 9 comments

I have the same issue.

Replacing ∞ with Infinity works like version 14.2.0

When comparing version 14.2.1 with 14.2.0 https://github.com/airbnb/javascript/compare/eslint-config-airbnb-base-v14.2.0...eslint-config-airbnb-base-v14.2.1

-   'import/no-cycle': ['error', { maxDepth: Infinity }],
+   'import/no-cycle': ['error', { maxDepth: '∞' }],

eslint-config-airbnb-base has a

  "peerDependencies": {
    "eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
    "eslint-plugin-import": "^2.22.1"
  },

so update your eslint-plugin-import to ^2.22.1 version, which supports "∞" symbol.

It works for me.

Run npm ls - if your peer dep versions are wrong, your dep graph is invalid, and nothing can be expected to work. Specifically, ensure your eslint plugins are updated (and nothing in your package.json should lack a ^, pinning is achieved with a lockfile, not with package.json)

This kind of issue is why I hate hate hate the Node ecosystem. Someone decides it would be cute to use a literaly infinity symbol in a config file, doesn't think through the implications, and _bam_ lint stops working. I wonder what proportion of all my "work" time is spent on tripping over, diagnosing, and working around totally avoidable problems like this? _sigh_

@MikeTaylor thats not actually what happened. eslint had a breaking change in a minor version, so that Infinity no longer was accepted, and in response, the import plugin added the infinity symbol as a string so as to not screw over static config users.

The issue is that updating anything, without updating its peer deps, is broken and your own mistake. Any time npm ls exits nonzero, your dep graph is invalid and nothing can be expected to work. In this package’s case, the readme itself gives you explicit install instructions which this user clearly did not follow.

Thanks, @ljharb, for that background, and my apologies to the eslint-config-airbnb-base people for falsely blaming them.

I send no compliments to the people who made a breaking change in a minor release of ESLint :-)

I have this problem too, but I have "eslint-plugin-import" updated to "2.22.1".

I also still have this problem with "eslint-plugin-import" updated to "2.22.1".

I also still have this problem with "eslint-plugin-import" updated to "2.22.1".

Try to remove node_modules and install it from scratch.
Also run npm ls, to check your peer dep versions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

graingert picture graingert  Â·  3Comments

kozhevnikov picture kozhevnikov  Â·  3Comments

ryankask picture ryankask  Â·  3Comments

brendanvinson picture brendanvinson  Â·  4Comments

felixsanz picture felixsanz  Â·  3Comments