Comments (13)
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 todaynow.
@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.
Yes, but in general asking doesn't do much, so the best thing is to wait :-)
from eslint-plugin-import.
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.
cc @michaelfaith it's possible #3018 caused some regressions in eslint-module-utils.
from eslint-plugin-import.
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.
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.
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';
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.
@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.
@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.
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';
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.
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.
Thanks for verifying.
from eslint-plugin-import.
@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)
- This plugin does not report `import/extensions` and `import/no-unresolved` errors on `import type ā¦` constructs HOT 3
- Making `ExportMap` available in `eslint-module-utils`?
- Update `tsconfig-paths` dependency to v4 HOT 1
- Regression in import/order rule after v2.26 HOT 1
- Mixed `type` imports does not trigger `import/no-duplicates` HOT 1
- Config to match vscode import sorting default HOT 2
- corrupted dependencies on windows?
- How to make it recognise internal modules as not external?
- Support for eslint v9 alternative HOT 1
- `import/consistent-type-specifier-style` for exports HOT 1
- Even larger `import/no-cycle` performance downgrade in 2.30.0 HOT 9
- eslint(import/named) reports `not found` errors in 2.30.0 HOT 7
- Enhancement: [import/no-restricted-paths] accept target exceptions HOT 5
- eslint > 9 as peer dependency of eslint HOT 3
- Rule to detect import of modules with and without directives HOT 3
- import/no-named-as-default-member rule became less useful in 2.30.0 HOT 1
- Missing `^9` eslint peer dependency HOT 2
- After upgrade from 2.29.1 to 2.30.0 get "Parse errors" in react-toastify: "parser.parse is not a function (undefined:undefined) import/no-deprecated" HOT 13
- š: [import/newline-after-import] Cannot recoginize the last require when use import and require in the same file HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-import.