eslint: JSX linting fails due to espree minor release including major dependency bump

Espree has released a minor version 4.1.0 which bumps acorn-jsx to a new major version (5), which in turn breaks JSX linting (see https://github.com/eslint/espree/issues/393)

Acorn-jsx needs to be used in a different way as of version 5, https://github.com/RReverser/acorn-jsx/commit/ddcc01d707b2eb5f9ae4de36ba32e2276a18ba3c

We are running command eslint **/*.jsx in the terminal, errors thrown: error Parsing error: Unexpected token =

ESLint: 5.7.0 Node: any npm: any

Configuration
module.exports = {
	env: {
		node: true,
		browser: true,
		es6: true
	},
	plugins: [
		'jsx-a11y'
	],
	extends: [
		'eslint:recommended',
		// https://github.com/jest-community/eslint-plugin-jest
		'plugin:jest/recommended',
		// https://github.com/yannickcr/eslint-plugin-react
		'plugin:react/recommended',
		// https://github.com/evcohen/eslint-plugin-jsx-a11y
		'plugin:jsx-a11y/recommended'
	],
	parserOptions: {
		ecmaFeatures: {
			jsx: true
		},
		ecmaVersion: 2018,
		// Support for ESM is not tied to an ES version
		sourceType: 'module'
	},
	settings: {
		react: {
			version: '16.3'
		}
	},
	rules: {
		// We don't expect consumers of x-dash to use prop types
		'react/prop-types': 'off',
		// We don't use display names for SFCs
		'react/display-name': 'off',
		// This rule is intended to catch < or > but it's too eager
		'react/no-unescaped-entities': 'off'
	},
	overrides: [
		{
			// Components in x-dash interact with x-engine rather than React
			files: [ 'components/**/*.jsx' ],
			settings: {
				react: {
					pragma: 'h',
					createClass: 'Component'
				}
			},
			rules: {
				'react/prefer-stateless-function': 'error'
			}
		}
	]
};

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 25 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I don’t think the revert makes sense. This causes by acorn’s breaking change. Currently, the npm’s bug appears when there is a older acorn in another dependency. After reverting, it will appear when there is a newer acorn in another dependency.

I had emailed with the npm support and they said they will discuss about this bug in npm inc.

But my request (please share the current status on https://npm.community/t/failed-to-install-eslint-in-a-specific-situation/2975) was ignored or they have no progress.

This is the simplest workaround I’ve found:

rm -rf node_modules && npm install --legacy-bundling

It forces npm to install packages like it did in npm@2, with no attempt to flatten the tree (which is where the bug is happening).

Since this happens in eslint 5.8 but not 5.7, perhaps whatever changed to surface the npm bug should be reverted and shipped in a patch release?

Since this issue seems to have been made worse by this past weekend’s release:

I don’t think we’re doing anything out of the ordinary here regarding Espree and its dependencies, and I’m curious if other projects are running into this issue at all.

The npm support team told me: “the bug fix requires substantial architectural changes, as a result, it’s on our roadmap for 2019 and might be implemented in the summer.”

Probably, it’s the following item in the roadmap:

Two-pass installer where resolution of the logical tree is distinct from computing the physical tree. With this we may be able to, at long last, end the pain around peerDependencies. https://blog.npmjs.org/post/173239798780/beyond-npm6-the-future-of-the-npm-cli

lol this is a bug, not a change request - please reopen it.

Agreed. I think this is helpful to leave open for now so that others experiencing this issue can track the progress of this.