-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
forEach is undefined when running import/namespace
#3099
Comments
What version of the import plugin are you using? |
it's possible it's coming from the angular eslint parser - can you narrow it down to what source code is causing the problem? |
@ljharb Modified the setup also. Seems like I need to import it as following to get it to work ...
const importPlugin = require("eslint-plugin-import");
module.exports = [
eslintConfigPrettier,
...tseslint.config(
{
files: ["**/*.ts"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended,
],
plugins: {
import: importPlugin,
},
... |
So you did get it to work? or are you saying it doesn't when you include the import rules? |
However it's not working for me on a new nx/angular project. It could very well be something related to angular-eslint, but I'm having trouble tracking it down. I have a minimal repro here: After cloning and
|
Looiking at the error, it appears to be linting an Try updating your config to something like this const nx = require('@nx/eslint-plugin');
const importPlugin = require('eslint-plugin-import');
module.exports = [
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
- importPlugin.flatConfigs.recommended,
+ {
+ files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
+ ...importPlugin.flatConfigs.recommended,
+ },
{
ignores: ['**/dist'],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
},
]; |
@michaelfaith Thank-you very much, that's solved my problem! If anybody else uses this plugin on an angular project, they're going to bump into this problem. What do you think would be the best? |
Since changing the |
You should be using an angular-specific eslint parser in an angular project, and you definitely need to be targeting files by extension in your own project. |
Thanks, with this solution, our issue is resolved. |
That'd be great, thanks! |
I'm trying to update to
ESLint 9
and switch over to the flat config.I'm getting the following error from
eslint-import-plugin
. Not sure why this is happening, so any help is appreciated.My flat eslint.config.js looks as following
The text was updated successfully, but these errors were encountered: