Skip to content

eslint.config.js #3176

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

Closed
cristofermartins opened this issue Apr 4, 2025 · 4 comments
Closed

eslint.config.js #3176

cristofermartins opened this issue Apr 4, 2025 · 4 comments

Comments

@cristofermartins
Copy link

cristofermartins commented Apr 4, 2025

I only got it to work in eslint flat config files like this:

import { defineConfig } from "eslint/config";
import globals from "globals";
import js from "@eslint/js";
import pluginImport from "eslint-plugin-import";

export default defineConfig([
  { files: ["**/*.{js,mjs,cjs}"] },
  { files: ["**/*.{js,mjs,cjs}"], languageOptions: { globals: {...globals.browser, ...globals.node} } },
  { files: ["**/*.{js,mjs,cjs}"], plugins: { js, pluginImport }, extends: ["js/recommended"] },

	{
		rules: {
      // modules
      "pluginImport/no-mutable-exports": "error",
      "pluginImport/named": "error",
    },
	},
]);

It is working. The linting gives me an error when i try to export a let or a var.

i'm not using the pluginImport inside the extends array since i want to turn on each rule by my self.

Also when i use extends: ["js/recommended", pluginImport.flatConfigs.recommended] i'm able to use the import name inside the rules config, but the named rule starts to give me a problem:

1:30 error Unable to resolve path to module 'eslint/config' import/no-unresolved

I'm new to javascript and linting.
Thanks in advance.

@ljharb
Copy link
Member

ljharb commented Apr 4, 2025

That's an issue with eslint, not this plugin.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2025
@cristofermartins
Copy link
Author

@ljharb Hey, thanks for the answer. Do you know how i can fix this?

@ljharb
Copy link
Member

ljharb commented Apr 4, 2025

Ah, on a reread it seems like an issue with this plugin.

Specifically, we use resolve, which doesn't support exports yet. So, the best workaround in the meantime is an eslint override comment.

@JounQin
Copy link
Collaborator

JounQin commented Apr 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants