Skip to content
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

eslint.config.(js|mjs|cjs) is required for ESLint v9 and above #701

Open
tonypaulbarker opened this issue Jan 18, 2025 · 4 comments
Open

Comments

@tonypaulbarker
Copy link

tonypaulbarker commented Jan 18, 2025

Steps to repdoruce

Run npm run lint:js

Results in the output:

Oops! Something went wrong! :(

ESLint: 9.16.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

Proposted resolution

Add a minimal eslint.config.mjs file.

Note: For me, the tool from the above migration-guide led to errors, which may be valid.

import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
    baseDirectory: __dirname,
    recommendedConfig: js.configs.recommended,
    allConfig: js.configs.all
});
export default [...compat.extends("../../../core/.eslintrc.json")];

This minimal config below works to get the js lint to run for me, but I don't think it is importing the Drupal rules, we should confirm the output of the linter is as expected and picking up the rules from the Drupal core file.

import globals from "globals";
import pluginJs from "@eslint/js";


/** @type {import('eslint').Linter.Config[]} */
export default [
  {languageOptions: { globals: globals.browser }},
  pluginJs.configs.recommended,
];
@andybroomfield
Copy link
Contributor

Drupal (10) uses eslint 8. I was able to run this on localgov_alert_banner using npx eslint@8
See localgovdrupal/localgov_alert_banner#404

@tonypaulbarker
Copy link
Author

Thanks @andybroomfield that's a useful clue. Perhaps it bumped to 9 along the way to resolve some other dependencies.

@tonypaulbarker
Copy link
Author

tonypaulbarker commented Jan 21, 2025

I see similar errors with ESLint 8 and ESLint 9 with the generated code so I think it will be on the right lines.


Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "airbnb-base" to extend from. Please check that the name of the config is correct.

@andybroomfield
Copy link
Contributor

I think that might need to be installed by going to web/core and running npm install there.
There is also a branch to add front end tooling to ddev / lando.
localgovdrupal/localgov_project#184

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

No branches or pull requests

2 participants