eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

`import/namespace` failures when importing chai@5

Open timbeadle opened this issue 1 year ago • 6 comments

Upgrading from chai v4 to chai v5 yields the following eslint error:

cfpathcheck/test/cfpathcheck.spec.js
  1:24  error  Parse errors in imported module 'chai': Unexpected token ; (146:10)  import/namespace

The line of code in question is as follows:

import { expect } from 'chai';

For now I have added an ignore annotation to my code so that the linting passes, but it would be good to know why the import/namespace rule has started to fail with this new, ESM-only, version of chai.

Thank you 😸

timbeadle avatar Jan 03 '24 11:01 timbeadle

What’s your eslint config? A parse error is not expected.

ljharb avatar Jan 03 '24 15:01 ljharb

What’s your eslint config? A parse error is not expected.

env:
  browser: true
  es6: true
extends:
  - xo
  - plugin:import/recommended
parserOptions:
  ecmaVersion: 2021
  sourceType: module
plugins:
  - import
  - redos
rules:
  arrow-parens: 0
  object-curly-spacing: 0
  import/no-unresolved: [2]
  redos/no-vulnerable: error
overrides:
- files:
  - "**/*.spec.js"
  rules:
    redos/no-vulnerable: 'off'

timbeadle avatar Jan 03 '24 17:01 timbeadle

(fwiw i would advise against using any "recommended" configs; use the airbnb config for the best settings for this plugin)

Is there any way you could make a repro repo for this? I don't see anything in https://unpkg.com/browse/[email protected]/lib/chai/interface/expect.js that should fail to parse, but with a repro i can debug it locally.

ljharb avatar Jan 06 '24 22:01 ljharb

(fwiw i would advise against using any "recommended" configs; use the airbnb config for the best settings for this plugin)

Interesting - thanks. Does the README need to be updated to advise this?

I will prepare a repro for this later.

timbeadle avatar Jan 08 '24 09:01 timbeadle

Yes, it probably should be, I'll get on that.

ljharb avatar Jan 08 '24 16:01 ljharb

I get this same error when attempting to import marked. Apparently from this line https://github.com/markedjs/marked/blob/d342aaa0f8a0f5987ffb8b5898f9e2e01ecab784/src/Tokenizer.ts#L72

anselmbradford avatar Feb 14 '24 00:02 anselmbradford