Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLINT 9: Cannot read config file: eslint.config.mjs. Error: end of the stream or a document separator is expected

generated eslint.config.mjs:

    import globals from "globals";
    import pluginJs from "@eslint/js";
    import tseslint from "typescript-eslint";
    
    
    export default [
      {languageOptions: { globals: globals.browser }},
      pluginJs.configs.recommended,
      ...tseslint.configs.recommended,
    ];

package.json eslint related packages:


    "@typescript-eslint/eslint-plugin": "^7.10.0",
    "@typescript-eslint/parser": "^7.10.0",
    "eslint": "^9.3.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-formatter-summary": "^1.1.0",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-lit": "^1.13.0",
    "eslint-plugin-sonarjs": "^1.0.3",
    "eslint-plugin-wc": "^2.1.0",
    "eslint-webpack-plugin": "^4.1.0"

Once I am running eslint on specific files/folders I am able to see the errors, rules / plugins are working. But, when I am getting on the build app stage of the application :

[PluginError: [eslint] Cannot read config file: eslint.config.mjs
Error: end of the stream or a document separator is expected (7:19)

 4 | 
 5 | 
 6 | export default [
 7 |   {languageOptions: { globals: globals.browser }},
-----------------------^
 8 |   pluginJs.configs.recommended,
 9 |   ...tseslint.configs.recommended,] {
  plugin: 'webpack-stream',
  showProperties: true,
  showStack: false,
  __safety: { toString: [Function: bound ] }
}
[19:04:14] assets by status 9.27 MiB [cached] 3 assets
  

ERROR in [eslint] Cannot read config file: eslint.config.mjs
Error: end of the stream or a document separator is expected (7:19)

 4 | 
 5 | 
 6 | export default [
 7 |   {languageOptions: { globals: globals.browser }},
-----------------------^
 8 |   pluginJs.configs.recommended,
 9 |   ...tseslint.configs.recommended,

Should there be any updates in Webpack config (for webpack eslint config) with this newest 9th ESLint version?

Configuration for webpack eslint config:

    new ESLintPlugin({
    quiet: true,
    failOnError: true,
    outputReport: true,
    overrideConfigFile: join(dirname, 'eslint.config.mjs'),
    exclude: [
      `model`,
      `dist`,
      `node_modules`,
      `buildlocales`
    ]
  }),
like image 945
AlexUA Avatar asked Feb 02 '26 08:02

AlexUA


1 Answers

Adding the line configType: 'flat' to Webpack ESLintPlugin configs did the trick for me (requested earlier but with a syntax error – remember to use camelCase)

like image 187
Sonja Ek Avatar answered Feb 03 '26 21:02

Sonja Ek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!