Code Monkey home page Code Monkey logo

Comments (13)

jordan-erisman avatar jordan-erisman commented on September 12, 2024 1

Actually, I think I might have figured it out why the parser isn't making it through on the context. I should be able to get a fix in later today now.

@michaelfaith, this seems to get me passed the no parser error! I can go ahead and approve my from standpoint (not sure who officially needs to do it). Would love if this got released soon!

from eslint-plugin-import.

ljharb avatar ljharb commented on September 12, 2024 1

Yes, but in general asking doesn't do much, so the best thing is to wait :-)

from eslint-plugin-import.

connorjs avatar connorjs commented on September 12, 2024

The PR has some documentation I was trying to follow, but I have not fully resolved it yet (likely a me issue). See #3018

Also, until I properly update to latest versions, I pinned eslint-module-utils to ~2.8. (Running npm upgrade led to similar errors as OP, so I figured Iā€™d note this too.)

from eslint-plugin-import.

ljharb avatar ljharb commented on September 12, 2024

cc @michaelfaith it's possible #3018 caused some regressions in eslint-module-utils.

from eslint-plugin-import.

michaelfaith avatar michaelfaith commented on September 12, 2024

That's interesting, though, I'm not sure how that PR could have caused and issue with eslint-module-utils. The only change to the utils package was expanding the default extensions array to include .mjs and .cjs, which was more of an after thought and not critical for the flat config support. Certainly don't mind reverting that, if that's causing issues; though I don't think that's at play here. Could it have been this change that came in 2.8.2? c387276
@connorjs does 2.8.2 work for you?

As far as documentation, I can improve on that for sure. @valleywood did you check out the typescript example that I added to the repo with the flat config PR: https://github.com/import-js/eslint-plugin-import/blob/main/examples/flat/eslint.config.mjs

from eslint-plugin-import.

connorjs avatar connorjs commented on September 12, 2024

2.8.2 worked for me. I'll do some more digging into my ESLint config. I was trying to do an "update all" pass and got everything except import plugin updated. I was also running npm upgrade in order to get transitive dependencies also up to date: that's when I found the utils change to be source of my issue. (Which, again, could be a me issue.)

I'll open a separate issue for what I see if needed though. We can keep this focused on documentation if desired? Up to y'all

from eslint-plugin-import.

jordan-erisman avatar jordan-erisman commented on September 12, 2024

That's interesting, though, I'm not sure how that PR could have caused and issue with eslint-module-utils. The only change to the utils package was expanding the default extensions array to include .mjs and .cjs, which was more of an after thought and not critical for the flat config support. Certainly don't mind reverting that, if that's causing issues; though I don't think that's at play here. Could it have been this change that came in 2.8.2? c387276 @connorjs does 2.8.2 work for you?

As far as documentation, I can improve on that for sure. @valleywood did you check out the typescript example that I added to the repo with the flat config PR: https://github.com/import-js/eslint-plugin-import/blob/main/examples/flat/eslint.config.mjs

@michaelfaith, I am also experiencing the same error here: parserPath or languageOptions.parser is required!

I cloned your example repo with the flat config and one way I was able to reproduce was by trying to import a third party library. For example:

yarn add redaxios

imports.ts

//import c from './exports';
import { a, b } from './exports';
import type { ScalarType, ObjType } from './exports';
import redaxios from 'redaxios';

import path from 'path';
import fs from 'node:fs';
import console from 'console';
image

Interesting side issue with that project

If i dont comment out 'import/no-unused-modules': ['warn', { unusedExports: true }], then I get this error:

Oops! Something went wrong! :(

ESLint: 8.57.0

ESLint couldn't find a configuration file

from eslint-plugin-import.

valleywood avatar valleywood commented on September 12, 2024

@michaelfaith Missed that example, thanks! (was looking in the README only)
However that example doesn't use make use of the the eslint-import-resolver-typescript as the old example does šŸ¤”
Don't know if's relevant/needed any longer though?

Also notably are that the only packages that are complaining about this in my case are the the @emotion prefixed imports (@emotion/styled, @emotion/cache, @emotion/server/create-instance etc.) all other packages seem to work.

Thanks @connorjs for the suggestion to pin eslint-module-utils to version 2.8.2. That made the errors with parserPath or languageOptions.parser is required! go away.

Looking forward to a solution though that doesn't require resolution/overrides šŸ™

from eslint-plugin-import.

SStranks avatar SStranks commented on September 12, 2024

@michaelfaith, I am also experiencing the same error here: parserPath or languageOptions.parser is required!

I'm experiencing this error, under the rule 'import/namespace', for both imported npm packages and also local pnpm workspace packages I have created. Using typescript, with the settings described in the docs for @typescript-eslint/parser and eslint-import-resolver-typescript.

from eslint-plugin-import.

michaelfaith avatar michaelfaith commented on September 12, 2024

I cloned your example repo with the flat config and one way I was able to reproduce was by trying to import a third party library. For example:

yarn add redaxios

imports.ts

//import c from './exports';
import { a, b } from './exports';
import type { ScalarType, ObjType } from './exports';
import redaxios from 'redaxios';

import path from 'path';
import fs from 'node:fs';
import console from 'console';
image

This was helpful. For the flat config example in the repo, if you explicitly define a parser for the other configs, then the error goes away.
e.g.

import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';

export default [
  js.configs.recommended,
  importPlugin.flatConfigs.react,
  {
    files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
    ...importPlugin.flatConfigs.recommended,
    ...importPlugin.flatConfigs.typescript,
    languageOptions: {
      parser: tsParser,
      ecmaVersion: 'latest',
      sourceType: 'module',
    },
  },
  {
    languageOptions: {
      parser: tsParser,
      ecmaVersion: 'latest',
      sourceType: 'module',
    },
    ignores: ['eslint.config.mjs', '**/exports-unused.ts'],
    rules: {
      'no-unused-vars': 'off',
      'import/no-dynamic-require': 'warn',
      'import/no-nodejs-modules': 'warn',
      'import/no-unused-modules': ['warn', { unusedExports: true }],
    },
  },
];

Which makes me wonder if this is related to what @G-Rath has been experiencing while trying to upgrade the plugin to support v9. They've been getting the same errors while trying to run the unit test suite with v9, and through console logging, found that eslint wasn't putting the default parser (espree) on the context, when a parser wasn't explicitly defined (eslint/eslint#17953 (comment)). So, it could be a bug with eslint, or it could be that the context isn't meant to have the parser attached if the user didn't define a parser, which makes the check that this plugin does in parse invalid and we need to fallback on a default ourselves, rather than relying on there always being one defined on the context, which is the current assumption the code makes.
In any event, if you try explicitly adding a parser, does that overcome the issue for you?

from eslint-plugin-import.

michaelfaith avatar michaelfaith commented on September 12, 2024

Actually, I think I might have figured it out why the parser isn't making it through on the context. I should be able to get a fix in later today now.

from eslint-plugin-import.

michaelfaith avatar michaelfaith commented on September 12, 2024

Thanks for verifying.

from eslint-plugin-import.

jordan-erisman avatar jordan-erisman commented on September 12, 2024

@ljharb, I see this fix was merged in. Is this something that will be released soon? If there's a better spot for me to ask, please let me know

from eslint-plugin-import.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.